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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
);
159 INT bpp
= GetDeviceCaps(hDC
, BITSPIXEL
);
160 ReleaseDC(NULL
, hDC
);
167 ilMask
= ILC_COLOR16
;
169 ilMask
= ILC_COLOR24
;
171 ilMask
= ILC_COLOR32
;
177 _himl
= ImageList_Create(GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), ilMask
, 2, 0);
180 _hMenuFrame
= GetMenu(hwnd
);
181 _hMenuWindow
= GetSubMenu(_hMenuFrame
, GetMenuItemCount(_hMenuFrame
)-3);
183 _menu_info
._hMenuView
= GetSubMenu(_hMenuFrame
, 1);
185 _hAccel
= LoadAccelerators(g_Globals
._hInstance
, MAKEINTRESOURCE(IDA_EXPLORER
));
188 TBBUTTON toolbarBtns
[] = {
190 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
192 {7, ID_GO_BACK
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
193 {8, ID_GO_FORWARD
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
194 {9, ID_GO_UP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
195 {10, ID_GO_HOME
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
196 {11, ID_GO_SEARCH
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
197 {12, ID_REFRESH
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
198 {13, ID_STOP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0}
201 _htoolbar
= CreateToolbarEx(hwnd
,
203 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
205 WS_CHILD
|TBSTYLE_FLAT
|WS_VISIBLE
, IDW_TOOLBAR
, 2, g_Globals
._hInstance
, IDB_TOOLBAR
,
206 toolbarBtns
, sizeof(toolbarBtns
)/sizeof(TBBUTTON
),
207 16, 16, 16, 16, sizeof(TBBUTTON
));
209 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_TOOL_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
213 _haddrcombo
= CreateWindowEx(0,
216 WS_CHILD
|WS_TABSTOP
|WS_BORDER
|WS_VISIBLE
|CBS_DROPDOWN
|
217 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|CCS_NOMOVEY
,
220 (HMENU
)IDW_ADDRESSBAR
,
221 g_Globals
._hInstance
,
224 HFONT hFont
= (HFONT
)GetStockObject(ANSI_VAR_FONT
);
225 SendMessageW(_haddrcombo
, WM_SETFONT
, (WPARAM
)hFont
, 0);
228 _hstatusbar
= CreateStatusWindow(WS_CHILD
|WS_VISIBLE
, 0, hwnd
, IDW_STATUSBAR
);
229 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
231 _hsidebar
= CreateWindowEx(WS_EX_STATICEDGE
, WC_TREEVIEW
, TEXT("Sidebar"),
232 WS_CHILD
|WS_TABSTOP
|WS_BORDER
|/*WS_VISIBLE|*/WS_CHILD
|TVS_HASLINES
|TVS_HASBUTTONS
|TVS_SHOWSELALWAYS
|TVS_INFOTIP
,
233 -1, -1, 200, 0, _hwnd
, (HMENU
)IDW_SIDEBAR
, g_Globals
._hInstance
, 0);
235 _himl_old
= TreeView_SetImageList(_hsidebar
, _himl
, TVSIL_NORMAL
);
237 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_SIDE_BAR
, MF_BYCOMMAND
|MF_UNCHECKED
/*MF_CHECKED*/);
240 // create rebar window to manage toolbar and drivebar
242 _hwndrebar
= CreateWindowEx(WS_EX_TOOLWINDOW
,
245 WS_CHILD
|WS_VISIBLE
|WS_BORDER
|WS_CLIPSIBLINGS
|WS_CLIPCHILDREN
|
246 RBS_VARHEIGHT
|RBS_DBLCLKTOGGLE
| RBS_AUTOSIZE
|RBS_BANDBORDERS
,
250 g_Globals
._hInstance
,
253 int btn_hgt
= HIWORD(SendMessage(_htoolbar
, TB_GETBUTTONSIZE
, 0, 0));
255 REBARBANDINFO rbBand
;
257 rbBand
.cbSize
= sizeof(REBARBANDINFO
);
258 rbBand
.fMask
= RBBIM_TEXT
|RBBIM_STYLE
|RBBIM_CHILD
|RBBIM_CHILDSIZE
|RBBIM_SIZE
;
259 rbBand
.fStyle
= RBBS_CHILDEDGE
|RBBS_GRIPPERALWAYS
|RBBS_HIDETITLE
;
261 rbBand
.cxMinChild
= 0;
262 rbBand
.cyMinChild
= 0;
264 rbBand
.cyMaxChild
= 0;
265 rbBand
.cyIntegral
= btn_hgt
;
267 rbBand
.lpText
= NULL
;//TEXT("Toolbar");
268 rbBand
.hwndChild
= _htoolbar
;
269 rbBand
.cxMinChild
= 0;
270 rbBand
.cyMinChild
= btn_hgt
;
272 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)0, (LPARAM
)&rbBand
);
274 rbBand
.fStyle
&= ~RBBS_HIDETITLE
;
275 rbBand
.fStyle
|= RBBS_BREAK
;
276 rbBand
.lpText
= TEXT("Address :");
277 rbBand
.hwndChild
= _haddrcombo
;
278 rbBand
.cxMinChild
= 0;
279 rbBand
.cyMinChild
= btn_hgt
;
281 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)3, (LPARAM
)&rbBand
);
286 MainFrameBase::~MainFrameBase()
288 (void)TreeView_SetImageList(_hsidebar
, _himl_old
, TVSIL_NORMAL
);
289 ImageList_Destroy(_himl
);
291 // don't exit desktop when closing file manager window
292 if (!g_Globals
._desktop_mode
)
293 if (g_Globals
._hMainWnd
== _hwnd
) // don't quit when switching between MDI and SDI mode
298 LRESULT
MainFrameBase::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
302 if (ProcessMessage(nmsg
, wparam
, lparam
, &res
))
305 return super::WndProc(nmsg
, wparam
, lparam
);
308 bool MainFrameBase::ProcessMessage(UINT nmsg
, WPARAM wparam
, LPARAM lparam
, LRESULT
* pres
)
311 case PM_TRANSLATE_MSG
:
312 *pres
= TranslateMsg((MSG
*)lparam
);
316 if (wparam
) { // trigger child resizing after window creation - now we can succesfully call IsWindowVisible()
317 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
318 MoveWindow(_hwndrebar
, 0, 0, LOWORD(lparam
), height
, TRUE
);
319 resize_frame_client();
321 return false; // goto def;
324 DestroyWindow(_hwnd
);
325 g_Globals
._hMainWnd
= 0;
332 #ifdef __REACTOS__ ///@todo Work around to display rebar in ROS (with flickering) as long as the control isn't fixed
333 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
334 MoveWindow(_hwndrebar
, 0, 0, LOWORD(lparam
), height
, TRUE
);
336 resize_frame(LOWORD(lparam
), HIWORD(lparam
));
337 SendMessage(_hwndrebar
, WM_SIZE
, 0, 0);
341 break;} // do not pass message to DefFrameProc
343 case WM_GETMINMAXINFO
: {
344 LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
346 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
347 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
350 case PM_FRM_CALC_CLIENT
:
351 frame_get_clientspace((PRECT
)lparam
);
355 case PM_FRM_GET_MENUINFO
:
356 *pres
= (LPARAM
)&_menu_info
;
359 case PM_GET_CONTROLWINDOW
:
360 if (wparam
== FCW_STATUS
) {
361 *pres
= (LRESULT
)(HWND
)_hstatusbar
;
366 case PM_SETSTATUSTEXT
:
367 SendMessage(_hstatusbar
, SB_SETTEXT
, 0, lparam
);
378 BOOL
MainFrameBase::TranslateMsg(MSG
* pmsg
)
380 if (TranslateAccelerator(_hwnd
, _hAccel
, pmsg
))
387 int MainFrameBase::Command(int id
, int code
)
389 CONTEXT("MainFrameBase::Command()");
393 SendMessage(_hwnd
, WM_CLOSE
, 0, 0);
396 case ID_VIEW_TOOL_BAR
:
397 toggle_child(_hwnd
, id
, _htoolbar
, 0);
400 case ID_VIEW_STATUSBAR
:
401 toggle_child(_hwnd
, id
, _hstatusbar
);
404 case ID_VIEW_SIDE_BAR
:
405 // lazy initialization
406 if (!TreeView_GetCount(_hsidebar
))
409 toggle_child(_hwnd
, id
, _hsidebar
);
413 ExecuteDialog dlg
= {{0}, 0};
415 if (DialogBoxParam(g_Globals
._hInstance
, MAKEINTRESOURCE(IDD_EXECUTE
), _hwnd
, ExecuteDialog::WndProc
, (LPARAM
)&dlg
) == IDOK
) {
416 CONTEXT("ID_EXECUTE - ShellExecute()");
418 HINSTANCE hinst
= ShellExecute(_hwnd
, NULL
/*operation*/, dlg
.cmd
/*file*/, NULL
/*parameters*/, NULL
/*dir*/, dlg
.cmdshow
);
420 if ((int)hinst
<= 32)
421 display_error(_hwnd
, GetLastError());
426 WinHelp(_hwnd
, TEXT("explorer")/*file explorer.hlp*/, HELP_INDEX
, 0);
429 case ID_VIEW_FULLSCREEN
:
430 CheckMenuItem(_menu_info
._hMenuView
, id
, toggle_fullscreen()?MF_CHECKED
:0);
433 case ID_TOOLS_OPTIONS
:
434 Dialog::DoModal(IDD_MDI_SDI
, WINDOW_CREATOR(MdiSdiDlg
), _hwnd
);
437 case ID_ABOUT_WINDOWS
:
438 ShellAbout(_hwnd
, ResString(IDS_TITLE
), NULL
, 0);
441 case ID_ABOUT_EXPLORER
:
442 explorer_about(_hwnd
);
445 case ID_EXPLORER_FAQ
:
446 launch_file(_hwnd
, TEXT("http://www.sky.franken.de/explorer/"), SW_SHOW
);
450 return 1; // no command handlers in Window::Command()
456 int MainFrameBase::Notify(int id
, NMHDR
* pnmh
)
459 // resize children windows when the rebar size changes
462 resize_frame_client();
465 case TVN_GETINFOTIP
: {
466 NMTVGETINFOTIP
* pnmgit
= (NMTVGETINFOTIP
*)pnmh
;
468 if (pnmgit
->lParam
) {
469 const BookmarkNode
& node
= *(BookmarkNode
*)pnmgit
->lParam
;
471 if (node
._type
== BookmarkNode::BMNT_FOLDER
) {
472 // display tooltips for bookmark folders
473 if (!node
._pfolder
->_description
.empty())
474 lstrcpyn(pnmgit
->pszText
, node
._pfolder
->_description
.c_str(), pnmgit
->cchTextMax
);
475 } else if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
476 // display tooltips for bookmark folders
477 String txt
= node
._pbookmark
->_description
;
479 if (!node
._pbookmark
->_url
.empty()) {
483 txt
+= node
._pbookmark
->_url
;
486 lstrcpyn(pnmgit
->pszText
, txt
.c_str(), pnmgit
->cchTextMax
);
492 HTREEITEM hitem
= TreeView_GetSelection(_hsidebar
);
493 LPARAM lparam
= TreeView_GetItemData(_hsidebar
, hitem
);
496 const BookmarkNode
& node
= *(BookmarkNode
*)lparam
;
498 if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
499 bool new_window
= GetAsyncKeyState(VK_SHIFT
)<0;
501 go_to(node
._pbookmark
->_url
, new_window
);
511 void MainFrameBase::resize_frame(int cx
, int cy
)
514 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
516 RECT rect
= {0, 0, cx
, cy
};
519 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
523 SetWindowPos(_haddrcombo
, NULL
, 0, 0, cx
, height
, SWP_NOMOVE
);
525 if (IsWindowVisible(_htoolbar
)) {
526 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
527 WindowRect
rt(_htoolbar
);
528 rect
.top
= rt
.bottom
;
529 // rect.bottom -= rt.bottom;
533 if (IsWindowVisible(_hstatusbar
)) {
534 int parts
[] = {300, 500};
536 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
537 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
538 ClientRect
rt(_hstatusbar
);
539 rect
.bottom
-= rt
.bottom
;
542 if (IsWindowVisible(_hsidebar
)) {
543 WindowRect
rt(_hsidebar
);
544 rect
.left
+= rt
.right
-rt
.left
;
546 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
550 void MainFrameBase::resize_frame_client()
552 ClientRect
rect(_hwnd
);
554 resize_frame(rect
.right
, rect
.bottom
);
557 void MainFrameBase::frame_get_clientspace(PRECT prect
)
559 if (!IsIconic(_hwnd
))
560 GetClientRect(_hwnd
, prect
);
564 GetWindowPlacement(_hwnd
, &wp
);
566 prect
->left
= prect
->top
= 0;
567 prect
->right
= wp
.rcNormalPosition
.right
-wp
.rcNormalPosition
.left
-
568 2*(GetSystemMetrics(SM_CXSIZEFRAME
)+GetSystemMetrics(SM_CXEDGE
));
569 prect
->bottom
= wp
.rcNormalPosition
.bottom
-wp
.rcNormalPosition
.top
-
570 2*(GetSystemMetrics(SM_CYSIZEFRAME
)+GetSystemMetrics(SM_CYEDGE
))-
571 GetSystemMetrics(SM_CYCAPTION
)-GetSystemMetrics(SM_CYMENUSIZE
);
574 if (IsWindowVisible(_htoolbar
)) {
575 ClientRect
rt(_htoolbar
);
576 prect
->top
+= rt
.bottom
+2;
579 if (IsWindowVisible(_hstatusbar
)) {
580 ClientRect
rt(_hstatusbar
);
581 prect
->bottom
-= rt
.bottom
;
585 BOOL
MainFrameBase::toggle_fullscreen()
589 if ((_fullscreen
._mode
=!_fullscreen
._mode
)) {
590 GetWindowRect(_hwnd
, &_fullscreen
._orgPos
);
591 _fullscreen
._wasZoomed
= IsZoomed(_hwnd
);
593 Frame_CalcFrameClient(_hwnd
, &rt
);
594 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.left
);
595 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.right
);
597 rt
.left
= _fullscreen
._orgPos
.left
-rt
.left
;
598 rt
.top
= _fullscreen
._orgPos
.top
-rt
.top
;
599 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+_fullscreen
._orgPos
.right
-rt
.right
;
600 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+_fullscreen
._orgPos
.bottom
-rt
.bottom
;
602 MoveWindow(_hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
604 MoveWindow(_hwnd
, _fullscreen
._orgPos
.left
, _fullscreen
._orgPos
.top
,
605 _fullscreen
._orgPos
.right
-_fullscreen
._orgPos
.left
,
606 _fullscreen
._orgPos
.bottom
-_fullscreen
._orgPos
.top
, TRUE
);
608 if (_fullscreen
._wasZoomed
)
609 ShowWindow(_hwnd
, WS_MAXIMIZE
);
612 return _fullscreen
._mode
;
615 void MainFrameBase::fullscreen_move()
618 GetWindowRect(_hwnd
, &pos
);
620 Frame_CalcFrameClient(_hwnd
, &rt
);
621 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.left
);
622 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.right
);
624 rt
.left
= pos
.left
-rt
.left
;
625 rt
.top
= pos
.top
-rt
.top
;
626 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+pos
.right
-rt
.right
;
627 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+pos
.bottom
-rt
.bottom
;
629 MoveWindow(_hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
633 void MainFrameBase::toggle_child(HWND hwnd
, UINT cmd
, HWND hchild
, int band_idx
)
635 BOOL vis
= IsWindowVisible(hchild
);
637 CheckMenuItem(_menu_info
._hMenuView
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
640 SendMessage(_hwndrebar
, RB_SHOWBAND
, band_idx
, !vis
);
642 ShowWindow(hchild
, vis
? SW_HIDE
: SW_SHOW
);
644 if (_fullscreen
._mode
)
647 resize_frame_client();
650 void MainFrameBase::FillBookmarks()
652 HiddenWindow
hide(_hsidebar
);
653 WindowCanvas
canvas(_hwnd
);
655 TreeView_DeleteAllItems(_hsidebar
);
657 g_Globals
._icon_cache
.get_icon(ICID_FAVORITES
).add_to_imagelist(_himl
, canvas
);
658 g_Globals
._icon_cache
.get_icon(ICID_BOOKMARK
).add_to_imagelist(_himl
, canvas
);
659 ImageList_AddAlphaIcon(_himl
, SmallIcon(IDI_DOT
), GetStockBrush(WHITE_BRUSH
), canvas
);
660 g_Globals
._icon_cache
.get_icon(ICID_FOLDER
).add_to_imagelist(_himl
, canvas
);
661 g_Globals
._icon_cache
.get_icon(ICID_FOLDER
).add_to_imagelist(_himl
, canvas
);
665 tvi
.hParent
= TVI_ROOT
;
666 tvi
.hInsertAfter
= TVI_LAST
;
667 tvi
.item
.mask
= TVIF_TEXT
|TVIF_IMAGE
|TVIF_SELECTEDIMAGE
;
668 ResString
sFavorites(IDS_FAVORITES
);
669 tvi
.item
.pszText
= sFavorites
.str();
670 tvi
.item
.iSelectedImage
= tvi
.item
.iImage
= 0;
672 HTREEITEM hitem_bookmarks
= TreeView_InsertItem(_hsidebar
, &tvi
);
674 g_Globals
._favorites
.fill_tree(_hsidebar
, hitem_bookmarks
, _himl
, canvas
);
676 TreeView_Expand(_hsidebar
, hitem_bookmarks
, TVE_EXPAND
);
680 bool MainFrameBase::go_to(LPCTSTR url
, bool new_window
)
682 ///@todo SDI implementation
690 MDIMainFrame::MDIMainFrame(HWND hwnd
)
693 TBBUTTON mdiBtns
[] = {
694 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
695 {0, ID_WINDOW_NEW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
696 {1, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
697 {2, ID_WINDOW_TILE_HORZ
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
698 {3, ID_WINDOW_TILE_VERT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0}
701 SendMessage(_htoolbar
, TB_ADDBUTTONS
, sizeof(mdiBtns
)/sizeof(TBBUTTON
), (LPARAM
)&mdiBtns
);
703 CLIENTCREATESTRUCT ccs
;
705 ccs
.hWindowMenu
= _hMenuWindow
;
706 ccs
.idFirstChild
= IDW_FIRST_CHILD
;
708 _hmdiclient
= CreateWindowEx(WS_EX_CLIENTEDGE
|WS_EX_NOPARENTNOTIFY
, TEXT("MDICLIENT"), NULL
,
709 WS_CHILD
|WS_CLIPCHILDREN
|WS_VSCROLL
|WS_HSCROLL
|WS_VISIBLE
|WS_BORDER
,
711 hwnd
, 0, g_Globals
._hInstance
, &ccs
);
713 TBBUTTON extraBtns
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
716 _hextrabar
= CreateToolbarEx(hwnd
,
717 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
718 WS_CHILD
|TBSTYLE_FLAT
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,
719 IDW_EXTRABAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, NULL
, 0,
720 16, 16, 16, 16, sizeof(TBBUTTON
));
722 _hextrabar
= CreateToolbarEx(hwnd
,
723 WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,CCS_NODIVIDER
|
724 IDW_EXTRABAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, &extraBtns
, 1,
725 16, 13, 16, 13, sizeof(TBBUTTON
));
728 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_EXTRA_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
731 extraBtns
.fsStyle
= BTNS_BUTTON
;
734 // insert unix file system button
735 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("/\0"));
736 extraBtns
.idCommand
= ID_DRIVE_UNIX_FS
;
737 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
740 // insert explorer window button
741 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Explore\0"));
742 extraBtns
.idCommand
= ID_DRIVE_DESKTOP
;
743 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
745 // insert shell namespace button
746 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Shell\0"));
747 extraBtns
.idCommand
= ID_DRIVE_SHELL_NS
;
748 extraBtns
.iBitmap
= 6;
749 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
751 // insert web control button
752 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Web\0"));
753 extraBtns
.idCommand
= ID_WEB_WINDOW
;
754 extraBtns
.iBitmap
= 7;
755 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
757 if ((HIWORD(GetVersion())>>14) == W_VER_NT
) {
758 // insert NT object namespace button
759 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("NT Obj\0"));
760 extraBtns
.idCommand
= ID_DRIVE_NTOBJ_NS
;
761 extraBtns
.iBitmap
= 8;
762 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
764 #ifndef __REACTOS__ // don't insert reg button for ROS. Regedit should be used.
765 // insert Registry button
766 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Reg.\0"));
767 extraBtns
.idCommand
= ID_DRIVE_REGISTRY
;
768 extraBtns
.iBitmap
= 9;
769 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
773 // insert FAT direct file system access button
774 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("FAT\0"));
775 extraBtns
.idCommand
= ID_DRIVE_FAT
;
776 extraBtns
.iBitmap
= 10;
777 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
781 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
786 _hdrivebar
= CreateToolbarEx(hwnd
,
787 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
788 WS_CHILD
|WS_VISIBLE
|TBSTYLE_FLAT
|CCS_NOMOVEY
|TBSTYLE_LIST
,
789 IDW_DRIVEBAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, NULL
, 0,
790 16, 16, 16, 16, sizeof(TBBUTTON
));
792 _hdrivebar
= CreateToolbarEx(hwnd
,
793 WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
|CCS_NODIVIDER
,
794 IDW_DRIVEBAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, &drivebarBtn
, 1,
795 16, 13, 16, 13, sizeof(TBBUTTON
));
799 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_DRIVE_BAR
, MF_BYCOMMAND
|MF_UNCHECKED
);
803 GetLogicalDriveStrings(BUFFER_LEN
, _drives
);
805 // register windows drive root strings
806 SendMessage(_hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)_drives
);
808 drivebarBtn
.fsStyle
= BTNS_BUTTON
;
809 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
811 for(p
=_drives
; *p
; ) {
812 switch(GetDriveType(p
)) {
813 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
814 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
815 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
816 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
817 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
820 SendMessage(_hdrivebar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&drivebarBtn
);
821 ++drivebarBtn
.idCommand
;
822 ++drivebarBtn
.iString
;
830 int btn_hgt
= HIWORD(SendMessage(_htoolbar
, TB_GETBUTTONSIZE
, 0, 0));
832 REBARBANDINFO rbBand
;
834 rbBand
.cbSize
= sizeof(REBARBANDINFO
);
835 rbBand
.fMask
= RBBIM_TEXT
|RBBIM_STYLE
|RBBIM_CHILD
|RBBIM_CHILDSIZE
|RBBIM_SIZE
;
836 #ifndef RBBS_HIDETITLE // missing in MinGW headers as of 25.02.2004
837 #define RBBS_HIDETITLE 0x400
839 rbBand
.fStyle
= RBBS_CHILDEDGE
|RBBS_GRIPPERALWAYS
|RBBS_HIDETITLE
;
841 TCHAR ExtrasBand
[] = _T("Extras");
842 rbBand
.lpText
= ExtrasBand
;
843 rbBand
.hwndChild
= _hextrabar
;
844 rbBand
.cxMinChild
= 0;
845 rbBand
.cyMinChild
= btn_hgt
;
847 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)1, (LPARAM
)&rbBand
);
850 rbBand
.fStyle
|= RBBS_BREAK
;
851 TCHAR DrivesBand
[] = _T("Drives");
852 rbBand
.lpText
= DrivesBand
;
853 rbBand
.hwndChild
= _hdrivebar
;
854 rbBand
.cxMinChild
= 0;
855 rbBand
.cyMinChild
= btn_hgt
;
857 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)2, (LPARAM
)&rbBand
);
859 // hide the drivebar by default
860 SendMessage(_hwndrebar
, RB_SHOWBAND
, 2, FALSE
);
866 HWND
MDIMainFrame::Create()
868 HMENU hMenuFrame
= LoadMenu(g_Globals
._hInstance
, MAKEINTRESOURCE(IDM_MDIFRAME
));
870 return Window::Create(WINDOW_CREATOR(MDIMainFrame
), 0,
871 (LPCTSTR
)(int)g_Globals
._hframeClass
, ResString(IDS_TITLE
), WS_OVERLAPPEDWINDOW
,
872 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
873 0/*hwndDesktop*/, hMenuFrame
);
876 HWND
MDIMainFrame::Create(LPCTSTR path
, int mode
)
878 HWND hFrame
= Create();
882 ShowWindow(hFrame
, SW_SHOW
);
884 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
887 pMainFrame
->CreateChild(path
, mode
);
892 HWND
MDIMainFrame::Create(LPCITEMIDLIST pidl
, int mode
)
894 HWND hFrame
= Create();
898 ShowWindow(hFrame
, SW_SHOW
);
900 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
903 pMainFrame
->CreateChild(pidl
, mode
);
909 ChildWindow
* MDIMainFrame::CreateChild(LPCTSTR path
, int mode
)
911 return reinterpret_cast<ChildWindow
*>(SendMessage(_hwnd
, PM_OPEN_WINDOW
, mode
, (LPARAM
)path
));
914 ChildWindow
* MDIMainFrame::CreateChild(LPCITEMIDLIST pidl
, int mode
)
916 return reinterpret_cast<ChildWindow
*>(SendMessage(_hwnd
, PM_OPEN_WINDOW
, mode
|OWM_PIDL
, (LPARAM
)pidl
));
920 BOOL
MDIMainFrame::TranslateMsg(MSG
* pmsg
)
922 if (_hmdiclient
&& TranslateMDISysAccel(_hmdiclient
, pmsg
))
925 return super::TranslateMsg(pmsg
);
928 LRESULT
MDIMainFrame::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
931 case PM_OPEN_WINDOW
: {
932 CONTEXT("MDIMainFrame PM_OPEN_WINDOW");
934 TCHAR buffer
[MAX_PATH
];
936 ShellPath shell_path
= DesktopFolderPath();
939 if (wparam
& OWM_PIDL
) {
940 // take over PIDL from lparam
941 shell_path
.assign((LPCITEMIDLIST
)lparam
); // create as "rooted" window
942 FileSysShellPath
fsp(shell_path
);
946 LOG(FmtString(TEXT("MDIMainFrame PM_OPEN_WINDOW: path=%s"), path
));
947 lstrcpy(buffer
, path
);
951 // take over path from lparam
952 path
= (LPCTSTR
)lparam
;
953 shell_path
= path
; // create as "rooted" window
956 ///@todo read paths and window placements from registry
957 if (!GetCurrentDirectory(MAX_PATH
, buffer
))
963 if (path
&& _tcsstr(path
, TEXT("://"))) { // "http://...", "ftp://", ...
964 OBJ_CONTEXT("create WebChild window", path
);
966 return (LRESULT
)GET_WINDOW(ChildWindow
, create_webchildwindow(WebChildWndInfo(_hmdiclient
, path
)));
968 OBJ_CONTEXT("create ShellChildWndInfo", path
);
970 // Shell Namespace as default view
971 ShellChildWndInfo
create_info(_hmdiclient
, path
, shell_path
);
973 if (wparam
& OWM_ROOTED
)
974 create_info
._root_shell_path
= shell_path
;
976 create_info
._root_shell_path
= DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
978 create_info
._pos
.showCmd
= wparam
&OWM_SEPARATE
? SW_SHOWNORMAL
: SW_SHOWMAXIMIZED
;
979 create_info
._pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
980 create_info
._pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
981 create_info
._pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
982 create_info
._pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
984 create_info
._open_mode
= wparam
;
986 // FileChildWindow::create(_hmdiclient, create_info);
987 return (LRESULT
)MDIShellBrowserChild::create(create_info
);
989 return TRUE
;} // success
994 if (super::ProcessMessage(nmsg
, wparam
, lparam
, &res
))
997 return DefFrameProc(_hwnd
, _hmdiclient
, nmsg
, wparam
, lparam
);
1004 int MDIMainFrame::Command(int id
, int code
)
1006 CONTEXT("MDIMainFrame::Command()");
1008 HWND hwndClient
= (HWND
) SendMessage(_hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1011 if (SendMessage(hwndClient
, PM_DISPATCH_COMMAND
, MAKELONG(id
,code
), 0))
1015 if (id
>=ID_DRIVE_FIRST
&& id
<=ID_DRIVE_FIRST
+0xFF) {
1016 TCHAR drv
[_MAX_DRIVE
], path
[MAX_PATH
];
1017 LPCTSTR root
= _drives
;
1019 for(int i
=id
-ID_DRIVE_FIRST
; i
--; root
++)
1023 if (activate_drive_window(root
))
1026 _tsplitpath_s(root
, drv
, COUNTOF(drv
), NULL
, 0, NULL
, 0, NULL
, 0);
1028 if (!SetCurrentDirectory(drv
)) {
1029 display_error(_hwnd
, GetLastError());
1033 GetCurrentDirectory(MAX_PATH
, path
); ///@todo store last directory per drive
1035 FileChildWindow::create(FileChildWndInfo(_hmdiclient
, path
));
1042 case ID_WINDOW_NEW
: {
1043 TCHAR path
[MAX_PATH
];
1045 GetCurrentDirectory(MAX_PATH
, path
);
1047 FileChildWindow::create(FileChildWndInfo(_hmdiclient
, path
));
1050 case ID_WINDOW_CASCADE
:
1051 SendMessage(_hmdiclient
, WM_MDICASCADE
, 0, 0);
1054 case ID_WINDOW_TILE_HORZ
:
1055 SendMessage(_hmdiclient
, WM_MDITILE
, MDITILE_HORIZONTAL
, 0);
1058 case ID_WINDOW_TILE_VERT
:
1059 SendMessage(_hmdiclient
, WM_MDITILE
, MDITILE_VERTICAL
, 0);
1062 case ID_WINDOW_ARRANGE
:
1063 SendMessage(_hmdiclient
, WM_MDIICONARRANGE
, 0, 0);
1066 case ID_VIEW_EXTRA_BAR
:
1067 toggle_child(_hwnd
, id
, _hextrabar
, 1);
1071 case ID_VIEW_DRIVE_BAR
:
1072 toggle_child(_hwnd
, id
, _hdrivebar
, 2);
1077 case ID_DRIVE_UNIX_FS
: {
1078 TCHAR path
[MAX_PATH
];
1079 FileChildWindow
* child
;
1081 getcwd(path
, COUNTOF(path
));
1083 if (activate_child_window(TEXT("unixfs")))
1086 FileChildWindow::create(_hmdiclient
, FileChildWndInfo(path
));
1090 case ID_DRIVE_DESKTOP
: {
1091 TCHAR path
[MAX_PATH
];
1093 if (activate_child_window(TEXT("Desktop")))
1096 GetCurrentDirectory(MAX_PATH
, path
);
1098 MDIShellBrowserChild::create(ShellChildWndInfo(_hmdiclient
, path
, DesktopFolderPath()));
1101 case ID_DRIVE_SHELL_NS
: {
1102 TCHAR path
[MAX_PATH
];
1103 GetCurrentDirectory(MAX_PATH
, path
);
1105 if (activate_child_window(TEXT("Shell")))
1108 FileChildWindow::create(ShellChildWndInfo(_hmdiclient
, path
, DesktopFolderPath()));
1111 case ID_DRIVE_NTOBJ_NS
: {
1112 if (activate_child_window(TEXT("NTOBJ")))
1115 FileChildWindow::create(NtObjChildWndInfo(_hmdiclient
, TEXT("\\")));
1118 case ID_DRIVE_REGISTRY
: {
1119 if (activate_child_window(TEXT("Registry")))
1122 FileChildWindow::create(RegistryChildWndInfo(_hmdiclient
, TEXT("\\")));
1125 case ID_DRIVE_FAT
: {
1127 ///@todo prompt for image file
1129 if (activate_child_window(TEXT("FAT")))
1132 FileChildWindow::create(FATChildWndInfo(_hmdiclient
, TEXT("FAT Image"))); //@@
1137 create_webchildwindow(WebChildWndInfo(_hmdiclient
, TEXT("http://localhost")));
1139 create_webchildwindow(WebChildWndInfo(_hmdiclient
, TEXT("http://www.reactos.org")));
1143 case ID_EXPLORER_FAQ
:
1144 create_webchildwindow(WebChildWndInfo(_hmdiclient
, TEXT("http://www.sky.franken.de/explorer/")));
1148 MainFrameBase::Create(ExplorerCmd());
1151 ///@todo There are even more menu items!
1154 if (super::Command(id
, code
) == 0)
1157 return DefFrameProc(_hwnd
, _hmdiclient
, WM_COMMAND
, MAKELONG(id
,code
), 0);
1164 void MDIMainFrame::frame_get_clientspace(PRECT prect
)
1166 super::frame_get_clientspace(prect
);
1169 if (IsWindowVisible(_hdrivebar
)) {
1170 ClientRect
rt(_hdrivebar
);
1171 prect
->top
+= rt
.bottom
+2;
1176 void MDIMainFrame::resize_frame(int cx
, int cy
)
1179 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
1181 RECT rect
= {0, 0, cx
, cy
};
1184 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
1188 if (IsWindowVisible(_htoolbar
)) {
1189 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
1190 WindowRect
rt(_htoolbar
);
1191 rect
.top
= rt
.bottom
;
1192 // rect.bottom -= rt.bottom;
1195 if (IsWindowVisible(_hextrabar
)) {
1196 SendMessage(_hextrabar
, WM_SIZE
, 0, 0);
1197 WindowRect
rt(_hextrabar
);
1198 int new_top
= --rect
.top
+ rt
.bottom
;
1199 MoveWindow(_hextrabar
, 0, rect
.top
, rt
.right
, new_top
, TRUE
);
1201 // rect.bottom -= rt.bottom;
1205 if (IsWindowVisible(_hdrivebar
)) {
1206 SendMessage(_hdrivebar
, WM_SIZE
, 0, 0);
1207 WindowRect
rt(_hdrivebar
);
1208 int new_top
= --rect
.top
+ rt
.bottom
;
1209 MoveWindow(_hdrivebar
, 0, rect
.top
, rt
.right
, new_top
, TRUE
);
1211 // rect.bottom -= rt.bottom;
1216 if (IsWindowVisible(_hstatusbar
)) {
1217 int parts
[] = {300, 500};
1219 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
1220 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1221 ClientRect
rt(_hstatusbar
);
1222 rect
.bottom
-= rt
.bottom
;
1225 if (IsWindowVisible(_hsidebar
)) {
1226 WindowRect
rt(_hsidebar
);
1227 rect
.left
+= rt
.right
-rt
.left
;
1229 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
1232 MoveWindow(_hmdiclient
, rect
.left
-1, rect
.top
-1, rect
.right
-rect
.left
+1, rect
.bottom
-rect
.top
+1, TRUE
);
1235 bool MDIMainFrame::activate_drive_window(LPCTSTR path
)
1237 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
1240 _tsplitpath_s(path
, drv1
, COUNTOF(drv1
), NULL
, 0, NULL
, 0, NULL
, 0);
1242 // search for a already open window for the same drive
1243 for(child_wnd
=GetNextWindow(_hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1244 FileChildWindow
* child
= (FileChildWindow
*) SendMessage(child_wnd
, PM_GET_FILEWND_PTR
, 0, 0);
1247 _tsplitpath_s(child
->get_root()._path
, drv2
, COUNTOF(drv2
), NULL
, 0, NULL
, 0, NULL
, 0);
1249 if (!lstrcmpi(drv2
, drv1
)) {
1250 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1252 if (IsMinimized(child_wnd
))
1253 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1263 bool MDIMainFrame::activate_child_window(LPCTSTR filesys
)
1267 // search for a already open window of the given file system name
1268 for(child_wnd
=GetNextWindow(_hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1269 FileChildWindow
* child
= (FileChildWindow
*) SendMessage(child_wnd
, PM_GET_FILEWND_PTR
, 0, 0);
1272 if (!lstrcmpi(child
->get_root()._fs
, filesys
)) {
1273 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1275 if (IsMinimized(child_wnd
))
1276 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1281 ShellBrowser
* shell_child
= (ShellBrowser
*) SendMessage(child_wnd
, PM_GET_SHELLBROWSER_PTR
, 0, 0);
1284 if (!lstrcmpi(shell_child
->get_root()._fs
, filesys
)) {
1285 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1287 if (IsMinimized(child_wnd
))
1288 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1299 bool MDIMainFrame::go_to(LPCTSTR url
, bool new_window
)
1302 HWND hwndClient
= (HWND
) SendMessage(_hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1305 if (SendMessage(hwndClient
, PM_JUMP_TO_URL
, 0, (LPARAM
)url
))
1309 if (CreateChild(url
))
1312 return super::go_to(url
, new_window
);
1318 SDIMainFrame::SDIMainFrame(HWND hwnd
)
1321 _split_pos
= DEFAULT_SPLIT_POS
;
1322 _last_split
= DEFAULT_SPLIT_POS
;
1324 /* wait for PM_OPEN_WINDOW message before creating a shell view
1325 update_shell_browser();*/
1328 HWND
SDIMainFrame::Create()
1330 HMENU hMenuFrame
= LoadMenu(g_Globals
._hInstance
, MAKEINTRESOURCE(IDM_SDIFRAME
));
1332 return Window::Create(WINDOW_CREATOR(SDIMainFrame
), 0,
1333 (LPCTSTR
)(int)g_Globals
._hframeClass
, ResString(IDS_TITLE
), WS_OVERLAPPEDWINDOW
,
1334 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
1335 0/*hwndDesktop*/, hMenuFrame
);
1338 HWND
SDIMainFrame::Create(LPCITEMIDLIST pidl
, int mode
)
1340 HWND hFrame
= Create();
1344 ShowWindow(hFrame
, SW_SHOW
);
1346 SDIMainFrame
* pFrame
= GET_WINDOW(SDIMainFrame
, hFrame
);
1349 pFrame
->jump_to(pidl
, mode
);
1354 HWND
SDIMainFrame::Create(LPCTSTR path
, int mode
)
1356 HWND hFrame
= Create();
1360 ShowWindow(hFrame
, SW_SHOW
);
1362 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
1365 pMainFrame
->CreateChild(path
, mode
);
1370 LRESULT
SDIMainFrame::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1374 resize_frame(LOWORD(lparam
), HIWORD(lparam
));
1378 PaintCanvas
canvas(_hwnd
);
1381 ClientRect
rt(_hwnd
);
1382 rt
.left
= _split_pos
-SPLIT_WIDTH
/2;
1383 rt
.right
= _split_pos
+SPLIT_WIDTH
/2+1;
1386 WindowRect
right_rect(_right_hwnd
);
1387 ScreenToClient(_hwnd
, &right_rect
);
1388 rt
.top
= right_rect
.top
;
1389 rt
.bottom
= right_rect
.bottom
;
1392 HBRUSH lastBrush
= SelectBrush(canvas
, GetStockBrush(COLOR_SPLITBAR
));
1393 Rectangle(canvas
, rt
.left
, rt
.top
-1, rt
.right
, rt
.bottom
+1);
1394 SelectObject(canvas
, lastBrush
);
1400 if (LOWORD(lparam
) == HTCLIENT
) {
1403 ScreenToClient(_hwnd
, &pt
);
1405 if (pt
.x
>=_split_pos
-SPLIT_WIDTH
/2 && pt
.x
<_split_pos
+SPLIT_WIDTH
/2+1) {
1406 SetCursor(LoadCursor(0, IDC_SIZEWE
));
1412 case WM_LBUTTONDOWN
:
1414 int x
= GET_X_LPARAM(lparam
);
1416 ClientRect
rt(_hwnd
);
1418 if (x
>=_split_pos
-SPLIT_WIDTH
/2 && x
<_split_pos
+SPLIT_WIDTH
/2+1) {
1419 _last_split
= _split_pos
;
1426 if (GetCapture() == _hwnd
)
1431 if (wparam
== VK_ESCAPE
)
1432 if (GetCapture() == _hwnd
) {
1433 _split_pos
= _last_split
;
1437 SetCursor(LoadCursor(0, IDC_ARROW
));
1442 if (GetCapture() == _hwnd
) {
1443 int x
= GET_X_LPARAM(lparam
);
1445 ClientRect
rt(_hwnd
);
1447 if (x
>=0 && x
<rt
.right
) {
1450 rt
.left
= x
-SPLIT_WIDTH
/2;
1451 rt
.right
= x
+SPLIT_WIDTH
/2+1;
1452 InvalidateRect(_hwnd
, &rt
, FALSE
);
1453 UpdateWindow(_left_hwnd
);
1454 UpdateWindow(_hwnd
);
1455 UpdateWindow(_right_hwnd
);
1460 case PM_OPEN_WINDOW
: {
1461 CONTEXT("SDIMainFrame PM_OPEN_WINDOW");
1463 TCHAR buffer
[MAX_PATH
];
1465 ShellPath shell_path
= DesktopFolderPath();
1468 if (wparam
& OWM_PIDL
) {
1469 // take over PIDL from lparam
1470 shell_path
.assign((LPCITEMIDLIST
)lparam
); // create as "rooted" window
1471 FileSysShellPath
fsp(shell_path
);
1475 LOG(FmtString(TEXT("SDIMainFrame PM_OPEN_WINDOW: path=%s"), path
));
1476 lstrcpy(buffer
, path
);
1480 // take over path from lparam
1481 path
= (LPCTSTR
)lparam
;
1482 shell_path
= path
; // create as "rooted" window
1485 ///@todo read paths and window placements from registry
1486 if (!GetCurrentDirectory(MAX_PATH
, buffer
))
1493 if (wparam
& OWM_ROOTED
)
1494 _shellpath_info
._root_shell_path
= shell_path
;
1496 _shellpath_info
._root_shell_path
= DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
1498 jump_to(shell_path
, wparam
); ///@todo content of 'path' not used any more
1499 return TRUE
;} // success
1502 return super::WndProc(nmsg
, wparam
, lparam
);
1508 int SDIMainFrame::Command(int id
, int code
)
1512 MainFrameBase::Create(ExplorerCmd(_url
, true));
1516 return super::Command(id
, code
);
1522 void SDIMainFrame::resize_frame(int cx
, int cy
)
1525 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
1527 RECT rect
= {0, 0, cx
, cy
};
1530 int height
= ClientRect(_hwndrebar
).bottom
;
1534 if (IsWindowVisible(_htoolbar
)) {
1535 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
1536 WindowRect
rt(_htoolbar
);
1537 rect
.top
= rt
.bottom
;
1538 // rect.bottom -= rt.bottom;
1542 if (IsWindowVisible(_hstatusbar
)) {
1543 int parts
[] = {300, 500};
1545 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
1546 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1547 ClientRect
rt(_hstatusbar
);
1548 rect
.bottom
-= rt
.bottom
;
1551 if (IsWindowVisible(_hsidebar
)) {
1552 WindowRect
rt(_hsidebar
);
1553 rect
.left
+= rt
.right
-rt
.left
;
1555 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
1563 void SDIMainFrame::resize_children()
1565 HDWP hdwp
= BeginDeferWindowPos(2);
1567 int cx
= _clnt_rect
.left
;
1570 cx
= _split_pos
+ SPLIT_WIDTH
/2;
1572 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
);
1579 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
);
1581 EndDeferWindowPos(hdwp
);
1584 void SDIMainFrame::update_clnt_rect()
1586 ClientRect
rect(_hwnd
);
1588 resize_frame(rect
.right
, rect
.bottom
);
1591 void SDIMainFrame::update_shell_browser()
1593 int split_pos
= DEFAULT_SPLIT_POS
;
1595 if (_shellBrowser
.get()) {
1596 split_pos
= _split_pos
;
1597 delete _shellBrowser
.release();
1600 // create explorer treeview
1601 if (_shellpath_info
._open_mode
& OWM_EXPLORE
) {
1603 ClientRect
rect(_hwnd
);
1605 _left_hwnd
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, NULL
,
1606 WS_CHILD
|WS_TABSTOP
|WS_VISIBLE
|TVS_HASLINES
|TVS_LINESATROOT
|TVS_HASBUTTONS
|TVS_NOTOOLTIPS
|TVS_SHOWSELALWAYS
,
1607 0, rect
.top
, split_pos
-SPLIT_WIDTH
/2, rect
.bottom
-rect
.top
,
1608 _hwnd
, (HMENU
)IDC_FILETREE
, g_Globals
._hInstance
, 0);
1610 // display tree window as long as the shell view is not yet visible
1611 resize_frame(rect
.right
, rect
.bottom
);
1612 MoveWindow(_left_hwnd
, rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
1616 DestroyWindow(_left_hwnd
);
1621 _shellBrowser
= auto_ptr
<ShellBrowser
>(new ShellBrowser(_hwnd
, _hwnd
, _left_hwnd
, _right_hwnd
,
1622 _shellpath_info
, this, _cm_ifs
));
1625 _shellBrowser
->Init();
1627 // update _clnt_rect and set size of new created shell view windows
1631 void SDIMainFrame::entry_selected(Entry
* entry
)
1634 _shellBrowser
->select_folder(entry
, false);
1636 _shellBrowser
->UpdateFolderView(entry
->get_shell_folder());
1638 // set size of new created shell view windows
1642 void SDIMainFrame::set_url(LPCTSTR url
)
1646 SetWindowText(_haddrcombo
, url
);
1651 void SDIMainFrame::jump_to(LPCTSTR path
, int mode
)
1653 if (_shellBrowser.get() && (_shellpath_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) {
1654 _shellBrowser->jump_to(path);
1656 _shellpath_info._shell_path = path;
1658 _shellpath_info
._open_mode
= mode
;
1659 _shellpath_info
._shell_path
= path
;
1661 update_shell_browser();
1665 void SDIMainFrame::jump_to(LPCITEMIDLIST path
, int mode
)
1667 if (_shellBrowser
.get() && (_shellpath_info
._open_mode
&~OWM_PIDL
)==(mode
&~OWM_PIDL
)) {
1668 ShellPath shell_path
= path
;
1670 _shellBrowser
->jump_to(shell_path
);
1672 _shellpath_info
._shell_path
= shell_path
;
1674 _shellpath_info
._open_mode
= mode
;
1675 _shellpath_info
._shell_path
= path
;
1677 update_shell_browser();