2 * Copyright 2003, 2004, 2005 Martin Fuchs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 // Martin Fuchs, 23.07.2003
31 /* We can't include webchild.h here - otherwise MinGW produces errors like: "multiple definition of `QACONTAINERFLAGS'"
34 extern HWND
create_webchildwindow(const WebChildWndInfo
& info
);
36 #include "../resource.h"
38 #include "../dialogs/settings.h" // for MdiSdiDlg
42 HWND
MainFrameBase::Create(const ExplorerCmd
& cmd
)
48 hFrame
= MDIMainFrame::Create();
51 hFrame
= SDIMainFrame::Create();
54 HWND hwndOld
= g_Globals
._hMainWnd
;
56 g_Globals
._hMainWnd
= hFrame
;
59 DestroyWindow(hwndOld
);
61 ShowWindow(hFrame
, cmd
._cmdShow
);
64 // Open the first child window after initializing the application
65 if (cmd
.IsValidPath()) {
66 // We use the static s_path variable to store the path string in order
67 // to avoid accessing prematurely freed memory in the PostMessage handlers.
68 static String s_path
= cmd
._path
;
70 PostMessage(hFrame
, PM_OPEN_WINDOW
, cmd
._flags
, (LPARAM
)(LPCTSTR
)s_path
);
72 PostMessage(hFrame
, PM_OPEN_WINDOW
, OWM_EXPLORE
|OWM_DETAILS
, 0);
79 int MainFrameBase::OpenShellFolders(LPIDA pida
, HWND hFrameWnd
)
83 LPCITEMIDLIST parent_pidl
= (LPCITEMIDLIST
) ((LPBYTE
)pida
+pida
->aoffset
[0]);
84 ShellFolder
folder(parent_pidl
);
85 LOG(FmtString(TEXT("MainFrameBase::OpenShellFolders(): parent_pidl=%s"), (LPCTSTR
)FileSysShellPath(parent_pidl
)));
87 for(int i
=pida
->cidl
; i
>0; --i
) {
88 LPCITEMIDLIST pidl
= (LPCITEMIDLIST
) ((LPBYTE
)pida
+pida
->aoffset
[i
]);
90 SFGAOF attribs
= SFGAO_FOLDER
;
91 HRESULT hr
= folder
->GetAttributesOf(1, &pidl
, &attribs
);
94 if (attribs
& SFGAO_FOLDER
) {
96 XMLPos explorer_options
= g_Globals
.get_cfg("general/explorer");
98 bool mdi
= XMLBool(explorer_options
, "mdi", true);
99 bool separateFolders
= XMLBool(explorer_options
, "separate-folders", false);
101 ShellPath pidl_abs
= ShellPath(pidl
).create_absolute_pidl(parent_pidl
);
102 LOG(FmtString(TEXT("MainFrameBase::OpenShellFolders(): pidl_abs=%s"), (LPCTSTR
)FileSysShellPath(pidl_abs
)));
104 if (hFrameWnd
&& (mdi
|| !separateFolders
)) {
105 int flags
= OWM_PIDL
;
108 flags
|= OWM_SEPARATE
;
110 if (SendMessage(hFrameWnd
, PM_OPEN_WINDOW
, flags
, (LPARAM
)(LPCITEMIDLIST
)pidl_abs
))
116 hwnd
= MDIMainFrame::Create(pidl_abs
, 0);
119 hwnd
= SDIMainFrame::Create(pidl_abs
, 0);
124 } catch(COMException
& e
) {
125 HandleException(e
, g_Globals
._hMainWnd
);
128 else { // !(attribs & SFGAO_FOLDER))
129 SHELLEXECUTEINFOA shexinfo;
131 shexinfo.cbSize = sizeof(SHELLEXECUTEINFOA);
132 shexinfo.fMask = SEE_MASK_INVOKEIDLIST;
133 shexinfo.hwnd = NULL;
134 shexinfo.lpVerb = NULL;
135 shexinfo.lpFile = NULL;
136 shexinfo.lpParameters = NULL;
137 shexinfo.lpDirectory = NULL;
138 shexinfo.nShow = SW_NORMAL;
139 shexinfo.lpIDList = ILCombine(parent_pidl, pidl);
141 if (ShellExecuteExA(&shexinfo))
144 ILFree((LPITEMIDLIST)shexinfo.lpIDList);
152 MainFrameBase::MainFrameBase(HWND hwnd
)
155 HDC hDC
= GetDC(NULL
);
157 //static TCHAR Title1[] = TEXT("Toolbar");
158 static TCHAR Title2
[] = TEXT("Address :");
164 INT bpp
= GetDeviceCaps(hDC
, BITSPIXEL
);
165 ReleaseDC(NULL
, hDC
);
172 ilMask
= ILC_COLOR16
;
174 ilMask
= ILC_COLOR24
;
176 ilMask
= ILC_COLOR32
;
182 _himl
= ImageList_Create(GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), ilMask
, 2, 0);
185 _hMenuFrame
= GetMenu(hwnd
);
186 _hMenuWindow
= GetSubMenu(_hMenuFrame
, GetMenuItemCount(_hMenuFrame
)-3);
188 _menu_info
._hMenuView
= GetSubMenu(_hMenuFrame
, 1);
190 _hAccel
= LoadAccelerators(g_Globals
._hInstance
, MAKEINTRESOURCE(IDA_EXPLORER
));
193 TBBUTTON toolbarBtns
[] = {
195 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
197 {7, ID_GO_BACK
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
198 {8, ID_GO_FORWARD
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
199 {9, ID_GO_UP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
200 {10, ID_GO_HOME
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
201 {11, ID_GO_SEARCH
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
202 {12, ID_REFRESH
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
203 {13, ID_STOP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0}
206 _htoolbar
= CreateToolbarEx(hwnd
,
208 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
210 WS_CHILD
|TBSTYLE_FLAT
|WS_VISIBLE
, IDW_TOOLBAR
, 2, g_Globals
._hInstance
, IDB_TOOLBAR
,
211 toolbarBtns
, sizeof(toolbarBtns
)/sizeof(TBBUTTON
),
212 16, 16, 16, 16, sizeof(TBBUTTON
));
214 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_TOOL_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
218 _haddrcombo
= CreateWindowEx(0,
221 WS_CHILD
|WS_TABSTOP
|WS_BORDER
|WS_VISIBLE
|CBS_DROPDOWN
|
222 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|CCS_NOMOVEY
,
225 (HMENU
)IDW_ADDRESSBAR
,
226 g_Globals
._hInstance
,
229 HFONT hFont
= (HFONT
)GetStockObject(ANSI_VAR_FONT
);
230 SendMessageW(_haddrcombo
, WM_SETFONT
, (WPARAM
)hFont
, 0);
233 _hstatusbar
= CreateStatusWindow(WS_CHILD
|WS_VISIBLE
, 0, hwnd
, IDW_STATUSBAR
);
234 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
236 _hsidebar
= CreateWindowEx(WS_EX_STATICEDGE
, WC_TREEVIEW
, TEXT("Sidebar"),
237 WS_CHILD
|WS_TABSTOP
|WS_BORDER
|/*WS_VISIBLE|*/WS_CHILD
|TVS_HASLINES
|TVS_HASBUTTONS
|TVS_SHOWSELALWAYS
|TVS_INFOTIP
,
238 -1, -1, 200, 0, _hwnd
, (HMENU
)IDW_SIDEBAR
, g_Globals
._hInstance
, 0);
240 _himl_old
= TreeView_SetImageList(_hsidebar
, _himl
, TVSIL_NORMAL
);
242 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_SIDE_BAR
, MF_BYCOMMAND
|MF_UNCHECKED
/*MF_CHECKED*/);
245 // create rebar window to manage toolbar and drivebar
247 _hwndrebar
= CreateWindowEx(WS_EX_TOOLWINDOW
,
250 WS_CHILD
|WS_VISIBLE
|WS_BORDER
|WS_CLIPSIBLINGS
|WS_CLIPCHILDREN
|
251 RBS_VARHEIGHT
|RBS_DBLCLKTOGGLE
| RBS_AUTOSIZE
|RBS_BANDBORDERS
,
255 g_Globals
._hInstance
,
258 int btn_hgt
= HIWORD(SendMessage(_htoolbar
, TB_GETBUTTONSIZE
, 0, 0));
260 REBARBANDINFO rbBand
;
262 rbBand
.cbSize
= sizeof(REBARBANDINFO
);
263 rbBand
.fMask
= RBBIM_TEXT
|RBBIM_STYLE
|RBBIM_CHILD
|RBBIM_CHILDSIZE
|RBBIM_SIZE
;
264 rbBand
.fStyle
= RBBS_CHILDEDGE
|RBBS_GRIPPERALWAYS
|RBBS_HIDETITLE
;
266 rbBand
.cxMinChild
= 0;
267 rbBand
.cyMinChild
= 0;
269 rbBand
.cyMaxChild
= 0;
270 rbBand
.cyIntegral
= btn_hgt
;
272 rbBand
.lpText
= NULL
;//Title1
273 rbBand
.hwndChild
= _htoolbar
;
274 rbBand
.cxMinChild
= 0;
275 rbBand
.cyMinChild
= btn_hgt
;
277 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)0, (LPARAM
)&rbBand
);
279 rbBand
.fStyle
&= ~RBBS_HIDETITLE
;
280 rbBand
.fStyle
|= RBBS_BREAK
;
281 rbBand
.lpText
= Title2
;
282 rbBand
.hwndChild
= _haddrcombo
;
283 rbBand
.cxMinChild
= 0;
284 rbBand
.cyMinChild
= btn_hgt
;
286 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)3, (LPARAM
)&rbBand
);
291 MainFrameBase::~MainFrameBase()
293 (void)TreeView_SetImageList(_hsidebar
, _himl_old
, TVSIL_NORMAL
);
294 ImageList_Destroy(_himl
);
296 // don't exit desktop when closing file manager window
297 if (!g_Globals
._desktop_mode
)
298 if (g_Globals
._hMainWnd
== _hwnd
) // don't quit when switching between MDI and SDI mode
303 LRESULT
MainFrameBase::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
307 if (ProcessMessage(nmsg
, wparam
, lparam
, &res
))
310 return super::WndProc(nmsg
, wparam
, lparam
);
313 bool MainFrameBase::ProcessMessage(UINT nmsg
, WPARAM wparam
, LPARAM lparam
, LRESULT
* pres
)
316 case PM_TRANSLATE_MSG
:
317 *pres
= TranslateMsg((MSG
*)lparam
);
321 if (wparam
) { // trigger child resizing after window creation - now we can succesfully call IsWindowVisible()
322 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
323 MoveWindow(_hwndrebar
, 0, 0, LOWORD(lparam
), height
, TRUE
);
324 resize_frame_client();
326 return false; // goto def;
329 DestroyWindow(_hwnd
);
330 g_Globals
._hMainWnd
= 0;
337 #ifdef __REACTOS__ ///@todo Work around to display rebar in ROS (with flickering) as long as the control isn't fixed
338 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
339 MoveWindow(_hwndrebar
, 0, 0, LOWORD(lparam
), height
, TRUE
);
341 resize_frame(LOWORD(lparam
), HIWORD(lparam
));
342 SendMessage(_hwndrebar
, WM_SIZE
, 0, 0);
346 break;} // do not pass message to DefFrameProc
348 case WM_GETMINMAXINFO
: {
349 LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
351 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
352 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
355 case PM_FRM_CALC_CLIENT
:
356 frame_get_clientspace((PRECT
)lparam
);
360 case PM_FRM_GET_MENUINFO
:
361 *pres
= (LPARAM
)&_menu_info
;
364 case PM_GET_CONTROLWINDOW
:
365 if (wparam
== FCW_STATUS
) {
366 *pres
= (LRESULT
)(HWND
)_hstatusbar
;
371 case PM_SETSTATUSTEXT
:
372 SendMessage(_hstatusbar
, SB_SETTEXT
, 0, lparam
);
375 case WM_SYSCOLORCHANGE
:
376 SendMessage(_hwndrebar
, WM_SYSCOLORCHANGE
, 0, 0);
377 SendMessage(_htoolbar
, WM_SYSCOLORCHANGE
, 0, 0);
388 BOOL
MainFrameBase::TranslateMsg(MSG
* pmsg
)
390 if (TranslateAccelerator(_hwnd
, _hAccel
, pmsg
))
397 int MainFrameBase::Command(int id
, int code
)
399 CONTEXT("MainFrameBase::Command()");
403 SendMessage(_hwnd
, WM_CLOSE
, 0, 0);
406 case ID_VIEW_TOOL_BAR
:
407 toggle_child(_hwnd
, id
, _htoolbar
, 0);
410 case ID_VIEW_STATUSBAR
:
411 toggle_child(_hwnd
, id
, _hstatusbar
);
414 case ID_VIEW_SIDE_BAR
:
415 // lazy initialization
416 if (!TreeView_GetCount(_hsidebar
))
419 toggle_child(_hwnd
, id
, _hsidebar
);
423 ExecuteDialog dlg
= {{0}, 0};
425 if (DialogBoxParam(g_Globals
._hInstance
, MAKEINTRESOURCE(IDD_EXECUTE
), _hwnd
, ExecuteDialog::WndProc
, (LPARAM
)&dlg
) == IDOK
) {
426 CONTEXT("ID_EXECUTE - ShellExecute()");
428 HINSTANCE hinst
= ShellExecute(_hwnd
, NULL
/*operation*/, dlg
.cmd
/*file*/, NULL
/*parameters*/, NULL
/*dir*/, dlg
.cmdshow
);
430 if ((int)hinst
<= 32)
431 display_error(_hwnd
, GetLastError());
436 WinHelp(_hwnd
, TEXT("explorer")/*file explorer.hlp*/, HELP_INDEX
, 0);
439 case ID_VIEW_FULLSCREEN
:
440 CheckMenuItem(_menu_info
._hMenuView
, id
, toggle_fullscreen()?MF_CHECKED
:0);
443 case ID_TOOLS_OPTIONS
:
444 Dialog::DoModal(IDD_MDI_SDI
, WINDOW_CREATOR(MdiSdiDlg
), _hwnd
);
447 case ID_ABOUT_WINDOWS
:
448 ShellAbout(_hwnd
, ResString(IDS_TITLE
), NULL
, 0);
451 case ID_ABOUT_EXPLORER
:
452 explorer_about(_hwnd
);
455 case ID_EXPLORER_FAQ
:
456 launch_file(_hwnd
, TEXT("http://www.sky.franken.de/explorer/"), SW_SHOW
);
460 return 1; // no command handlers in Window::Command()
466 int MainFrameBase::Notify(int id
, NMHDR
* pnmh
)
469 // resize children windows when the rebar size changes
472 resize_frame_client();
475 case TVN_GETINFOTIP
: {
476 NMTVGETINFOTIP
* pnmgit
= (NMTVGETINFOTIP
*)pnmh
;
478 if (pnmgit
->lParam
) {
479 const BookmarkNode
& node
= *(BookmarkNode
*)pnmgit
->lParam
;
481 if (node
._type
== BookmarkNode::BMNT_FOLDER
) {
482 // display tooltips for bookmark folders
483 if (!node
._pfolder
->_description
.empty())
484 lstrcpyn(pnmgit
->pszText
, node
._pfolder
->_description
.c_str(), pnmgit
->cchTextMax
);
485 } else if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
486 // display tooltips for bookmark folders
487 String txt
= node
._pbookmark
->_description
;
489 if (!node
._pbookmark
->_url
.empty()) {
493 txt
+= node
._pbookmark
->_url
;
496 lstrcpyn(pnmgit
->pszText
, txt
.c_str(), pnmgit
->cchTextMax
);
502 HTREEITEM hitem
= TreeView_GetSelection(_hsidebar
);
503 LPARAM lparam
= TreeView_GetItemData(_hsidebar
, hitem
);
506 const BookmarkNode
& node
= *(BookmarkNode
*)lparam
;
508 if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
509 bool new_window
= GetAsyncKeyState(VK_SHIFT
)<0;
511 go_to(node
._pbookmark
->_url
, new_window
);
521 void MainFrameBase::resize_frame(int cx
, int cy
)
524 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
526 RECT rect
= {0, 0, cx
, cy
};
529 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
533 SetWindowPos(_haddrcombo
, NULL
, 0, 0, cx
, height
, SWP_NOMOVE
);
535 if (IsWindowVisible(_htoolbar
)) {
536 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
537 WindowRect
rt(_htoolbar
);
538 rect
.top
= rt
.bottom
;
539 // rect.bottom -= rt.bottom;
543 if (IsWindowVisible(_hstatusbar
)) {
544 int parts
[] = {300, 500};
546 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
547 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
548 ClientRect
rt(_hstatusbar
);
549 rect
.bottom
-= rt
.bottom
;
552 if (IsWindowVisible(_hsidebar
)) {
553 WindowRect
rt(_hsidebar
);
554 rect
.left
+= rt
.right
-rt
.left
;
556 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
560 void MainFrameBase::resize_frame_client()
562 ClientRect
rect(_hwnd
);
564 resize_frame(rect
.right
, rect
.bottom
);
567 void MainFrameBase::frame_get_clientspace(PRECT prect
)
569 if (!IsIconic(_hwnd
))
570 GetClientRect(_hwnd
, prect
);
574 GetWindowPlacement(_hwnd
, &wp
);
576 prect
->left
= prect
->top
= 0;
577 prect
->right
= wp
.rcNormalPosition
.right
-wp
.rcNormalPosition
.left
-
578 2*(GetSystemMetrics(SM_CXSIZEFRAME
)+GetSystemMetrics(SM_CXEDGE
));
579 prect
->bottom
= wp
.rcNormalPosition
.bottom
-wp
.rcNormalPosition
.top
-
580 2*(GetSystemMetrics(SM_CYSIZEFRAME
)+GetSystemMetrics(SM_CYEDGE
))-
581 GetSystemMetrics(SM_CYCAPTION
)-GetSystemMetrics(SM_CYMENUSIZE
);
584 if (IsWindowVisible(_htoolbar
)) {
585 ClientRect
rt(_htoolbar
);
586 prect
->top
+= rt
.bottom
+2;
589 if (IsWindowVisible(_hstatusbar
)) {
590 ClientRect
rt(_hstatusbar
);
591 prect
->bottom
-= rt
.bottom
;
595 BOOL
MainFrameBase::toggle_fullscreen()
599 if ((_fullscreen
._mode
=!_fullscreen
._mode
)) {
600 GetWindowRect(_hwnd
, &_fullscreen
._orgPos
);
601 _fullscreen
._wasZoomed
= IsZoomed(_hwnd
);
603 Frame_CalcFrameClient(_hwnd
, &rt
);
604 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.left
);
605 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.right
);
607 rt
.left
= _fullscreen
._orgPos
.left
-rt
.left
;
608 rt
.top
= _fullscreen
._orgPos
.top
-rt
.top
;
609 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+_fullscreen
._orgPos
.right
-rt
.right
;
610 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+_fullscreen
._orgPos
.bottom
-rt
.bottom
;
612 MoveWindow(_hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
614 MoveWindow(_hwnd
, _fullscreen
._orgPos
.left
, _fullscreen
._orgPos
.top
,
615 _fullscreen
._orgPos
.right
-_fullscreen
._orgPos
.left
,
616 _fullscreen
._orgPos
.bottom
-_fullscreen
._orgPos
.top
, TRUE
);
618 if (_fullscreen
._wasZoomed
)
619 ShowWindow(_hwnd
, WS_MAXIMIZE
);
622 return _fullscreen
._mode
;
625 void MainFrameBase::fullscreen_move()
628 GetWindowRect(_hwnd
, &pos
);
630 Frame_CalcFrameClient(_hwnd
, &rt
);
631 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.left
);
632 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.right
);
634 rt
.left
= pos
.left
-rt
.left
;
635 rt
.top
= pos
.top
-rt
.top
;
636 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+pos
.right
-rt
.right
;
637 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+pos
.bottom
-rt
.bottom
;
639 MoveWindow(_hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
643 void MainFrameBase::toggle_child(HWND hwnd
, UINT cmd
, HWND hchild
, int band_idx
)
645 BOOL vis
= IsWindowVisible(hchild
);
647 CheckMenuItem(_menu_info
._hMenuView
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
650 SendMessage(_hwndrebar
, RB_SHOWBAND
, band_idx
, !vis
);
652 ShowWindow(hchild
, vis
? SW_HIDE
: SW_SHOW
);
654 if (_fullscreen
._mode
)
657 resize_frame_client();
660 void MainFrameBase::FillBookmarks()
662 HiddenWindow
hide(_hsidebar
);
663 WindowCanvas
canvas(_hwnd
);
665 TreeView_DeleteAllItems(_hsidebar
);
667 g_Globals
._icon_cache
.get_icon(ICID_FAVORITES
).add_to_imagelist(_himl
, canvas
);
668 g_Globals
._icon_cache
.get_icon(ICID_BOOKMARK
).add_to_imagelist(_himl
, canvas
);
669 ImageList_AddAlphaIcon(_himl
, SmallIcon(IDI_DOT
), GetStockBrush(WHITE_BRUSH
), canvas
);
670 g_Globals
._icon_cache
.get_icon(ICID_FOLDER
).add_to_imagelist(_himl
, canvas
);
671 g_Globals
._icon_cache
.get_icon(ICID_FOLDER
).add_to_imagelist(_himl
, canvas
);
675 tvi
.hParent
= TVI_ROOT
;
676 tvi
.hInsertAfter
= TVI_LAST
;
677 tvi
.item
.mask
= TVIF_TEXT
|TVIF_IMAGE
|TVIF_SELECTEDIMAGE
;
678 ResString
sFavorites(IDS_FAVORITES
);
679 tvi
.item
.pszText
= sFavorites
.str();
680 tvi
.item
.iSelectedImage
= tvi
.item
.iImage
= 0;
682 HTREEITEM hitem_bookmarks
= TreeView_InsertItem(_hsidebar
, &tvi
);
684 g_Globals
._favorites
.fill_tree(_hsidebar
, hitem_bookmarks
, _himl
, canvas
);
686 TreeView_Expand(_hsidebar
, hitem_bookmarks
, TVE_EXPAND
);
690 bool MainFrameBase::go_to(LPCTSTR url
, bool new_window
)
692 ///@todo SDI implementation
700 MDIMainFrame::MDIMainFrame(HWND hwnd
)
703 TBBUTTON mdiBtns
[] = {
704 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
705 {0, ID_WINDOW_NEW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
706 {1, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
707 {2, ID_WINDOW_TILE_HORZ
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
708 {3, ID_WINDOW_TILE_VERT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0}
711 SendMessage(_htoolbar
, TB_ADDBUTTONS
, sizeof(mdiBtns
)/sizeof(TBBUTTON
), (LPARAM
)&mdiBtns
);
713 CLIENTCREATESTRUCT ccs
;
715 ccs
.hWindowMenu
= _hMenuWindow
;
716 ccs
.idFirstChild
= IDW_FIRST_CHILD
;
718 _hmdiclient
= CreateWindowEx(WS_EX_CLIENTEDGE
|WS_EX_NOPARENTNOTIFY
, TEXT("MDICLIENT"), NULL
,
719 WS_CHILD
|WS_CLIPCHILDREN
|WS_VSCROLL
|WS_HSCROLL
|WS_VISIBLE
|WS_BORDER
,
721 hwnd
, 0, g_Globals
._hInstance
, &ccs
);
723 TBBUTTON extraBtns
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
726 _hextrabar
= CreateToolbarEx(hwnd
,
727 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
728 WS_CHILD
|TBSTYLE_FLAT
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,
729 IDW_EXTRABAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, NULL
, 0,
730 16, 16, 16, 16, sizeof(TBBUTTON
));
732 _hextrabar
= CreateToolbarEx(hwnd
,
733 WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,CCS_NODIVIDER
|
734 IDW_EXTRABAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, &extraBtns
, 1,
735 16, 13, 16, 13, sizeof(TBBUTTON
));
738 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_EXTRA_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
741 extraBtns
.fsStyle
= BTNS_BUTTON
;
744 // insert unix file system button
745 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("/\0"));
746 extraBtns
.idCommand
= ID_DRIVE_UNIX_FS
;
747 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
750 // insert explorer window button
751 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Explore\0"));
752 extraBtns
.idCommand
= ID_DRIVE_DESKTOP
;
753 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
755 // insert shell namespace button
756 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Shell\0"));
757 extraBtns
.idCommand
= ID_DRIVE_SHELL_NS
;
758 extraBtns
.iBitmap
= 6;
759 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
761 // insert web control button
762 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Web\0"));
763 extraBtns
.idCommand
= ID_WEB_WINDOW
;
764 extraBtns
.iBitmap
= 7;
765 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
767 if ((HIWORD(GetVersion())>>14) == W_VER_NT
) {
768 // insert NT object namespace button
769 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("NT Obj\0"));
770 extraBtns
.idCommand
= ID_DRIVE_NTOBJ_NS
;
771 extraBtns
.iBitmap
= 8;
772 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
774 #ifndef __REACTOS__ // don't insert reg button for ROS. Regedit should be used.
775 // insert Registry button
776 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Reg.\0"));
777 extraBtns
.idCommand
= ID_DRIVE_REGISTRY
;
778 extraBtns
.iBitmap
= 9;
779 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
783 // insert FAT direct file system access button
784 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("FAT\0"));
785 extraBtns
.idCommand
= ID_DRIVE_FAT
;
786 extraBtns
.iBitmap
= 10;
787 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
791 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
796 _hdrivebar
= CreateToolbarEx(hwnd
,
797 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
798 WS_CHILD
|WS_VISIBLE
|TBSTYLE_FLAT
|CCS_NOMOVEY
|TBSTYLE_LIST
,
799 IDW_DRIVEBAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, NULL
, 0,
800 16, 16, 16, 16, sizeof(TBBUTTON
));
802 _hdrivebar
= CreateToolbarEx(hwnd
,
803 WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
|CCS_NODIVIDER
,
804 IDW_DRIVEBAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, &drivebarBtn
, 1,
805 16, 13, 16, 13, sizeof(TBBUTTON
));
809 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_DRIVE_BAR
, MF_BYCOMMAND
|MF_UNCHECKED
);
813 GetLogicalDriveStrings(BUFFER_LEN
, _drives
);
815 // register windows drive root strings
816 SendMessage(_hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)_drives
);
818 drivebarBtn
.fsStyle
= BTNS_BUTTON
;
819 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
821 for(p
=_drives
; *p
; ) {
822 switch(GetDriveType(p
)) {
823 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
824 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
825 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
826 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
827 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
830 SendMessage(_hdrivebar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&drivebarBtn
);
831 ++drivebarBtn
.idCommand
;
832 ++drivebarBtn
.iString
;
840 int btn_hgt
= HIWORD(SendMessage(_htoolbar
, TB_GETBUTTONSIZE
, 0, 0));
842 REBARBANDINFO rbBand
;
844 rbBand
.cbSize
= sizeof(REBARBANDINFO
);
845 rbBand
.fMask
= RBBIM_TEXT
|RBBIM_STYLE
|RBBIM_CHILD
|RBBIM_CHILDSIZE
|RBBIM_SIZE
;
846 #ifndef RBBS_HIDETITLE // missing in MinGW headers as of 25.02.2004
847 #define RBBS_HIDETITLE 0x400
849 rbBand
.fStyle
= RBBS_CHILDEDGE
|RBBS_GRIPPERALWAYS
|RBBS_HIDETITLE
;
851 TCHAR ExtrasBand
[] = _T("Extras");
852 rbBand
.lpText
= ExtrasBand
;
853 rbBand
.hwndChild
= _hextrabar
;
854 rbBand
.cxMinChild
= 0;
855 rbBand
.cyMinChild
= btn_hgt
;
857 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)1, (LPARAM
)&rbBand
);
860 rbBand
.fStyle
|= RBBS_BREAK
;
861 TCHAR DrivesBand
[] = _T("Drives");
862 rbBand
.lpText
= DrivesBand
;
863 rbBand
.hwndChild
= _hdrivebar
;
864 rbBand
.cxMinChild
= 0;
865 rbBand
.cyMinChild
= btn_hgt
;
867 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)2, (LPARAM
)&rbBand
);
869 // hide the drivebar by default
870 SendMessage(_hwndrebar
, RB_SHOWBAND
, 2, FALSE
);
876 HWND
MDIMainFrame::Create()
878 HMENU hMenuFrame
= LoadMenu(g_Globals
._hInstance
, MAKEINTRESOURCE(IDM_MDIFRAME
));
880 return Window::Create(WINDOW_CREATOR(MDIMainFrame
), 0,
881 (LPCTSTR
)(int)g_Globals
._hframeClass
, ResString(IDS_TITLE
), WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
,
882 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
883 0/*hwndDesktop*/, hMenuFrame
);
886 HWND
MDIMainFrame::Create(LPCTSTR path
, int mode
)
888 HWND hFrame
= Create();
892 ShowWindow(hFrame
, SW_SHOW
);
894 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
897 pMainFrame
->CreateChild(path
, mode
);
902 HWND
MDIMainFrame::Create(LPCITEMIDLIST pidl
, int mode
)
904 HWND hFrame
= Create();
908 ShowWindow(hFrame
, SW_SHOW
);
910 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
913 pMainFrame
->CreateChild(pidl
, mode
);
919 ChildWindow
* MDIMainFrame::CreateChild(LPCTSTR path
, int mode
)
921 return reinterpret_cast<ChildWindow
*>(SendMessage(_hwnd
, PM_OPEN_WINDOW
, mode
, (LPARAM
)path
));
924 ChildWindow
* MDIMainFrame::CreateChild(LPCITEMIDLIST pidl
, int mode
)
926 return reinterpret_cast<ChildWindow
*>(SendMessage(_hwnd
, PM_OPEN_WINDOW
, mode
|OWM_PIDL
, (LPARAM
)pidl
));
930 BOOL
MDIMainFrame::TranslateMsg(MSG
* pmsg
)
932 if (_hmdiclient
&& TranslateMDISysAccel(_hmdiclient
, pmsg
))
935 return super::TranslateMsg(pmsg
);
938 LRESULT
MDIMainFrame::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
941 case PM_OPEN_WINDOW
: {
942 CONTEXT("MDIMainFrame PM_OPEN_WINDOW");
944 TCHAR buffer
[MAX_PATH
];
946 ShellPath shell_path
= DesktopFolderPath();
949 if (wparam
& OWM_PIDL
) {
950 // take over PIDL from lparam
951 shell_path
.assign((LPCITEMIDLIST
)lparam
); // create as "rooted" window
952 FileSysShellPath
fsp(shell_path
);
956 LOG(FmtString(TEXT("MDIMainFrame PM_OPEN_WINDOW: path=%s"), path
));
957 lstrcpy(buffer
, path
);
961 // take over path from lparam
962 path
= (LPCTSTR
)lparam
;
963 shell_path
= path
; // create as "rooted" window
966 ///@todo read paths and window placements from registry
967 if (!GetCurrentDirectory(MAX_PATH
, buffer
))
973 if (path
&& _tcsstr(path
, TEXT("://"))) { // "http://...", "ftp://", ...
974 OBJ_CONTEXT("create WebChild window", path
);
976 return (LRESULT
)GET_WINDOW(ChildWindow
, create_webchildwindow(WebChildWndInfo(_hmdiclient
, path
)));
978 OBJ_CONTEXT("create ShellChildWndInfo", path
);
980 // Shell Namespace as default view
981 ShellChildWndInfo
create_info(_hmdiclient
, path
, shell_path
);
983 if (wparam
& OWM_ROOTED
)
984 create_info
._root_shell_path
= shell_path
;
986 create_info
._root_shell_path
= DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
988 create_info
._pos
.showCmd
= wparam
&OWM_SEPARATE
? SW_SHOWNORMAL
: SW_SHOWMAXIMIZED
;
989 create_info
._pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
990 create_info
._pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
991 create_info
._pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
992 create_info
._pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
994 create_info
._open_mode
= wparam
;
996 // FileChildWindow::create(_hmdiclient, create_info);
997 return (LRESULT
)MDIShellBrowserChild::create(create_info
);
999 return TRUE
;} // success
1001 case WM_SYSCOLORCHANGE
: {
1005 /* Forward WM_SYSCOLORCHANGE to common controls */
1006 SendMessage(_hextrabar
, WM_SYSCOLORCHANGE
, 0, 0);
1007 SendMessage(_hdrivebar
, WM_SYSCOLORCHANGE
, 0, 0);
1009 for(hChild
= GetNextWindow(_hmdiclient
,GW_CHILD
); hChild
; hChild
= GetNextWindow(hChild
, GW_HWNDNEXT
))
1010 SendMessage(hChild
, WM_SYSCOLORCHANGE
, 0, 0);
1012 super::ProcessMessage(nmsg
, wparam
, lparam
, &res
);
1018 if (super::ProcessMessage(nmsg
, wparam
, lparam
, &res
))
1021 return DefFrameProc(_hwnd
, _hmdiclient
, nmsg
, wparam
, lparam
);
1028 int MDIMainFrame::Command(int id
, int code
)
1030 CONTEXT("MDIMainFrame::Command()");
1032 HWND hwndClient
= (HWND
) SendMessage(_hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1035 if (SendMessage(hwndClient
, PM_DISPATCH_COMMAND
, MAKELONG(id
,code
), 0))
1039 if (id
>=ID_DRIVE_FIRST
&& id
<=ID_DRIVE_FIRST
+0xFF) {
1040 TCHAR drv
[_MAX_DRIVE
], path
[MAX_PATH
];
1041 LPCTSTR root
= _drives
;
1043 for(int i
=id
-ID_DRIVE_FIRST
; i
--; root
++)
1047 if (activate_drive_window(root
))
1050 _tsplitpath_s(root
, drv
, COUNTOF(drv
), NULL
, 0, NULL
, 0, NULL
, 0);
1052 if (!SetCurrentDirectory(drv
)) {
1053 display_error(_hwnd
, GetLastError());
1057 GetCurrentDirectory(MAX_PATH
, path
); ///@todo store last directory per drive
1059 FileChildWindow::create(FileChildWndInfo(_hmdiclient
, path
));
1066 case ID_WINDOW_NEW
: {
1067 TCHAR path
[MAX_PATH
];
1069 GetCurrentDirectory(MAX_PATH
, path
);
1071 FileChildWindow::create(FileChildWndInfo(_hmdiclient
, path
));
1074 case ID_WINDOW_CASCADE
:
1075 SendMessage(_hmdiclient
, WM_MDICASCADE
, 0, 0);
1078 case ID_WINDOW_TILE_HORZ
:
1079 SendMessage(_hmdiclient
, WM_MDITILE
, MDITILE_HORIZONTAL
, 0);
1082 case ID_WINDOW_TILE_VERT
:
1083 SendMessage(_hmdiclient
, WM_MDITILE
, MDITILE_VERTICAL
, 0);
1086 case ID_WINDOW_ARRANGE
:
1087 SendMessage(_hmdiclient
, WM_MDIICONARRANGE
, 0, 0);
1090 case ID_VIEW_EXTRA_BAR
:
1091 toggle_child(_hwnd
, id
, _hextrabar
, 1);
1095 case ID_VIEW_DRIVE_BAR
:
1096 toggle_child(_hwnd
, id
, _hdrivebar
, 2);
1101 case ID_DRIVE_UNIX_FS
: {
1102 TCHAR path
[MAX_PATH
];
1103 FileChildWindow
* child
;
1105 getcwd(path
, COUNTOF(path
));
1107 if (activate_child_window(TEXT("unixfs")))
1110 FileChildWindow::create(_hmdiclient
, FileChildWndInfo(path
));
1114 case ID_DRIVE_DESKTOP
: {
1115 TCHAR path
[MAX_PATH
];
1117 if (activate_child_window(TEXT("Desktop")))
1120 GetCurrentDirectory(MAX_PATH
, path
);
1122 MDIShellBrowserChild::create(ShellChildWndInfo(_hmdiclient
, path
, DesktopFolderPath()));
1125 case ID_DRIVE_SHELL_NS
: {
1126 TCHAR path
[MAX_PATH
];
1127 GetCurrentDirectory(MAX_PATH
, path
);
1129 if (activate_child_window(TEXT("Shell")))
1132 FileChildWindow::create(ShellChildWndInfo(_hmdiclient
, path
, DesktopFolderPath()));
1135 case ID_DRIVE_NTOBJ_NS
: {
1136 if (activate_child_window(TEXT("NTOBJ")))
1139 FileChildWindow::create(NtObjChildWndInfo(_hmdiclient
, TEXT("\\")));
1142 case ID_DRIVE_REGISTRY
: {
1143 if (activate_child_window(TEXT("Registry")))
1146 FileChildWindow::create(RegistryChildWndInfo(_hmdiclient
, TEXT("\\")));
1149 case ID_DRIVE_FAT
: {
1151 ///@todo prompt for image file
1153 if (activate_child_window(TEXT("FAT")))
1156 FileChildWindow::create(FATChildWndInfo(_hmdiclient
, TEXT("FAT Image"))); //@@
1161 create_webchildwindow(WebChildWndInfo(_hmdiclient
, TEXT("http://localhost")));
1163 create_webchildwindow(WebChildWndInfo(_hmdiclient
, TEXT("http://www.reactos.org")));
1167 case ID_EXPLORER_FAQ
:
1168 create_webchildwindow(WebChildWndInfo(_hmdiclient
, TEXT("http://www.sky.franken.de/explorer/")));
1172 MainFrameBase::Create(ExplorerCmd());
1175 ///@todo There are even more menu items!
1178 if (super::Command(id
, code
) == 0)
1181 return DefFrameProc(_hwnd
, _hmdiclient
, WM_COMMAND
, MAKELONG(id
,code
), 0);
1188 void MDIMainFrame::frame_get_clientspace(PRECT prect
)
1190 super::frame_get_clientspace(prect
);
1193 if (IsWindowVisible(_hdrivebar
)) {
1194 ClientRect
rt(_hdrivebar
);
1195 prect
->top
+= rt
.bottom
+2;
1200 void MDIMainFrame::resize_frame(int cx
, int cy
)
1203 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
1205 RECT rect
= {0, 0, cx
, cy
};
1208 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
1212 if (IsWindowVisible(_htoolbar
)) {
1213 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
1214 WindowRect
rt(_htoolbar
);
1215 rect
.top
= rt
.bottom
;
1216 // rect.bottom -= rt.bottom;
1219 if (IsWindowVisible(_hextrabar
)) {
1220 SendMessage(_hextrabar
, WM_SIZE
, 0, 0);
1221 WindowRect
rt(_hextrabar
);
1222 int new_top
= --rect
.top
+ rt
.bottom
;
1223 MoveWindow(_hextrabar
, 0, rect
.top
, rt
.right
, new_top
, TRUE
);
1225 // rect.bottom -= rt.bottom;
1229 if (IsWindowVisible(_hdrivebar
)) {
1230 SendMessage(_hdrivebar
, WM_SIZE
, 0, 0);
1231 WindowRect
rt(_hdrivebar
);
1232 int new_top
= --rect
.top
+ rt
.bottom
;
1233 MoveWindow(_hdrivebar
, 0, rect
.top
, rt
.right
, new_top
, TRUE
);
1235 // rect.bottom -= rt.bottom;
1240 if (IsWindowVisible(_hstatusbar
)) {
1241 int parts
[] = {300, 500};
1243 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
1244 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1245 ClientRect
rt(_hstatusbar
);
1246 rect
.bottom
-= rt
.bottom
;
1249 if (IsWindowVisible(_hsidebar
)) {
1250 WindowRect
rt(_hsidebar
);
1251 rect
.left
+= rt
.right
-rt
.left
;
1253 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
1256 MoveWindow(_hmdiclient
, rect
.left
-1, rect
.top
-1, rect
.right
-rect
.left
+1, rect
.bottom
-rect
.top
+1, TRUE
);
1259 bool MDIMainFrame::activate_drive_window(LPCTSTR path
)
1261 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
1264 _tsplitpath_s(path
, drv1
, COUNTOF(drv1
), NULL
, 0, NULL
, 0, NULL
, 0);
1266 // search for a already open window for the same drive
1267 for(child_wnd
=GetNextWindow(_hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1268 FileChildWindow
* child
= (FileChildWindow
*) SendMessage(child_wnd
, PM_GET_FILEWND_PTR
, 0, 0);
1271 _tsplitpath_s(child
->get_root()._path
, drv2
, COUNTOF(drv2
), NULL
, 0, NULL
, 0, NULL
, 0);
1273 if (!lstrcmpi(drv2
, drv1
)) {
1274 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1276 if (IsMinimized(child_wnd
))
1277 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1287 bool MDIMainFrame::activate_child_window(LPCTSTR filesys
)
1291 // search for a already open window of the given file system name
1292 for(child_wnd
=GetNextWindow(_hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1293 FileChildWindow
* child
= (FileChildWindow
*) SendMessage(child_wnd
, PM_GET_FILEWND_PTR
, 0, 0);
1296 if (!lstrcmpi(child
->get_root()._fs
, filesys
)) {
1297 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1299 if (IsMinimized(child_wnd
))
1300 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1305 ShellBrowser
* shell_child
= (ShellBrowser
*) SendMessage(child_wnd
, PM_GET_SHELLBROWSER_PTR
, 0, 0);
1308 if (!lstrcmpi(shell_child
->get_root()._fs
, filesys
)) {
1309 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1311 if (IsMinimized(child_wnd
))
1312 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1323 bool MDIMainFrame::go_to(LPCTSTR url
, bool new_window
)
1326 HWND hwndClient
= (HWND
) SendMessage(_hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1329 if (SendMessage(hwndClient
, PM_JUMP_TO_URL
, 0, (LPARAM
)url
))
1333 if (CreateChild(url
))
1336 return super::go_to(url
, new_window
);
1342 SDIMainFrame::SDIMainFrame(HWND hwnd
)
1345 _split_pos
= DEFAULT_SPLIT_POS
;
1346 _last_split
= DEFAULT_SPLIT_POS
;
1348 /* wait for PM_OPEN_WINDOW message before creating a shell view
1349 update_shell_browser();*/
1352 HWND
SDIMainFrame::Create()
1354 HMENU hMenuFrame
= LoadMenu(g_Globals
._hInstance
, MAKEINTRESOURCE(IDM_SDIFRAME
));
1356 return Window::Create(WINDOW_CREATOR(SDIMainFrame
), 0,
1357 (LPCTSTR
)(int)g_Globals
._hframeClass
, ResString(IDS_TITLE
), WS_OVERLAPPEDWINDOW
,
1358 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
1359 0/*hwndDesktop*/, hMenuFrame
);
1362 HWND
SDIMainFrame::Create(LPCITEMIDLIST pidl
, int mode
)
1364 HWND hFrame
= Create();
1368 ShowWindow(hFrame
, SW_SHOW
);
1370 SDIMainFrame
* pFrame
= GET_WINDOW(SDIMainFrame
, hFrame
);
1373 pFrame
->jump_to(pidl
, mode
);
1378 HWND
SDIMainFrame::Create(LPCTSTR path
, int mode
)
1380 HWND hFrame
= Create();
1384 ShowWindow(hFrame
, SW_SHOW
);
1386 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
1389 pMainFrame
->CreateChild(path
, mode
);
1394 LRESULT
SDIMainFrame::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1398 resize_frame(LOWORD(lparam
), HIWORD(lparam
));
1402 PaintCanvas
canvas(_hwnd
);
1405 ClientRect
rt(_hwnd
);
1406 rt
.left
= _split_pos
-SPLIT_WIDTH
/2;
1407 rt
.right
= _split_pos
+SPLIT_WIDTH
/2+1;
1410 WindowRect
right_rect(_right_hwnd
);
1411 ScreenToClient(_hwnd
, &right_rect
);
1412 rt
.top
= right_rect
.top
;
1413 rt
.bottom
= right_rect
.bottom
;
1416 HBRUSH lastBrush
= SelectBrush(canvas
, GetStockBrush(COLOR_SPLITBAR
));
1417 Rectangle(canvas
, rt
.left
, rt
.top
-1, rt
.right
, rt
.bottom
+1);
1418 SelectObject(canvas
, lastBrush
);
1424 if (LOWORD(lparam
) == HTCLIENT
) {
1427 ScreenToClient(_hwnd
, &pt
);
1429 if (pt
.x
>=_split_pos
-SPLIT_WIDTH
/2 && pt
.x
<_split_pos
+SPLIT_WIDTH
/2+1) {
1430 SetCursor(LoadCursor(0, IDC_SIZEWE
));
1436 case WM_LBUTTONDOWN
:
1438 int x
= GET_X_LPARAM(lparam
);
1440 ClientRect
rt(_hwnd
);
1442 if (x
>=_split_pos
-SPLIT_WIDTH
/2 && x
<_split_pos
+SPLIT_WIDTH
/2+1) {
1443 _last_split
= _split_pos
;
1450 if (GetCapture() == _hwnd
)
1455 if (wparam
== VK_ESCAPE
)
1456 if (GetCapture() == _hwnd
) {
1457 _split_pos
= _last_split
;
1461 SetCursor(LoadCursor(0, IDC_ARROW
));
1466 if (GetCapture() == _hwnd
) {
1467 int x
= GET_X_LPARAM(lparam
);
1469 ClientRect
rt(_hwnd
);
1471 if (x
>=0 && x
<rt
.right
) {
1474 rt
.left
= x
-SPLIT_WIDTH
/2;
1475 rt
.right
= x
+SPLIT_WIDTH
/2+1;
1476 InvalidateRect(_hwnd
, &rt
, FALSE
);
1477 UpdateWindow(_left_hwnd
);
1478 UpdateWindow(_hwnd
);
1479 UpdateWindow(_right_hwnd
);
1484 case PM_OPEN_WINDOW
: {
1485 CONTEXT("SDIMainFrame PM_OPEN_WINDOW");
1487 TCHAR buffer
[MAX_PATH
];
1489 ShellPath shell_path
= DesktopFolderPath();
1492 if (wparam
& OWM_PIDL
) {
1493 // take over PIDL from lparam
1494 shell_path
.assign((LPCITEMIDLIST
)lparam
); // create as "rooted" window
1495 FileSysShellPath
fsp(shell_path
);
1499 LOG(FmtString(TEXT("SDIMainFrame PM_OPEN_WINDOW: path=%s"), path
));
1500 lstrcpy(buffer
, path
);
1504 // take over path from lparam
1505 path
= (LPCTSTR
)lparam
;
1506 shell_path
= path
; // create as "rooted" window
1509 ///@todo read paths and window placements from registry
1510 if (!GetCurrentDirectory(MAX_PATH
, buffer
))
1517 if (wparam
& OWM_ROOTED
)
1518 _shellpath_info
._root_shell_path
= shell_path
;
1520 _shellpath_info
._root_shell_path
= DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
1522 jump_to(shell_path
, wparam
); ///@todo content of 'path' not used any more
1523 return TRUE
;} // success
1526 return super::WndProc(nmsg
, wparam
, lparam
);
1532 int SDIMainFrame::Command(int id
, int code
)
1536 MainFrameBase::Create(ExplorerCmd(_url
, true));
1540 return super::Command(id
, code
);
1546 void SDIMainFrame::resize_frame(int cx
, int cy
)
1549 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
1551 RECT rect
= {0, 0, cx
, cy
};
1554 int height
= ClientRect(_hwndrebar
).bottom
;
1558 if (IsWindowVisible(_htoolbar
)) {
1559 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
1560 WindowRect
rt(_htoolbar
);
1561 rect
.top
= rt
.bottom
;
1562 // rect.bottom -= rt.bottom;
1566 if (IsWindowVisible(_hstatusbar
)) {
1567 int parts
[] = {300, 500};
1569 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
1570 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1571 ClientRect
rt(_hstatusbar
);
1572 rect
.bottom
-= rt
.bottom
;
1575 if (IsWindowVisible(_hsidebar
)) {
1576 WindowRect
rt(_hsidebar
);
1577 rect
.left
+= rt
.right
-rt
.left
;
1579 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
1587 void SDIMainFrame::resize_children()
1589 HDWP hdwp
= BeginDeferWindowPos(2);
1591 int cx
= _clnt_rect
.left
;
1594 cx
= _split_pos
+ SPLIT_WIDTH
/2;
1596 hdwp
= DeferWindowPos(hdwp
, _left_hwnd
, 0, _clnt_rect
.left
, _clnt_rect
.top
, _split_pos
-SPLIT_WIDTH
/2-_clnt_rect
.left
, _clnt_rect
.bottom
-_clnt_rect
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
1603 hdwp
= DeferWindowPos(hdwp
, _right_hwnd
, 0, _clnt_rect
.left
+cx
+1, _clnt_rect
.top
, _clnt_rect
.right
-cx
, _clnt_rect
.bottom
-_clnt_rect
.top
, SWP_NOZORDER
|SWP_NOACTIVATE
);
1605 EndDeferWindowPos(hdwp
);
1608 void SDIMainFrame::update_clnt_rect()
1610 ClientRect
rect(_hwnd
);
1612 resize_frame(rect
.right
, rect
.bottom
);
1615 void SDIMainFrame::update_shell_browser()
1617 int split_pos
= DEFAULT_SPLIT_POS
;
1619 if (_shellBrowser
.get()) {
1620 split_pos
= _split_pos
;
1621 delete _shellBrowser
.release();
1624 // create explorer treeview
1625 if (_shellpath_info
._open_mode
& OWM_EXPLORE
) {
1627 ClientRect
rect(_hwnd
);
1629 _left_hwnd
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, NULL
,
1630 WS_CHILD
|WS_TABSTOP
|WS_VISIBLE
|TVS_HASLINES
|TVS_LINESATROOT
|TVS_HASBUTTONS
|TVS_NOTOOLTIPS
|TVS_SHOWSELALWAYS
,
1631 0, rect
.top
, split_pos
-SPLIT_WIDTH
/2, rect
.bottom
-rect
.top
,
1632 _hwnd
, (HMENU
)IDC_FILETREE
, g_Globals
._hInstance
, 0);
1634 // display tree window as long as the shell view is not yet visible
1635 resize_frame(rect
.right
, rect
.bottom
);
1636 MoveWindow(_left_hwnd
, rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
1640 DestroyWindow(_left_hwnd
);
1645 _shellBrowser
= auto_ptr
<ShellBrowser
>(new ShellBrowser(_hwnd
, _hwnd
, _left_hwnd
, _right_hwnd
,
1646 _shellpath_info
, this, _cm_ifs
));
1649 _shellBrowser
->Init();
1651 // update _clnt_rect and set size of new created shell view windows
1655 void SDIMainFrame::entry_selected(Entry
* entry
)
1658 _shellBrowser
->select_folder(entry
, false);
1660 _shellBrowser
->UpdateFolderView(entry
->get_shell_folder());
1662 // set size of new created shell view windows
1666 void SDIMainFrame::set_url(LPCTSTR url
)
1670 SetWindowText(_haddrcombo
, url
);
1675 void SDIMainFrame::jump_to(LPCTSTR path
, int mode
)
1677 if (_shellBrowser.get() && (_shellpath_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) {
1678 _shellBrowser->jump_to(path);
1680 _shellpath_info._shell_path = path;
1682 _shellpath_info
._open_mode
= mode
;
1683 _shellpath_info
._shell_path
= path
;
1685 update_shell_browser();
1689 void SDIMainFrame::jump_to(LPCITEMIDLIST path
, int mode
)
1691 if (_shellBrowser
.get() && (_shellpath_info
._open_mode
&~OWM_PIDL
)==(mode
&~OWM_PIDL
)) {
1692 ShellPath shell_path
= path
;
1694 _shellBrowser
->jump_to(shell_path
);
1696 _shellpath_info
._shell_path
= shell_path
;
1698 _shellpath_info
._open_mode
= mode
;
1699 _shellpath_info
._shell_path
= path
;
1701 update_shell_browser();