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 "../dialogs/settings.h" // for MdiSdiDlg
40 HWND
MainFrameBase::Create(const ExplorerCmd
& cmd
)
46 hFrame
= MDIMainFrame::Create();
49 hFrame
= SDIMainFrame::Create();
52 HWND hwndOld
= g_Globals
._hMainWnd
;
54 g_Globals
._hMainWnd
= hFrame
;
57 DestroyWindow(hwndOld
);
59 ShowWindow(hFrame
, cmd
._cmdShow
);
62 // Open the first child window after initializing the application
63 if (cmd
.IsValidPath()) {
64 // We use the static s_path variable to store the path string in order
65 // to avoid accessing prematurely freed memory in the PostMessage handlers.
66 static String s_path
= cmd
._path
;
68 PostMessage(hFrame
, PM_OPEN_WINDOW
, cmd
._flags
, (LPARAM
)(LPCTSTR
)s_path
);
70 PostMessage(hFrame
, PM_OPEN_WINDOW
, OWM_EXPLORE
|OWM_DETAILS
, 0);
77 int MainFrameBase::OpenShellFolders(LPIDA pida
, HWND hFrameWnd
)
81 LPCITEMIDLIST parent_pidl
= (LPCITEMIDLIST
) ((LPBYTE
)pida
+pida
->aoffset
[0]);
82 ShellFolder
folder(parent_pidl
);
83 LOG(FmtString(TEXT("MainFrameBase::OpenShellFolders(): parent_pidl=%s"), (LPCTSTR
)FileSysShellPath(parent_pidl
)));
85 for(int i
=pida
->cidl
; i
>0; --i
) {
86 LPCITEMIDLIST pidl
= (LPCITEMIDLIST
) ((LPBYTE
)pida
+pida
->aoffset
[i
]);
88 SFGAOF attribs
= SFGAO_FOLDER
;
89 HRESULT hr
= folder
->GetAttributesOf(1, &pidl
, &attribs
);
92 if (attribs
& SFGAO_FOLDER
) {
94 XMLPos explorer_options
= g_Globals
.get_cfg("general/explorer");
96 bool mdi
= XMLBool(explorer_options
, "mdi", true);
97 bool separateFolders
= XMLBool(explorer_options
, "separate-folders", false);
99 ShellPath pidl_abs
= ShellPath(pidl
).create_absolute_pidl(parent_pidl
);
100 LOG(FmtString(TEXT("MainFrameBase::OpenShellFolders(): pidl_abs=%s"), (LPCTSTR
)FileSysShellPath(pidl_abs
)));
102 if (hFrameWnd
&& (mdi
|| !separateFolders
)) {
103 int flags
= OWM_PIDL
;
106 flags
|= OWM_SEPARATE
;
108 if (SendMessage(hFrameWnd
, PM_OPEN_WINDOW
, flags
, (LPARAM
)(LPCITEMIDLIST
)pidl_abs
))
114 hwnd
= MDIMainFrame::Create(pidl_abs
, 0);
117 hwnd
= SDIMainFrame::Create(pidl_abs
, 0);
122 } catch(COMException
& e
) {
123 HandleException(e
, g_Globals
._hMainWnd
);
126 else { // !(attribs & SFGAO_FOLDER))
127 SHELLEXECUTEINFOA shexinfo;
129 shexinfo.cbSize = sizeof(SHELLEXECUTEINFOA);
130 shexinfo.fMask = SEE_MASK_INVOKEIDLIST;
131 shexinfo.hwnd = NULL;
132 shexinfo.lpVerb = NULL;
133 shexinfo.lpFile = NULL;
134 shexinfo.lpParameters = NULL;
135 shexinfo.lpDirectory = NULL;
136 shexinfo.nShow = SW_NORMAL;
137 shexinfo.lpIDList = ILCombine(parent_pidl, pidl);
139 if (ShellExecuteExA(&shexinfo))
142 ILFree((LPITEMIDLIST)shexinfo.lpIDList);
150 MainFrameBase::MainFrameBase(HWND hwnd
)
153 HDC hDC
= GetDC(NULL
);
155 //static TCHAR Title1[] = TEXT("Toolbar");
156 static TCHAR Title2
[] = TEXT("Address :");
162 INT bpp
= GetDeviceCaps(hDC
, BITSPIXEL
);
163 ReleaseDC(NULL
, hDC
);
170 ilMask
= ILC_COLOR16
;
172 ilMask
= ILC_COLOR24
;
174 ilMask
= ILC_COLOR32
;
180 _himl
= ImageList_Create(GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), ilMask
, 2, 0);
183 _hMenuFrame
= GetMenu(hwnd
);
184 _hMenuWindow
= GetSubMenu(_hMenuFrame
, GetMenuItemCount(_hMenuFrame
)-3);
186 _menu_info
._hMenuView
= GetSubMenu(_hMenuFrame
, 1);
188 _hAccel
= LoadAccelerators(g_Globals
._hInstance
, MAKEINTRESOURCE(IDA_EXPLORER
));
191 TBBUTTON toolbarBtns
[] = {
193 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
195 {7, ID_GO_BACK
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
196 {8, ID_GO_FORWARD
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
197 {9, ID_GO_UP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
198 {10, ID_GO_HOME
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
199 {11, ID_GO_SEARCH
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
200 {12, ID_REFRESH
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
201 {13, ID_STOP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0}
204 _htoolbar
= CreateToolbarEx(hwnd
,
206 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
208 WS_CHILD
|TBSTYLE_FLAT
|WS_VISIBLE
, IDW_TOOLBAR
, 2, g_Globals
._hInstance
, IDB_TOOLBAR
,
209 toolbarBtns
, sizeof(toolbarBtns
)/sizeof(TBBUTTON
),
210 16, 16, 16, 16, sizeof(TBBUTTON
));
212 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_TOOL_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
216 _haddrcombo
= CreateWindowEx(0,
219 WS_CHILD
|WS_TABSTOP
|WS_BORDER
|WS_VISIBLE
|CBS_DROPDOWN
|
220 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|CCS_NOMOVEY
,
223 (HMENU
)IDW_ADDRESSBAR
,
224 g_Globals
._hInstance
,
227 HFONT hFont
= (HFONT
)GetStockObject(ANSI_VAR_FONT
);
228 SendMessageW(_haddrcombo
, WM_SETFONT
, (WPARAM
)hFont
, 0);
231 _hstatusbar
= CreateStatusWindow(WS_CHILD
|WS_VISIBLE
, 0, hwnd
, IDW_STATUSBAR
);
232 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
234 _hsidebar
= CreateWindowEx(WS_EX_STATICEDGE
, WC_TREEVIEW
, TEXT("Sidebar"),
235 WS_CHILD
|WS_TABSTOP
|WS_BORDER
|/*WS_VISIBLE|*/TVS_HASLINES
|TVS_HASBUTTONS
|TVS_SHOWSELALWAYS
|TVS_INFOTIP
,
236 -1, -1, 200, 0, _hwnd
, (HMENU
)IDW_SIDEBAR
, g_Globals
._hInstance
, 0);
238 _himl_old
= TreeView_SetImageList(_hsidebar
, _himl
, TVSIL_NORMAL
);
240 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_SIDE_BAR
, MF_BYCOMMAND
|MF_UNCHECKED
/*MF_CHECKED*/);
243 // create rebar window to manage toolbar and drivebar
245 _hwndrebar
= CreateWindowEx(WS_EX_TOOLWINDOW
,
248 WS_CHILD
|WS_VISIBLE
|WS_BORDER
|WS_CLIPSIBLINGS
|WS_CLIPCHILDREN
|
249 RBS_VARHEIGHT
|RBS_DBLCLKTOGGLE
| RBS_AUTOSIZE
|RBS_BANDBORDERS
,
253 g_Globals
._hInstance
,
256 int btn_hgt
= HIWORD(SendMessage(_htoolbar
, TB_GETBUTTONSIZE
, 0, 0));
258 REBARBANDINFO rbBand
;
260 rbBand
.cbSize
= sizeof(REBARBANDINFO
);
261 rbBand
.fMask
= RBBIM_TEXT
|RBBIM_STYLE
|RBBIM_CHILD
|RBBIM_CHILDSIZE
|RBBIM_SIZE
;
262 rbBand
.fStyle
= RBBS_CHILDEDGE
|RBBS_GRIPPERALWAYS
|RBBS_HIDETITLE
;
264 rbBand
.cxMinChild
= 0;
265 rbBand
.cyMinChild
= 0;
267 rbBand
.cyMaxChild
= 0;
268 rbBand
.cyIntegral
= btn_hgt
;
270 rbBand
.lpText
= NULL
;//Title1
271 rbBand
.hwndChild
= _htoolbar
;
272 rbBand
.cxMinChild
= 0;
273 rbBand
.cyMinChild
= btn_hgt
;
275 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)0, (LPARAM
)&rbBand
);
277 rbBand
.fStyle
&= ~RBBS_HIDETITLE
;
278 rbBand
.fStyle
|= RBBS_BREAK
;
279 rbBand
.lpText
= Title2
;
280 rbBand
.hwndChild
= _haddrcombo
;
281 rbBand
.cxMinChild
= 0;
282 rbBand
.cyMinChild
= btn_hgt
;
284 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)3, (LPARAM
)&rbBand
);
289 MainFrameBase::~MainFrameBase()
291 (void)TreeView_SetImageList(_hsidebar
, _himl_old
, TVSIL_NORMAL
);
292 ImageList_Destroy(_himl
);
294 // don't exit desktop when closing file manager window
295 if (!g_Globals
._desktop_mode
)
296 if (g_Globals
._hMainWnd
== _hwnd
) // don't quit when switching between MDI and SDI mode
301 LRESULT
MainFrameBase::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
305 if (ProcessMessage(nmsg
, wparam
, lparam
, &res
))
308 return super::WndProc(nmsg
, wparam
, lparam
);
311 bool MainFrameBase::ProcessMessage(UINT nmsg
, WPARAM wparam
, LPARAM lparam
, LRESULT
* pres
)
314 case PM_TRANSLATE_MSG
:
315 *pres
= TranslateMsg((MSG
*)lparam
);
319 if (wparam
) { // trigger child resizing after window creation - now we can succesfully call IsWindowVisible()
320 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
321 MoveWindow(_hwndrebar
, 0, 0, LOWORD(lparam
), height
, TRUE
);
322 resize_frame_client();
324 return false; // goto def;
327 DestroyWindow(_hwnd
);
328 g_Globals
._hMainWnd
= 0;
335 #ifdef __REACTOS__ ///@todo Work around to display rebar in ROS (with flickering) as long as the control isn't fixed
336 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
337 MoveWindow(_hwndrebar
, 0, 0, LOWORD(lparam
), height
, TRUE
);
339 resize_frame(LOWORD(lparam
), HIWORD(lparam
));
340 SendMessage(_hwndrebar
, WM_SIZE
, 0, 0);
344 break;} // do not pass message to DefFrameProc
346 case WM_GETMINMAXINFO
: {
347 LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
349 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
350 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
353 case PM_FRM_CALC_CLIENT
:
354 frame_get_clientspace((PRECT
)lparam
);
358 case PM_FRM_GET_MENUINFO
:
359 *pres
= (LPARAM
)&_menu_info
;
362 case PM_GET_CONTROLWINDOW
:
363 if (wparam
== FCW_STATUS
) {
364 *pres
= (LRESULT
)(HWND
)_hstatusbar
;
369 case PM_SETSTATUSTEXT
:
370 SendMessage(_hstatusbar
, SB_SETTEXT
, 0, lparam
);
373 case WM_SYSCOLORCHANGE
:
374 SendMessage(_hwndrebar
, WM_SYSCOLORCHANGE
, 0, 0);
375 SendMessage(_htoolbar
, WM_SYSCOLORCHANGE
, 0, 0);
386 BOOL
MainFrameBase::TranslateMsg(MSG
* pmsg
)
388 if (TranslateAccelerator(_hwnd
, _hAccel
, pmsg
))
395 int MainFrameBase::Command(int id
, int code
)
397 CONTEXT("MainFrameBase::Command()");
401 SendMessage(_hwnd
, WM_CLOSE
, 0, 0);
404 case ID_VIEW_TOOL_BAR
:
405 toggle_child(_hwnd
, id
, _htoolbar
, 0);
408 case ID_VIEW_STATUSBAR
:
409 toggle_child(_hwnd
, id
, _hstatusbar
);
412 case ID_VIEW_SIDE_BAR
:
413 // lazy initialization
414 if (!TreeView_GetCount(_hsidebar
))
417 toggle_child(_hwnd
, id
, _hsidebar
);
421 ExecuteDialog dlg
= {{0}, 0};
423 if (DialogBoxParam(g_Globals
._hInstance
, MAKEINTRESOURCE(IDD_EXECUTE
), _hwnd
, ExecuteDialog::WndProc
, (LPARAM
)&dlg
) == IDOK
) {
424 CONTEXT("ID_EXECUTE - ShellExecute()");
426 HINSTANCE hinst
= ShellExecute(_hwnd
, NULL
/*operation*/, dlg
.cmd
/*file*/, NULL
/*parameters*/, NULL
/*dir*/, dlg
.cmdshow
);
428 if ((int)hinst
<= 32)
429 display_error(_hwnd
, GetLastError());
434 WinHelp(_hwnd
, TEXT("explorer")/*file explorer.hlp*/, HELP_INDEX
, 0);
437 case ID_VIEW_FULLSCREEN
:
438 CheckMenuItem(_menu_info
._hMenuView
, id
, toggle_fullscreen()?MF_CHECKED
:0);
441 case ID_TOOLS_OPTIONS
:
442 Dialog::DoModal(IDD_MDI_SDI
, WINDOW_CREATOR(MdiSdiDlg
), _hwnd
);
445 case ID_ABOUT_WINDOWS
:
446 ShellAbout(_hwnd
, ResString(IDS_TITLE
), NULL
, 0);
449 case ID_ABOUT_EXPLORER
:
450 explorer_about(_hwnd
);
453 case ID_EXPLORER_FAQ
:
454 launch_file(_hwnd
, TEXT("http://www.sky.franken.de/explorer/"), SW_SHOW
);
458 return 1; // no command handlers in Window::Command()
464 int MainFrameBase::Notify(int id
, NMHDR
* pnmh
)
467 // resize children windows when the rebar size changes
470 resize_frame_client();
473 case TVN_GETINFOTIP
: {
474 NMTVGETINFOTIP
* pnmgit
= (NMTVGETINFOTIP
*)pnmh
;
476 if (pnmgit
->lParam
) {
477 const BookmarkNode
& node
= *(BookmarkNode
*)pnmgit
->lParam
;
479 if (node
._type
== BookmarkNode::BMNT_FOLDER
) {
480 // display tooltips for bookmark folders
481 if (!node
._pfolder
->_description
.empty())
482 lstrcpyn(pnmgit
->pszText
, node
._pfolder
->_description
.c_str(), pnmgit
->cchTextMax
);
483 } else if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
484 // display tooltips for bookmark folders
485 String txt
= node
._pbookmark
->_description
;
487 if (!node
._pbookmark
->_url
.empty()) {
491 txt
+= node
._pbookmark
->_url
;
494 lstrcpyn(pnmgit
->pszText
, txt
.c_str(), pnmgit
->cchTextMax
);
500 HTREEITEM hitem
= TreeView_GetSelection(_hsidebar
);
501 LPARAM lparam
= TreeView_GetItemData(_hsidebar
, hitem
);
504 const BookmarkNode
& node
= *(BookmarkNode
*)lparam
;
506 if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
507 bool new_window
= GetAsyncKeyState(VK_SHIFT
)<0;
509 go_to(node
._pbookmark
->_url
, new_window
);
519 void MainFrameBase::resize_frame(int cx
, int cy
)
522 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
524 RECT rect
= {0, 0, cx
, cy
};
527 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
531 SetWindowPos(_haddrcombo
, NULL
, 0, 0, cx
, height
, SWP_NOMOVE
);
533 if (IsWindowVisible(_htoolbar
)) {
534 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
535 WindowRect
rt(_htoolbar
);
536 rect
.top
= rt
.bottom
;
537 // rect.bottom -= rt.bottom;
541 if (IsWindowVisible(_hstatusbar
)) {
542 int parts
[] = {300, 500};
544 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
545 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
546 ClientRect
rt(_hstatusbar
);
547 rect
.bottom
-= rt
.bottom
;
550 if (IsWindowVisible(_hsidebar
)) {
551 WindowRect
rt(_hsidebar
);
552 rect
.left
+= rt
.right
-rt
.left
;
554 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
558 void MainFrameBase::resize_frame_client()
560 ClientRect
rect(_hwnd
);
562 resize_frame(rect
.right
, rect
.bottom
);
565 void MainFrameBase::frame_get_clientspace(PRECT prect
)
567 if (!IsIconic(_hwnd
))
568 GetClientRect(_hwnd
, prect
);
572 GetWindowPlacement(_hwnd
, &wp
);
574 prect
->left
= prect
->top
= 0;
575 prect
->right
= wp
.rcNormalPosition
.right
-wp
.rcNormalPosition
.left
-
576 2*(GetSystemMetrics(SM_CXSIZEFRAME
)+GetSystemMetrics(SM_CXEDGE
));
577 prect
->bottom
= wp
.rcNormalPosition
.bottom
-wp
.rcNormalPosition
.top
-
578 2*(GetSystemMetrics(SM_CYSIZEFRAME
)+GetSystemMetrics(SM_CYEDGE
))-
579 GetSystemMetrics(SM_CYCAPTION
)-GetSystemMetrics(SM_CYMENUSIZE
);
582 if (IsWindowVisible(_htoolbar
)) {
583 ClientRect
rt(_htoolbar
);
584 prect
->top
+= rt
.bottom
+2;
587 if (IsWindowVisible(_hstatusbar
)) {
588 ClientRect
rt(_hstatusbar
);
589 prect
->bottom
-= rt
.bottom
;
593 BOOL
MainFrameBase::toggle_fullscreen()
597 if ((_fullscreen
._mode
=!_fullscreen
._mode
)) {
598 GetWindowRect(_hwnd
, &_fullscreen
._orgPos
);
599 _fullscreen
._wasZoomed
= IsZoomed(_hwnd
);
601 Frame_CalcFrameClient(_hwnd
, &rt
);
602 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.left
);
603 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.right
);
605 rt
.left
= _fullscreen
._orgPos
.left
-rt
.left
;
606 rt
.top
= _fullscreen
._orgPos
.top
-rt
.top
;
607 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+_fullscreen
._orgPos
.right
-rt
.right
;
608 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+_fullscreen
._orgPos
.bottom
-rt
.bottom
;
610 MoveWindow(_hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
612 MoveWindow(_hwnd
, _fullscreen
._orgPos
.left
, _fullscreen
._orgPos
.top
,
613 _fullscreen
._orgPos
.right
-_fullscreen
._orgPos
.left
,
614 _fullscreen
._orgPos
.bottom
-_fullscreen
._orgPos
.top
, TRUE
);
616 if (_fullscreen
._wasZoomed
)
617 ShowWindow(_hwnd
, WS_MAXIMIZE
);
620 return _fullscreen
._mode
;
623 void MainFrameBase::fullscreen_move()
626 GetWindowRect(_hwnd
, &pos
);
628 Frame_CalcFrameClient(_hwnd
, &rt
);
629 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.left
);
630 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.right
);
632 rt
.left
= pos
.left
-rt
.left
;
633 rt
.top
= pos
.top
-rt
.top
;
634 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+pos
.right
-rt
.right
;
635 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+pos
.bottom
-rt
.bottom
;
637 MoveWindow(_hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
641 void MainFrameBase::toggle_child(HWND hwnd
, UINT cmd
, HWND hchild
, int band_idx
)
643 BOOL vis
= IsWindowVisible(hchild
);
645 CheckMenuItem(_menu_info
._hMenuView
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
648 SendMessage(_hwndrebar
, RB_SHOWBAND
, band_idx
, !vis
);
650 ShowWindow(hchild
, vis
? SW_HIDE
: SW_SHOW
);
652 if (_fullscreen
._mode
)
655 resize_frame_client();
658 void MainFrameBase::FillBookmarks()
660 HiddenWindow
hide(_hsidebar
);
661 WindowCanvas
canvas(_hwnd
);
663 TreeView_DeleteAllItems(_hsidebar
);
665 g_Globals
._icon_cache
.get_icon(ICID_FAVORITES
).add_to_imagelist(_himl
, canvas
);
666 g_Globals
._icon_cache
.get_icon(ICID_BOOKMARK
).add_to_imagelist(_himl
, canvas
);
667 ImageList_AddAlphaIcon(_himl
, SmallIcon(IDI_DOT
), GetStockBrush(WHITE_BRUSH
), canvas
);
668 g_Globals
._icon_cache
.get_icon(ICID_FOLDER
).add_to_imagelist(_himl
, canvas
);
669 g_Globals
._icon_cache
.get_icon(ICID_FOLDER
).add_to_imagelist(_himl
, canvas
);
673 tvi
.hParent
= TVI_ROOT
;
674 tvi
.hInsertAfter
= TVI_LAST
;
675 tvi
.item
.mask
= TVIF_TEXT
|TVIF_IMAGE
|TVIF_SELECTEDIMAGE
;
676 ResString
sFavorites(IDS_FAVORITES
);
677 tvi
.item
.pszText
= sFavorites
.str();
678 tvi
.item
.iSelectedImage
= tvi
.item
.iImage
= 0;
680 HTREEITEM hitem_bookmarks
= TreeView_InsertItem(_hsidebar
, &tvi
);
682 g_Globals
._favorites
.fill_tree(_hsidebar
, hitem_bookmarks
, _himl
, canvas
);
684 TreeView_Expand(_hsidebar
, hitem_bookmarks
, TVE_EXPAND
);
688 bool MainFrameBase::go_to(LPCTSTR url
, bool new_window
)
690 ///@todo SDI implementation
698 MDIMainFrame::MDIMainFrame(HWND hwnd
)
701 TBBUTTON mdiBtns
[] = {
702 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
703 {0, ID_WINDOW_NEW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
704 {1, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
705 {2, ID_WINDOW_TILE_HORZ
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
706 {3, ID_WINDOW_TILE_VERT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0}
709 SendMessage(_htoolbar
, TB_ADDBUTTONS
, sizeof(mdiBtns
)/sizeof(TBBUTTON
), (LPARAM
)&mdiBtns
);
711 CLIENTCREATESTRUCT ccs
;
713 ccs
.hWindowMenu
= _hMenuWindow
;
714 ccs
.idFirstChild
= IDW_FIRST_CHILD
;
716 _hmdiclient
= CreateWindowEx(WS_EX_CLIENTEDGE
|WS_EX_NOPARENTNOTIFY
, TEXT("MDICLIENT"), NULL
,
717 WS_CHILD
|WS_CLIPCHILDREN
|WS_VSCROLL
|WS_HSCROLL
|WS_VISIBLE
|WS_BORDER
,
719 hwnd
, 0, g_Globals
._hInstance
, &ccs
);
721 TBBUTTON extraBtns
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
724 _hextrabar
= CreateToolbarEx(hwnd
,
725 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
726 WS_CHILD
|TBSTYLE_FLAT
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,
727 IDW_EXTRABAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, NULL
, 0,
728 16, 16, 16, 16, sizeof(TBBUTTON
));
730 _hextrabar
= CreateToolbarEx(hwnd
,
731 WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,CCS_NODIVIDER
|
732 IDW_EXTRABAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, &extraBtns
, 1,
733 16, 13, 16, 13, sizeof(TBBUTTON
));
736 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_EXTRA_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
739 extraBtns
.fsStyle
= BTNS_BUTTON
;
742 // insert unix file system button
743 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("/\0"));
744 extraBtns
.idCommand
= ID_DRIVE_UNIX_FS
;
745 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
748 // insert explorer window button
749 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Explore\0"));
750 extraBtns
.idCommand
= ID_DRIVE_DESKTOP
;
751 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
753 // insert shell namespace button
754 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Shell\0"));
755 extraBtns
.idCommand
= ID_DRIVE_SHELL_NS
;
756 extraBtns
.iBitmap
= 6;
757 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
759 // insert web control button
760 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Web\0"));
761 extraBtns
.idCommand
= ID_WEB_WINDOW
;
762 extraBtns
.iBitmap
= 7;
763 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
765 if ((HIWORD(GetVersion())>>14) == W_VER_NT
) {
766 // insert NT object namespace button
767 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("NT Obj\0"));
768 extraBtns
.idCommand
= ID_DRIVE_NTOBJ_NS
;
769 extraBtns
.iBitmap
= 8;
770 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
772 #ifndef __REACTOS__ // don't insert reg button for ROS. Regedit should be used.
773 // insert Registry button
774 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Reg.\0"));
775 extraBtns
.idCommand
= ID_DRIVE_REGISTRY
;
776 extraBtns
.iBitmap
= 9;
777 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
781 // insert FAT direct file system access button
782 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("FAT\0"));
783 extraBtns
.idCommand
= ID_DRIVE_FAT
;
784 extraBtns
.iBitmap
= 10;
785 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
789 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
794 _hdrivebar
= CreateToolbarEx(hwnd
,
795 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
796 WS_CHILD
|WS_VISIBLE
|TBSTYLE_FLAT
|CCS_NOMOVEY
|TBSTYLE_LIST
,
797 IDW_DRIVEBAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, NULL
, 0,
798 16, 16, 16, 16, sizeof(TBBUTTON
));
800 _hdrivebar
= CreateToolbarEx(hwnd
,
801 WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
|CCS_NODIVIDER
,
802 IDW_DRIVEBAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, &drivebarBtn
, 1,
803 16, 13, 16, 13, sizeof(TBBUTTON
));
807 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_DRIVE_BAR
, MF_BYCOMMAND
|MF_UNCHECKED
);
811 GetLogicalDriveStrings(BUFFER_LEN
, _drives
);
813 // register windows drive root strings
814 SendMessage(_hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)_drives
);
816 drivebarBtn
.fsStyle
= BTNS_BUTTON
;
817 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
819 for(p
=_drives
; *p
; ) {
820 switch(GetDriveType(p
)) {
821 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
822 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
823 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
824 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
825 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
828 SendMessage(_hdrivebar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&drivebarBtn
);
829 ++drivebarBtn
.idCommand
;
830 ++drivebarBtn
.iString
;
838 int btn_hgt
= HIWORD(SendMessage(_htoolbar
, TB_GETBUTTONSIZE
, 0, 0));
840 REBARBANDINFO rbBand
;
842 rbBand
.cbSize
= sizeof(REBARBANDINFO
);
843 rbBand
.fMask
= RBBIM_TEXT
|RBBIM_STYLE
|RBBIM_CHILD
|RBBIM_CHILDSIZE
|RBBIM_SIZE
;
844 #ifndef RBBS_HIDETITLE // missing in MinGW headers as of 25.02.2004
845 #define RBBS_HIDETITLE 0x400
847 rbBand
.fStyle
= RBBS_CHILDEDGE
|RBBS_GRIPPERALWAYS
|RBBS_HIDETITLE
;
849 TCHAR ExtrasBand
[] = _T("Extras");
850 rbBand
.lpText
= ExtrasBand
;
851 rbBand
.hwndChild
= _hextrabar
;
852 rbBand
.cxMinChild
= 0;
853 rbBand
.cyMinChild
= btn_hgt
;
855 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)1, (LPARAM
)&rbBand
);
858 rbBand
.fStyle
|= RBBS_BREAK
;
859 TCHAR DrivesBand
[] = _T("Drives");
860 rbBand
.lpText
= DrivesBand
;
861 rbBand
.hwndChild
= _hdrivebar
;
862 rbBand
.cxMinChild
= 0;
863 rbBand
.cyMinChild
= btn_hgt
;
865 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)2, (LPARAM
)&rbBand
);
867 // hide the drivebar by default
868 SendMessage(_hwndrebar
, RB_SHOWBAND
, 2, FALSE
);
874 HWND
MDIMainFrame::Create()
876 HMENU hMenuFrame
= LoadMenu(g_Globals
._hInstance
, MAKEINTRESOURCE(IDM_MDIFRAME
));
878 return Window::Create(WINDOW_CREATOR(MDIMainFrame
), 0,
879 (LPCTSTR
)(int)g_Globals
._hframeClass
, ResString(IDS_TITLE
), WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
,
880 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
881 0/*hwndDesktop*/, hMenuFrame
);
884 HWND
MDIMainFrame::Create(LPCTSTR path
, int mode
)
886 HWND hFrame
= Create();
890 ShowWindow(hFrame
, SW_SHOW
);
892 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
895 pMainFrame
->CreateChild(path
, mode
);
900 HWND
MDIMainFrame::Create(LPCITEMIDLIST pidl
, int mode
)
902 HWND hFrame
= Create();
906 ShowWindow(hFrame
, SW_SHOW
);
908 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
911 pMainFrame
->CreateChild(pidl
, mode
);
917 ChildWindow
* MDIMainFrame::CreateChild(LPCTSTR path
, int mode
)
919 return reinterpret_cast<ChildWindow
*>(SendMessage(_hwnd
, PM_OPEN_WINDOW
, mode
, (LPARAM
)path
));
922 ChildWindow
* MDIMainFrame::CreateChild(LPCITEMIDLIST pidl
, int mode
)
924 return reinterpret_cast<ChildWindow
*>(SendMessage(_hwnd
, PM_OPEN_WINDOW
, mode
|OWM_PIDL
, (LPARAM
)pidl
));
928 BOOL
MDIMainFrame::TranslateMsg(MSG
* pmsg
)
930 if (_hmdiclient
&& TranslateMDISysAccel(_hmdiclient
, pmsg
))
933 return super::TranslateMsg(pmsg
);
936 LRESULT
MDIMainFrame::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
939 case PM_OPEN_WINDOW
: {
940 CONTEXT("MDIMainFrame PM_OPEN_WINDOW");
942 TCHAR buffer
[MAX_PATH
];
944 ShellPath shell_path
= DesktopFolderPath();
947 if (wparam
& OWM_PIDL
) {
948 // take over PIDL from lparam
949 shell_path
.assign((LPCITEMIDLIST
)lparam
); // create as "rooted" window
950 FileSysShellPath
fsp(shell_path
);
954 LOG(FmtString(TEXT("MDIMainFrame PM_OPEN_WINDOW: path=%s"), path
));
955 lstrcpy(buffer
, path
);
959 // take over path from lparam
960 path
= (LPCTSTR
)lparam
;
961 shell_path
= path
; // create as "rooted" window
964 ///@todo read paths and window placements from registry
965 if (!GetCurrentDirectory(MAX_PATH
, buffer
))
971 if (path
&& _tcsstr(path
, TEXT("://"))) { // "http://...", "ftp://", ...
972 OBJ_CONTEXT("create WebChild window", path
);
974 return (LRESULT
)GET_WINDOW(ChildWindow
, create_webchildwindow(WebChildWndInfo(_hmdiclient
, path
)));
976 OBJ_CONTEXT("create ShellChildWndInfo", path
);
978 // Shell Namespace as default view
979 ShellChildWndInfo
create_info(_hmdiclient
, path
, shell_path
);
981 if (wparam
& OWM_ROOTED
)
982 create_info
._root_shell_path
= shell_path
;
984 create_info
._root_shell_path
= DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
986 create_info
._pos
.showCmd
= wparam
&OWM_SEPARATE
? SW_SHOWNORMAL
: SW_SHOWMAXIMIZED
;
987 create_info
._pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
988 create_info
._pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
989 create_info
._pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
990 create_info
._pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
992 create_info
._open_mode
= wparam
;
994 // FileChildWindow::create(_hmdiclient, create_info);
995 return (LRESULT
)MDIShellBrowserChild::create(create_info
);
997 return TRUE
;} // success
999 case WM_SYSCOLORCHANGE
: {
1003 /* Forward WM_SYSCOLORCHANGE to common controls */
1004 SendMessage(_hextrabar
, WM_SYSCOLORCHANGE
, 0, 0);
1005 SendMessage(_hdrivebar
, WM_SYSCOLORCHANGE
, 0, 0);
1007 for(hChild
= GetNextWindow(_hmdiclient
,GW_CHILD
); hChild
; hChild
= GetNextWindow(hChild
, GW_HWNDNEXT
))
1008 SendMessage(hChild
, WM_SYSCOLORCHANGE
, 0, 0);
1010 super::ProcessMessage(nmsg
, wparam
, lparam
, &res
);
1016 if (super::ProcessMessage(nmsg
, wparam
, lparam
, &res
))
1019 return DefFrameProc(_hwnd
, _hmdiclient
, nmsg
, wparam
, lparam
);
1026 int MDIMainFrame::Command(int id
, int code
)
1028 CONTEXT("MDIMainFrame::Command()");
1030 HWND hwndClient
= (HWND
) SendMessage(_hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1033 if (SendMessage(hwndClient
, PM_DISPATCH_COMMAND
, MAKELONG(id
,code
), 0))
1037 if (id
>=ID_DRIVE_FIRST
&& id
<=ID_DRIVE_FIRST
+0xFF) {
1038 TCHAR drv
[_MAX_DRIVE
], path
[MAX_PATH
];
1039 LPCTSTR root
= _drives
;
1041 for(int i
=id
-ID_DRIVE_FIRST
; i
--; root
++)
1045 if (activate_drive_window(root
))
1048 _tsplitpath_s(root
, drv
, COUNTOF(drv
), NULL
, 0, NULL
, 0, NULL
, 0);
1050 if (!SetCurrentDirectory(drv
)) {
1051 display_error(_hwnd
, GetLastError());
1055 GetCurrentDirectory(MAX_PATH
, path
); ///@todo store last directory per drive
1057 FileChildWindow::create(FileChildWndInfo(_hmdiclient
, path
));
1064 case ID_WINDOW_NEW
: {
1065 TCHAR path
[MAX_PATH
];
1067 GetCurrentDirectory(MAX_PATH
, path
);
1069 FileChildWindow::create(FileChildWndInfo(_hmdiclient
, path
));
1072 case ID_WINDOW_CASCADE
:
1073 SendMessage(_hmdiclient
, WM_MDICASCADE
, 0, 0);
1076 case ID_WINDOW_TILE_HORZ
:
1077 SendMessage(_hmdiclient
, WM_MDITILE
, MDITILE_HORIZONTAL
, 0);
1080 case ID_WINDOW_TILE_VERT
:
1081 SendMessage(_hmdiclient
, WM_MDITILE
, MDITILE_VERTICAL
, 0);
1084 case ID_WINDOW_ARRANGE
:
1085 SendMessage(_hmdiclient
, WM_MDIICONARRANGE
, 0, 0);
1088 case ID_VIEW_EXTRA_BAR
:
1089 toggle_child(_hwnd
, id
, _hextrabar
, 1);
1093 case ID_VIEW_DRIVE_BAR
:
1094 toggle_child(_hwnd
, id
, _hdrivebar
, 2);
1099 case ID_DRIVE_UNIX_FS
: {
1100 TCHAR path
[MAX_PATH
];
1101 FileChildWindow
* child
;
1103 getcwd(path
, COUNTOF(path
));
1105 if (activate_child_window(TEXT("unixfs")))
1108 FileChildWindow::create(_hmdiclient
, FileChildWndInfo(path
));
1112 case ID_DRIVE_DESKTOP
: {
1113 TCHAR path
[MAX_PATH
];
1115 if (activate_child_window(TEXT("Desktop")))
1118 GetCurrentDirectory(MAX_PATH
, path
);
1120 MDIShellBrowserChild::create(ShellChildWndInfo(_hmdiclient
, path
, DesktopFolderPath()));
1123 case ID_DRIVE_SHELL_NS
: {
1124 TCHAR path
[MAX_PATH
];
1125 GetCurrentDirectory(MAX_PATH
, path
);
1127 if (activate_child_window(TEXT("Shell")))
1130 FileChildWindow::create(ShellChildWndInfo(_hmdiclient
, path
, DesktopFolderPath()));
1133 case ID_DRIVE_NTOBJ_NS
: {
1134 if (activate_child_window(TEXT("NTOBJ")))
1137 FileChildWindow::create(NtObjChildWndInfo(_hmdiclient
, TEXT("\\")));
1140 case ID_DRIVE_REGISTRY
: {
1141 if (activate_child_window(TEXT("Registry")))
1144 FileChildWindow::create(RegistryChildWndInfo(_hmdiclient
, TEXT("\\")));
1147 case ID_DRIVE_FAT
: {
1149 ///@todo prompt for image file
1151 if (activate_child_window(TEXT("FAT")))
1154 FileChildWindow::create(FATChildWndInfo(_hmdiclient
, TEXT("FAT Image"))); //@@
1159 create_webchildwindow(WebChildWndInfo(_hmdiclient
, TEXT("http://localhost")));
1161 create_webchildwindow(WebChildWndInfo(_hmdiclient
, TEXT("http://www.reactos.org")));
1165 case ID_EXPLORER_FAQ
:
1166 create_webchildwindow(WebChildWndInfo(_hmdiclient
, TEXT("http://www.sky.franken.de/explorer/")));
1170 MainFrameBase::Create(ExplorerCmd());
1173 ///@todo There are even more menu items!
1176 if (super::Command(id
, code
) == 0)
1179 return DefFrameProc(_hwnd
, _hmdiclient
, WM_COMMAND
, MAKELONG(id
,code
), 0);
1186 void MDIMainFrame::frame_get_clientspace(PRECT prect
)
1188 super::frame_get_clientspace(prect
);
1191 if (IsWindowVisible(_hdrivebar
)) {
1192 ClientRect
rt(_hdrivebar
);
1193 prect
->top
+= rt
.bottom
+2;
1198 void MDIMainFrame::resize_frame(int cx
, int cy
)
1201 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
1203 RECT rect
= {0, 0, cx
, cy
};
1206 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
1210 if (IsWindowVisible(_htoolbar
)) {
1211 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
1212 WindowRect
rt(_htoolbar
);
1213 rect
.top
= rt
.bottom
;
1214 // rect.bottom -= rt.bottom;
1217 if (IsWindowVisible(_hextrabar
)) {
1218 SendMessage(_hextrabar
, WM_SIZE
, 0, 0);
1219 WindowRect
rt(_hextrabar
);
1220 int new_top
= --rect
.top
+ rt
.bottom
;
1221 MoveWindow(_hextrabar
, 0, rect
.top
, rt
.right
, new_top
, TRUE
);
1223 // rect.bottom -= rt.bottom;
1227 if (IsWindowVisible(_hdrivebar
)) {
1228 SendMessage(_hdrivebar
, WM_SIZE
, 0, 0);
1229 WindowRect
rt(_hdrivebar
);
1230 int new_top
= --rect
.top
+ rt
.bottom
;
1231 MoveWindow(_hdrivebar
, 0, rect
.top
, rt
.right
, new_top
, TRUE
);
1233 // rect.bottom -= rt.bottom;
1238 if (IsWindowVisible(_hstatusbar
)) {
1239 int parts
[] = {300, 500};
1241 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
1242 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1243 ClientRect
rt(_hstatusbar
);
1244 rect
.bottom
-= rt
.bottom
;
1247 if (IsWindowVisible(_hsidebar
)) {
1248 WindowRect
rt(_hsidebar
);
1249 rect
.left
+= rt
.right
-rt
.left
;
1251 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
1254 MoveWindow(_hmdiclient
, rect
.left
-1, rect
.top
-1, rect
.right
-rect
.left
+1, rect
.bottom
-rect
.top
+1, TRUE
);
1257 bool MDIMainFrame::activate_drive_window(LPCTSTR path
)
1259 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
1262 _tsplitpath_s(path
, drv1
, COUNTOF(drv1
), NULL
, 0, NULL
, 0, NULL
, 0);
1264 // search for a already open window for the same drive
1265 for(child_wnd
=GetNextWindow(_hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1266 FileChildWindow
* child
= (FileChildWindow
*) SendMessage(child_wnd
, PM_GET_FILEWND_PTR
, 0, 0);
1269 _tsplitpath_s(child
->get_root()._path
, drv2
, COUNTOF(drv2
), NULL
, 0, NULL
, 0, NULL
, 0);
1271 if (!lstrcmpi(drv2
, drv1
)) {
1272 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1274 if (IsMinimized(child_wnd
))
1275 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1285 bool MDIMainFrame::activate_child_window(LPCTSTR filesys
)
1289 // search for a already open window of the given file system name
1290 for(child_wnd
=GetNextWindow(_hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1291 FileChildWindow
* child
= (FileChildWindow
*) SendMessage(child_wnd
, PM_GET_FILEWND_PTR
, 0, 0);
1294 if (!lstrcmpi(child
->get_root()._fs
, filesys
)) {
1295 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1297 if (IsMinimized(child_wnd
))
1298 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1303 ShellBrowser
* shell_child
= (ShellBrowser
*) SendMessage(child_wnd
, PM_GET_SHELLBROWSER_PTR
, 0, 0);
1306 if (!lstrcmpi(shell_child
->get_root()._fs
, filesys
)) {
1307 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1309 if (IsMinimized(child_wnd
))
1310 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1321 bool MDIMainFrame::go_to(LPCTSTR url
, bool new_window
)
1324 HWND hwndClient
= (HWND
) SendMessage(_hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1327 if (SendMessage(hwndClient
, PM_JUMP_TO_URL
, 0, (LPARAM
)url
))
1331 if (CreateChild(url
))
1334 return super::go_to(url
, new_window
);
1340 SDIMainFrame::SDIMainFrame(HWND hwnd
)
1343 _split_pos
= DEFAULT_SPLIT_POS
;
1344 _last_split
= DEFAULT_SPLIT_POS
;
1346 /* wait for PM_OPEN_WINDOW message before creating a shell view
1347 update_shell_browser();*/
1350 HWND
SDIMainFrame::Create()
1352 HMENU hMenuFrame
= LoadMenu(g_Globals
._hInstance
, MAKEINTRESOURCE(IDM_SDIFRAME
));
1354 return Window::Create(WINDOW_CREATOR(SDIMainFrame
), 0,
1355 (LPCTSTR
)(int)g_Globals
._hframeClass
, ResString(IDS_TITLE
), WS_OVERLAPPEDWINDOW
,
1356 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
1357 0/*hwndDesktop*/, hMenuFrame
);
1360 HWND
SDIMainFrame::Create(LPCITEMIDLIST pidl
, int mode
)
1362 HWND hFrame
= Create();
1366 ShowWindow(hFrame
, SW_SHOW
);
1368 SDIMainFrame
* pFrame
= GET_WINDOW(SDIMainFrame
, hFrame
);
1371 pFrame
->jump_to(pidl
, mode
);
1376 HWND
SDIMainFrame::Create(LPCTSTR path
, int mode
)
1378 HWND hFrame
= Create();
1382 ShowWindow(hFrame
, SW_SHOW
);
1384 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
1387 pMainFrame
->CreateChild(path
, mode
);
1392 LRESULT
SDIMainFrame::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1396 resize_frame(LOWORD(lparam
), HIWORD(lparam
));
1400 PaintCanvas
canvas(_hwnd
);
1403 ClientRect
rt(_hwnd
);
1404 rt
.left
= _split_pos
-SPLIT_WIDTH
/2;
1405 rt
.right
= _split_pos
+SPLIT_WIDTH
/2+1;
1408 WindowRect
right_rect(_right_hwnd
);
1409 ScreenToClient(_hwnd
, &right_rect
);
1410 rt
.top
= right_rect
.top
;
1411 rt
.bottom
= right_rect
.bottom
;
1414 HBRUSH lastBrush
= SelectBrush(canvas
, GetStockBrush(COLOR_SPLITBAR
));
1415 Rectangle(canvas
, rt
.left
, rt
.top
-1, rt
.right
, rt
.bottom
+1);
1416 SelectObject(canvas
, lastBrush
);
1422 if (LOWORD(lparam
) == HTCLIENT
) {
1425 ScreenToClient(_hwnd
, &pt
);
1427 if (pt
.x
>=_split_pos
-SPLIT_WIDTH
/2 && pt
.x
<_split_pos
+SPLIT_WIDTH
/2+1) {
1428 SetCursor(LoadCursor(0, IDC_SIZEWE
));
1434 case WM_LBUTTONDOWN
:
1436 int x
= GET_X_LPARAM(lparam
);
1438 ClientRect
rt(_hwnd
);
1440 if (x
>=_split_pos
-SPLIT_WIDTH
/2 && x
<_split_pos
+SPLIT_WIDTH
/2+1) {
1441 _last_split
= _split_pos
;
1448 if (GetCapture() == _hwnd
)
1453 if (wparam
== VK_ESCAPE
)
1454 if (GetCapture() == _hwnd
) {
1455 _split_pos
= _last_split
;
1459 SetCursor(LoadCursor(0, IDC_ARROW
));
1464 if (GetCapture() == _hwnd
) {
1465 int x
= GET_X_LPARAM(lparam
);
1467 ClientRect
rt(_hwnd
);
1469 if (x
>=0 && x
<rt
.right
) {
1472 rt
.left
= x
-SPLIT_WIDTH
/2;
1473 rt
.right
= x
+SPLIT_WIDTH
/2+1;
1474 InvalidateRect(_hwnd
, &rt
, FALSE
);
1475 UpdateWindow(_left_hwnd
);
1476 UpdateWindow(_hwnd
);
1477 UpdateWindow(_right_hwnd
);
1482 case PM_OPEN_WINDOW
: {
1483 CONTEXT("SDIMainFrame PM_OPEN_WINDOW");
1485 TCHAR buffer
[MAX_PATH
];
1487 ShellPath shell_path
= DesktopFolderPath();
1490 if (wparam
& OWM_PIDL
) {
1491 // take over PIDL from lparam
1492 shell_path
.assign((LPCITEMIDLIST
)lparam
); // create as "rooted" window
1493 FileSysShellPath
fsp(shell_path
);
1497 LOG(FmtString(TEXT("SDIMainFrame PM_OPEN_WINDOW: path=%s"), path
));
1498 lstrcpy(buffer
, path
);
1502 // take over path from lparam
1503 path
= (LPCTSTR
)lparam
;
1504 shell_path
= path
; // create as "rooted" window
1507 ///@todo read paths and window placements from registry
1508 if (!GetCurrentDirectory(MAX_PATH
, buffer
))
1515 if (wparam
& OWM_ROOTED
)
1516 _shellpath_info
._root_shell_path
= shell_path
;
1518 _shellpath_info
._root_shell_path
= DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
1520 jump_to(shell_path
, wparam
); ///@todo content of 'path' not used any more
1521 return TRUE
;} // success
1524 return super::WndProc(nmsg
, wparam
, lparam
);
1530 int SDIMainFrame::Command(int id
, int code
)
1534 MainFrameBase::Create(ExplorerCmd(_url
, true));
1538 return super::Command(id
, code
);
1544 void SDIMainFrame::resize_frame(int cx
, int cy
)
1547 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
1549 RECT rect
= {0, 0, cx
, cy
};
1552 int height
= ClientRect(_hwndrebar
).bottom
;
1556 if (IsWindowVisible(_htoolbar
)) {
1557 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
1558 WindowRect
rt(_htoolbar
);
1559 rect
.top
= rt
.bottom
;
1560 // rect.bottom -= rt.bottom;
1564 if (IsWindowVisible(_hstatusbar
)) {
1565 int parts
[] = {300, 500};
1567 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
1568 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1569 ClientRect
rt(_hstatusbar
);
1570 rect
.bottom
-= rt
.bottom
;
1573 if (IsWindowVisible(_hsidebar
)) {
1574 WindowRect
rt(_hsidebar
);
1575 rect
.left
+= rt
.right
-rt
.left
;
1577 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
1585 void SDIMainFrame::resize_children()
1587 HDWP hdwp
= BeginDeferWindowPos(2);
1589 int cx
= _clnt_rect
.left
;
1592 cx
= _split_pos
+ SPLIT_WIDTH
/2;
1594 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
);
1601 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
);
1603 EndDeferWindowPos(hdwp
);
1606 void SDIMainFrame::update_clnt_rect()
1608 ClientRect
rect(_hwnd
);
1610 resize_frame(rect
.right
, rect
.bottom
);
1613 void SDIMainFrame::update_shell_browser()
1615 int split_pos
= DEFAULT_SPLIT_POS
;
1617 if (_shellBrowser
.get()) {
1618 split_pos
= _split_pos
;
1619 delete _shellBrowser
.release();
1622 // create explorer treeview
1623 if (_shellpath_info
._open_mode
& OWM_EXPLORE
) {
1625 ClientRect
rect(_hwnd
);
1627 _left_hwnd
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, NULL
,
1628 WS_CHILD
|WS_TABSTOP
|WS_VISIBLE
|TVS_HASLINES
|TVS_LINESATROOT
|TVS_HASBUTTONS
|TVS_NOTOOLTIPS
|TVS_SHOWSELALWAYS
,
1629 0, rect
.top
, split_pos
-SPLIT_WIDTH
/2, rect
.bottom
-rect
.top
,
1630 _hwnd
, (HMENU
)IDC_FILETREE
, g_Globals
._hInstance
, 0);
1632 // display tree window as long as the shell view is not yet visible
1633 resize_frame(rect
.right
, rect
.bottom
);
1634 MoveWindow(_left_hwnd
, rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
1638 DestroyWindow(_left_hwnd
);
1643 _shellBrowser
= auto_ptr
<ShellBrowser
>(new ShellBrowser(_hwnd
, _hwnd
, _left_hwnd
, _right_hwnd
,
1644 _shellpath_info
, this, _cm_ifs
));
1647 _shellBrowser
->Init();
1649 // update _clnt_rect and set size of new created shell view windows
1653 void SDIMainFrame::entry_selected(Entry
* entry
)
1656 _shellBrowser
->select_folder(entry
, false);
1658 _shellBrowser
->UpdateFolderView(entry
->get_shell_folder());
1660 // set size of new created shell view windows
1664 void SDIMainFrame::set_url(LPCTSTR url
)
1668 SetWindowText(_haddrcombo
, url
);
1673 void SDIMainFrame::jump_to(LPCTSTR path
, int mode
)
1675 if (_shellBrowser.get() && (_shellpath_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) {
1676 _shellBrowser->jump_to(path);
1678 _shellpath_info._shell_path = path;
1680 _shellpath_info
._open_mode
= mode
;
1681 _shellpath_info
._shell_path
= path
;
1683 update_shell_browser();
1687 void SDIMainFrame::jump_to(LPCITEMIDLIST path
, int mode
)
1689 if (_shellBrowser
.get() && (_shellpath_info
._open_mode
&~OWM_PIDL
)==(mode
&~OWM_PIDL
)) {
1690 ShellPath shell_path
= path
;
1692 _shellBrowser
->jump_to(shell_path
);
1694 _shellpath_info
._shell_path
= shell_path
;
1696 _shellpath_info
._open_mode
= mode
;
1697 _shellpath_info
._shell_path
= path
;
1699 update_shell_browser();