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", true);
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 _himl
= ImageList_Create(GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), ILC_MASK
|ILC_COLOR24
, 2, 0);
157 _hMenuFrame
= GetMenu(hwnd
);
158 _hMenuWindow
= GetSubMenu(_hMenuFrame
, GetMenuItemCount(_hMenuFrame
)-3);
160 _menu_info
._hMenuView
= GetSubMenu(_hMenuFrame
, 1);
162 _hAccel
= LoadAccelerators(g_Globals
._hInstance
, MAKEINTRESOURCE(IDA_EXPLORER
));
165 TBBUTTON toolbarBtns
[] = {
167 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
169 {7, ID_GO_BACK
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
170 {8, ID_GO_FORWARD
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
171 {9, ID_GO_UP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
172 {10, ID_GO_HOME
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
173 {11, ID_GO_SEARCH
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
174 {12, ID_REFRESH
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
175 {13, ID_STOP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0}
178 _htoolbar
= CreateToolbarEx(hwnd
,
180 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
182 WS_CHILD
|TBSTYLE_FLAT
|WS_VISIBLE
, IDW_TOOLBAR
, 2, g_Globals
._hInstance
, IDB_TOOLBAR
,
183 toolbarBtns
, sizeof(toolbarBtns
)/sizeof(TBBUTTON
),
184 16, 15, 16, 15, sizeof(TBBUTTON
));
186 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_TOOL_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
189 // address & command bar
190 WindowCanvas
canvas(hwnd
);
191 RECT rect
= {0, 0, 0, 0};
192 DrawText(canvas
, TEXT("My"), -1, &rect
, DT_SINGLELINE
|DT_NOPREFIX
|DT_CALCRECT
);
193 HFONT hfont
= GetStockFont(DEFAULT_GUI_FONT
);
195 _haddressedit
= CreateWindow(TEXT("EDIT"), NULL
, WS_CHILD
|WS_VISIBLE
, 0, 0, 0, rect
.bottom
,
196 hwnd
, (HMENU
)IDW_ADDRESSBAR
, g_Globals
._hInstance
, 0);
197 SetWindowFont(_haddressedit
, hfont
, FALSE
);
198 new EditController(_haddressedit
);
200 _hcommandedit
= CreateWindow(TEXT("EDIT"), TEXT("> "), WS_CHILD
|WS_VISIBLE
, 0, 0, 0, rect
.bottom
,
201 hwnd
, (HMENU
)IDW_COMMANDBAR
, g_Globals
._hInstance
, 0);
202 SetWindowFont(_hcommandedit
, hfont
, FALSE
);
203 new EditController(_hcommandedit
);
205 /* CreateStatusWindow does not accept WS_BORDER
206 _hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0,
207 WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0,
208 hwnd, (HMENU)IDW_STATUSBAR, g_Globals._hInstance, 0);*/
210 _hstatusbar
= CreateStatusWindow(WS_CHILD
|WS_VISIBLE
, 0, hwnd
, IDW_STATUSBAR
);
211 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
213 _hsidebar
= CreateWindowEx(WS_EX_STATICEDGE
, WC_TREEVIEW
, TEXT("Sidebar"),
214 WS_CHILD
|WS_TABSTOP
|WS_BORDER
|/*WS_VISIBLE|*/WS_CHILD
|TVS_HASLINES
|TVS_HASBUTTONS
|TVS_SHOWSELALWAYS
|TVS_INFOTIP
,
215 -1, -1, 200, 0, _hwnd
, (HMENU
)IDW_SIDEBAR
, g_Globals
._hInstance
, 0);
217 _himl_old
= TreeView_SetImageList(_hsidebar
, _himl
, TVSIL_NORMAL
);
219 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_SIDE_BAR
, MF_BYCOMMAND
|MF_UNCHECKED
/*MF_CHECKED*/);
222 // create rebar window to manage toolbar and drivebar
224 _hwndrebar
= CreateWindowEx(WS_EX_TOOLWINDOW
, REBARCLASSNAME
, NULL
,
225 WS_CHILD
|WS_VISIBLE
|WS_CLIPSIBLINGS
|WS_CLIPCHILDREN
|
226 RBS_VARHEIGHT
|RBS_DBLCLKTOGGLE
|
227 WS_BORDER
|RBS_AUTOSIZE
|RBS_BANDBORDERS
,
228 0, 0, 0, 0, _hwnd
, 0, g_Globals
._hInstance
, 0);
230 int btn_hgt
= HIWORD(SendMessage(_htoolbar
, TB_GETBUTTONSIZE
, 0, 0));
232 REBARBANDINFO rbBand
;
234 rbBand
.cbSize
= sizeof(REBARBANDINFO
);
235 rbBand
.fMask
= RBBIM_TEXT
|RBBIM_STYLE
|RBBIM_CHILD
|RBBIM_CHILDSIZE
|RBBIM_SIZE
;
236 #ifndef RBBS_HIDETITLE // missing in MinGW headers as of 25.02.2004
237 #define RBBS_HIDETITLE 0x400
239 rbBand
.fStyle
= RBBS_CHILDEDGE
|RBBS_GRIPPERALWAYS
|RBBS_HIDETITLE
;
241 rbBand
.cxMinChild
= 0;
242 rbBand
.cyMinChild
= 0;
244 rbBand
.cyMaxChild
= 0;
245 rbBand
.cyIntegral
= btn_hgt
;
247 rbBand
.lpText
= NULL
;//TEXT("Toolbar");
248 rbBand
.hwndChild
= _htoolbar
;
249 rbBand
.cxMinChild
= 0;
250 rbBand
.cyMinChild
= btn_hgt
;
252 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)-1, (LPARAM
)&rbBand
);
257 MainFrameBase::~MainFrameBase()
259 (void)TreeView_SetImageList(_hsidebar
, _himl_old
, TVSIL_NORMAL
);
260 ImageList_Destroy(_himl
);
262 // don't exit desktop when closing file manager window
263 if (!g_Globals
._desktop_mode
)
264 if (g_Globals
._hMainWnd
== _hwnd
) // don't quit when switching between MDI and SDI mode
269 LRESULT
MainFrameBase::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
273 if (ProcessMessage(nmsg
, wparam
, lparam
, &res
))
276 return super::WndProc(nmsg
, wparam
, lparam
);
279 bool MainFrameBase::ProcessMessage(UINT nmsg
, WPARAM wparam
, LPARAM lparam
, LRESULT
* pres
)
282 case PM_TRANSLATE_MSG
:
283 *pres
= TranslateMsg((MSG
*)lparam
);
287 if (wparam
) { // trigger child resizing after window creation - now we can succesfully call IsWindowVisible()
288 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
289 MoveWindow(_hwndrebar
, 0, 0, LOWORD(lparam
), height
, TRUE
);
290 resize_frame_client();
292 return false; // goto def;
295 DestroyWindow(_hwnd
);
296 g_Globals
._hMainWnd
= 0;
303 #ifdef _ROS_ ///@todo Work around to display rebar in ROS (with flickering) as long as the control isn't fixed
304 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
305 MoveWindow(_hwndrebar
, 0, 0, LOWORD(lparam
), height
, TRUE
);
307 resize_frame(LOWORD(lparam
), HIWORD(lparam
));
308 SendMessage(_hwndrebar
, WM_SIZE
, 0, 0);
310 break;} // do not pass message to DefFrameProc
312 case WM_GETMINMAXINFO
: {
313 LPMINMAXINFO lpmmi
= (LPMINMAXINFO
)lparam
;
315 lpmmi
->ptMaxTrackSize
.x
<<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
316 lpmmi
->ptMaxTrackSize
.y
<<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
319 case PM_FRM_CALC_CLIENT
:
320 frame_get_clientspace((PRECT
)lparam
);
324 case PM_FRM_GET_MENUINFO
:
325 *pres
= (LPARAM
)&_menu_info
;
328 case PM_GET_CONTROLWINDOW
:
329 if (wparam
== FCW_STATUS
) {
330 *pres
= (LRESULT
)(HWND
)_hstatusbar
;
335 case PM_SETSTATUSTEXT
:
336 SendMessage(_hstatusbar
, SB_SETTEXT
, 0, lparam
);
340 SetWindowText(_haddressedit
, (LPCTSTR
)lparam
);
351 BOOL
MainFrameBase::TranslateMsg(MSG
* pmsg
)
353 if (TranslateAccelerator(_hwnd
, _hAccel
, pmsg
))
360 int MainFrameBase::Command(int id
, int code
)
362 CONTEXT("MainFrameBase::Command()");
366 SendMessage(_hwnd
, WM_CLOSE
, 0, 0);
369 case ID_VIEW_TOOL_BAR
:
370 toggle_child(_hwnd
, id
, _htoolbar
, 0);
373 case ID_VIEW_STATUSBAR
:
374 toggle_child(_hwnd
, id
, _hstatusbar
);
377 case ID_VIEW_SIDE_BAR
:
378 // lazy initialization
379 if (!TreeView_GetCount(_hsidebar
))
382 toggle_child(_hwnd
, id
, _hsidebar
);
386 ExecuteDialog dlg
= {{0}, 0};
388 if (DialogBoxParam(g_Globals
._hInstance
, MAKEINTRESOURCE(IDD_EXECUTE
), _hwnd
, ExecuteDialog::WndProc
, (LPARAM
)&dlg
) == IDOK
) {
389 CONTEXT("ID_EXECUTE - ShellExecute()");
391 HINSTANCE hinst
= ShellExecute(_hwnd
, NULL
/*operation*/, dlg
.cmd
/*file*/, NULL
/*parameters*/, NULL
/*dir*/, dlg
.cmdshow
);
393 if ((int)hinst
<= 32)
394 display_error(_hwnd
, GetLastError());
399 WinHelp(_hwnd
, TEXT("explorer")/*file explorer.hlp*/, HELP_INDEX
, 0);
402 case ID_VIEW_FULLSCREEN
:
403 CheckMenuItem(_menu_info
._hMenuView
, id
, toggle_fullscreen()?MF_CHECKED
:0);
406 case ID_TOOLS_OPTIONS
:
407 Dialog::DoModal(IDD_MDI_SDI
, WINDOW_CREATOR(MdiSdiDlg
), _hwnd
);
410 case ID_ABOUT_WINDOWS
:
411 ShellAbout(_hwnd
, ResString(IDS_TITLE
), NULL
, 0);
414 case ID_ABOUT_EXPLORER
:
415 explorer_about(_hwnd
);
418 case ID_EXPLORER_FAQ
:
419 launch_file(_hwnd
, TEXT("http://www.sky.franken.de/explorer/"), SW_SHOW
);
424 TCHAR url
[BUFFER_LEN
];
426 if (GetWindowText(_haddressedit
, url
, BUFFER_LEN
))
433 ExecuteCommandbar(NULL
);
437 return 1; // no command handlers in Window::Command()
444 void MainFrameBase::ExecuteCommandbar(LPCTSTR dir
)
446 TCHAR cmd
[BUFFER_LEN
];
448 if (GetWindowText(_hcommandedit
, cmd
, BUFFER_LEN
)) {
449 CONTEXT("ExecuteCommandbar - ShellExecute()");
451 // remove command prompt from 'cmd' string
461 // remove "file://" from directory URL
462 if (!_tcsnicmp(dir
, TEXT("file://"), 7))
466 ///@todo use SHGetFileInfo() with SHGFI_EXETYPE flag to determine EXE type and open console window
468 HINSTANCE hinst
= ShellExecute(_hwnd
, NULL
, p
, NULL
, dir
, SW_SHOWNORMAL
);
470 if ((int)hinst
<= 32)
471 display_error(_hwnd
, GetLastError());
476 int MainFrameBase::Notify(int id
, NMHDR
* pnmh
)
479 // resize children windows when the rebar size changes
482 resize_frame_client();
485 case TVN_GETINFOTIP
: {
486 NMTVGETINFOTIP
* pnmgit
= (NMTVGETINFOTIP
*)pnmh
;
488 if (pnmgit
->lParam
) {
489 const BookmarkNode
& node
= *(BookmarkNode
*)pnmgit
->lParam
;
491 if (node
._type
== BookmarkNode::BMNT_FOLDER
) {
492 // display tooltips for bookmark folders
493 if (!node
._pfolder
->_description
.empty())
494 lstrcpyn(pnmgit
->pszText
, node
._pfolder
->_description
.c_str(), pnmgit
->cchTextMax
);
495 } else if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
496 // display tooltips for bookmark folders
497 String txt
= node
._pbookmark
->_description
;
499 if (!node
._pbookmark
->_url
.empty()) {
503 txt
+= node
._pbookmark
->_url
;
506 lstrcpyn(pnmgit
->pszText
, txt
.c_str(), pnmgit
->cchTextMax
);
512 HTREEITEM hitem
= TreeView_GetSelection(_hsidebar
);
513 LPARAM lparam
= TreeView_GetItemData(_hsidebar
, hitem
);
516 const BookmarkNode
& node
= *(BookmarkNode
*)lparam
;
518 if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
519 bool new_window
= GetAsyncKeyState(VK_SHIFT
)<0;
521 go_to(node
._pbookmark
->_url
, new_window
);
531 void MainFrameBase::resize_frame(int cx
, int cy
)
534 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
536 RECT rect
= {0, 0, cx
, cy
};
539 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
543 if (IsWindowVisible(_htoolbar
)) {
544 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
545 WindowRect
rt(_htoolbar
);
546 rect
.top
= rt
.bottom
;
547 // rect.bottom -= rt.bottom;
551 if (IsWindowVisible(_hstatusbar
)) {
552 int parts
[] = {300, 500};
554 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
555 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
556 ClientRect
rt(_hstatusbar
);
557 rect
.bottom
-= rt
.bottom
;
560 if (IsWindowVisible(_haddressedit
) || IsWindowVisible(_hcommandedit
)) {
561 ClientRect
rt(_haddressedit
);
562 rect
.bottom
-= rt
.bottom
;
564 int mid
= (rect
.right
-rect
.left
) / 2; ///@todo use split bar
565 SetWindowPos(_haddressedit
, 0, 0, rect
.bottom
, mid
, rt
.bottom
, SWP_NOACTIVATE
|SWP_NOZORDER
);
566 SetWindowPos(_hcommandedit
, 0, mid
+1, rect
.bottom
, rect
.right
-(mid
+1), rt
.bottom
, SWP_NOACTIVATE
|SWP_NOZORDER
);
569 if (IsWindowVisible(_hsidebar
)) {
570 WindowRect
rt(_hsidebar
);
571 rect
.left
+= rt
.right
-rt
.left
;
573 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
577 void MainFrameBase::resize_frame_client()
579 ClientRect
rect(_hwnd
);
581 resize_frame(rect
.right
, rect
.bottom
);
584 void MainFrameBase::frame_get_clientspace(PRECT prect
)
586 if (!IsIconic(_hwnd
))
587 GetClientRect(_hwnd
, prect
);
591 GetWindowPlacement(_hwnd
, &wp
);
593 prect
->left
= prect
->top
= 0;
594 prect
->right
= wp
.rcNormalPosition
.right
-wp
.rcNormalPosition
.left
-
595 2*(GetSystemMetrics(SM_CXSIZEFRAME
)+GetSystemMetrics(SM_CXEDGE
));
596 prect
->bottom
= wp
.rcNormalPosition
.bottom
-wp
.rcNormalPosition
.top
-
597 2*(GetSystemMetrics(SM_CYSIZEFRAME
)+GetSystemMetrics(SM_CYEDGE
))-
598 GetSystemMetrics(SM_CYCAPTION
)-GetSystemMetrics(SM_CYMENUSIZE
);
601 if (IsWindowVisible(_htoolbar
)) {
602 ClientRect
rt(_htoolbar
);
603 prect
->top
+= rt
.bottom
+2;
606 if (IsWindowVisible(_hstatusbar
)) {
607 ClientRect
rt(_hstatusbar
);
608 prect
->bottom
-= rt
.bottom
;
612 BOOL
MainFrameBase::toggle_fullscreen()
616 if ((_fullscreen
._mode
=!_fullscreen
._mode
)) {
617 GetWindowRect(_hwnd
, &_fullscreen
._orgPos
);
618 _fullscreen
._wasZoomed
= IsZoomed(_hwnd
);
620 Frame_CalcFrameClient(_hwnd
, &rt
);
621 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.left
);
622 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.right
);
624 rt
.left
= _fullscreen
._orgPos
.left
-rt
.left
;
625 rt
.top
= _fullscreen
._orgPos
.top
-rt
.top
;
626 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+_fullscreen
._orgPos
.right
-rt
.right
;
627 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+_fullscreen
._orgPos
.bottom
-rt
.bottom
;
629 MoveWindow(_hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
631 MoveWindow(_hwnd
, _fullscreen
._orgPos
.left
, _fullscreen
._orgPos
.top
,
632 _fullscreen
._orgPos
.right
-_fullscreen
._orgPos
.left
,
633 _fullscreen
._orgPos
.bottom
-_fullscreen
._orgPos
.top
, TRUE
);
635 if (_fullscreen
._wasZoomed
)
636 ShowWindow(_hwnd
, WS_MAXIMIZE
);
639 return _fullscreen
._mode
;
642 void MainFrameBase::fullscreen_move()
645 GetWindowRect(_hwnd
, &pos
);
647 Frame_CalcFrameClient(_hwnd
, &rt
);
648 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.left
);
649 ClientToScreen(_hwnd
, (LPPOINT
)&rt
.right
);
651 rt
.left
= pos
.left
-rt
.left
;
652 rt
.top
= pos
.top
-rt
.top
;
653 rt
.right
= GetSystemMetrics(SM_CXSCREEN
)+pos
.right
-rt
.right
;
654 rt
.bottom
= GetSystemMetrics(SM_CYSCREEN
)+pos
.bottom
-rt
.bottom
;
656 MoveWindow(_hwnd
, rt
.left
, rt
.top
, rt
.right
-rt
.left
, rt
.bottom
-rt
.top
, TRUE
);
660 void MainFrameBase::toggle_child(HWND hwnd
, UINT cmd
, HWND hchild
, int band_idx
)
662 BOOL vis
= IsWindowVisible(hchild
);
664 CheckMenuItem(_menu_info
._hMenuView
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
667 SendMessage(_hwndrebar
, RB_SHOWBAND
, band_idx
, !vis
);
669 ShowWindow(hchild
, vis
? SW_HIDE
: SW_SHOW
);
671 if (_fullscreen
._mode
)
674 resize_frame_client();
677 void MainFrameBase::FillBookmarks()
679 HiddenWindow
hide(_hsidebar
);
680 WindowCanvas
canvas(_hwnd
);
682 TreeView_DeleteAllItems(_hsidebar
);
684 g_Globals
._icon_cache
.get_icon(ICID_FAVORITES
).add_to_imagelist(_himl
, canvas
);
685 g_Globals
._icon_cache
.get_icon(ICID_BOOKMARK
).add_to_imagelist(_himl
, canvas
);
686 ImageList_AddAlphaIcon(_himl
, SmallIcon(IDI_DOT
), GetStockBrush(WHITE_BRUSH
), canvas
);
687 g_Globals
._icon_cache
.get_icon(ICID_FOLDER
).add_to_imagelist(_himl
, canvas
);
688 g_Globals
._icon_cache
.get_icon(ICID_FOLDER
).add_to_imagelist(_himl
, canvas
);
692 tvi
.hParent
= TVI_ROOT
;
693 tvi
.hInsertAfter
= TVI_LAST
;
694 tvi
.item
.mask
= TVIF_TEXT
|TVIF_IMAGE
|TVIF_SELECTEDIMAGE
;
695 ResString
sFavorites(IDS_FAVORITES
);
696 tvi
.item
.pszText
= sFavorites
.str();
697 tvi
.item
.iSelectedImage
= tvi
.item
.iImage
= 0;
699 HTREEITEM hitem_bookmarks
= TreeView_InsertItem(_hsidebar
, &tvi
);
701 g_Globals
._favorites
.fill_tree(_hsidebar
, hitem_bookmarks
, _himl
, canvas
);
703 TreeView_Expand(_hsidebar
, hitem_bookmarks
, TVE_EXPAND
);
707 bool MainFrameBase::go_to(LPCTSTR url
, bool new_window
)
709 ///@todo SDI implementation
717 MDIMainFrame::MDIMainFrame(HWND hwnd
)
720 TBBUTTON mdiBtns
[] = {
721 {0, 0, 0, BTNS_SEP
, {0, 0}, 0, 0},
722 {0, ID_WINDOW_NEW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
723 {1, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
724 {2, ID_WINDOW_TILE_HORZ
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0},
725 {3, ID_WINDOW_TILE_VERT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0, 0}, 0, 0}
728 SendMessage(_htoolbar
, TB_ADDBUTTONS
, sizeof(mdiBtns
)/sizeof(TBBUTTON
), (LPARAM
)&mdiBtns
);
730 CLIENTCREATESTRUCT ccs
;
732 ccs
.hWindowMenu
= _hMenuWindow
;
733 ccs
.idFirstChild
= IDW_FIRST_CHILD
;
735 _hmdiclient
= CreateWindowEx(WS_EX_CLIENTEDGE
, TEXT("MDICLIENT"), NULL
,
736 WS_CHILD
|WS_CLIPCHILDREN
|WS_VSCROLL
|WS_HSCROLL
|WS_VISIBLE
|WS_BORDER
,
738 hwnd
, 0, g_Globals
._hInstance
, &ccs
);
740 TBBUTTON extraBtns
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
743 _hextrabar
= CreateToolbarEx(hwnd
,
744 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
745 WS_CHILD
|TBSTYLE_FLAT
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,
746 IDW_EXTRABAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, NULL
, 0,
747 16, 15, 16, 15, sizeof(TBBUTTON
));
749 _hextrabar
= CreateToolbarEx(hwnd
,
750 WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
,CCS_NODIVIDER
|
751 IDW_EXTRABAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, &extraBtns
, 1,
752 16, 13, 16, 13, sizeof(TBBUTTON
));
755 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_EXTRA_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
758 extraBtns
.fsStyle
= BTNS_BUTTON
;
761 // insert unix file system button
762 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("/\0"));
763 extraBtns
.idCommand
= ID_DRIVE_UNIX_FS
;
764 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
767 // insert explorer window button
768 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Explore\0"));
769 extraBtns
.idCommand
= ID_DRIVE_DESKTOP
;
770 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
772 // insert shell namespace button
773 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Shell\0"));
774 extraBtns
.idCommand
= ID_DRIVE_SHELL_NS
;
775 extraBtns
.iBitmap
= 6;
776 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
778 // insert web control button
779 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Web\0"));
780 extraBtns
.idCommand
= ID_WEB_WINDOW
;
781 extraBtns
.iBitmap
= 7;
782 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
784 if ((HIWORD(GetVersion())>>14) == W_VER_NT
) {
785 // insert NT object namespace button
786 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("NT Obj\0"));
787 extraBtns
.idCommand
= ID_DRIVE_NTOBJ_NS
;
788 extraBtns
.iBitmap
= 8;
789 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
791 #ifndef _ROS_ // don't insert reg button for ROS. Regedit should be used.
792 // insert Registry button
793 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("Reg.\0"));
794 extraBtns
.idCommand
= ID_DRIVE_REGISTRY
;
795 extraBtns
.iBitmap
= 9;
796 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
800 // insert FAT direct file system access button
801 extraBtns
.iString
= SendMessage(_hextrabar
, TB_ADDSTRING
, 0, (LPARAM
)TEXT("FAT\0"));
802 extraBtns
.idCommand
= ID_DRIVE_FAT
;
803 extraBtns
.iBitmap
= 10;
804 SendMessage(_hextrabar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&extraBtns
);
808 TBBUTTON drivebarBtn
= {0, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0, 0}, 0, 0};
813 _hdrivebar
= CreateToolbarEx(hwnd
,
814 CCS_NOPARENTALIGN
|CCS_NORESIZE
|CCS_NODIVIDER
|
815 WS_CHILD
|WS_VISIBLE
|TBSTYLE_FLAT
|CCS_NOMOVEY
|TBSTYLE_LIST
,
816 IDW_DRIVEBAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, NULL
, 0,
817 16, 15, 16, 15, sizeof(TBBUTTON
));
819 _hdrivebar
= CreateToolbarEx(hwnd
,
820 WS_CHILD
|WS_VISIBLE
|CCS_NOMOVEY
|TBSTYLE_LIST
|CCS_NODIVIDER
,
821 IDW_DRIVEBAR
, 2, g_Globals
._hInstance
, IDB_DRIVEBAR
, &drivebarBtn
, 1,
822 16, 13, 16, 13, sizeof(TBBUTTON
));
826 CheckMenuItem(_menu_info
._hMenuView
, ID_VIEW_DRIVE_BAR
, MF_BYCOMMAND
|MF_CHECKED
);
830 GetLogicalDriveStrings(BUFFER_LEN
, _drives
);
832 // register windows drive root strings
833 SendMessage(_hdrivebar
, TB_ADDSTRING
, 0, (LPARAM
)_drives
);
835 drivebarBtn
.fsStyle
= BTNS_BUTTON
;
836 drivebarBtn
.idCommand
= ID_DRIVE_FIRST
;
838 for(p
=_drives
; *p
; ) {
839 switch(GetDriveType(p
)) {
840 case DRIVE_REMOVABLE
: drivebarBtn
.iBitmap
= 1; break;
841 case DRIVE_CDROM
: drivebarBtn
.iBitmap
= 3; break;
842 case DRIVE_REMOTE
: drivebarBtn
.iBitmap
= 4; break;
843 case DRIVE_RAMDISK
: drivebarBtn
.iBitmap
= 5; break;
844 default:/*DRIVE_FIXED*/ drivebarBtn
.iBitmap
= 2;
847 SendMessage(_hdrivebar
, TB_INSERTBUTTON
, INT_MAX
, (LPARAM
)&drivebarBtn
);
848 ++drivebarBtn
.idCommand
;
849 ++drivebarBtn
.iString
;
857 int btn_hgt
= HIWORD(SendMessage(_htoolbar
, TB_GETBUTTONSIZE
, 0, 0));
859 REBARBANDINFO rbBand
;
861 rbBand
.cbSize
= sizeof(REBARBANDINFO
);
862 rbBand
.fMask
= RBBIM_TEXT
|RBBIM_STYLE
|RBBIM_CHILD
|RBBIM_CHILDSIZE
|RBBIM_SIZE
;
863 #ifndef RBBS_HIDETITLE // missing in MinGW headers as of 25.02.2004
864 #define RBBS_HIDETITLE 0x400
866 rbBand
.fStyle
= RBBS_CHILDEDGE
|RBBS_GRIPPERALWAYS
|RBBS_HIDETITLE
;
868 TCHAR ExtrasBand
[] = _T("Extras");
869 rbBand
.lpText
= ExtrasBand
;
870 rbBand
.hwndChild
= _hextrabar
;
871 rbBand
.cxMinChild
= 0;
872 rbBand
.cyMinChild
= btn_hgt
;
874 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)-1, (LPARAM
)&rbBand
);
877 rbBand
.fStyle
|= RBBS_BREAK
;
878 TCHAR DrivesBand
[] = _T("Drives");
879 rbBand
.lpText
= DrivesBand
;
880 rbBand
.hwndChild
= _hdrivebar
;
881 rbBand
.cxMinChild
= 0;
882 rbBand
.cyMinChild
= btn_hgt
;
884 SendMessage(_hwndrebar
, RB_INSERTBAND
, (WPARAM
)-1, (LPARAM
)&rbBand
);
890 HWND
MDIMainFrame::Create()
892 HMENU hMenuFrame
= LoadMenu(g_Globals
._hInstance
, MAKEINTRESOURCE(IDM_MDIFRAME
));
894 return Window::Create(WINDOW_CREATOR(MDIMainFrame
), 0,
895 (LPCTSTR
)(int)g_Globals
._hframeClass
, ResString(IDS_TITLE
), WS_OVERLAPPEDWINDOW
,
896 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
897 0/*hwndDesktop*/, hMenuFrame
);
900 HWND
MDIMainFrame::Create(LPCTSTR path
, int mode
)
902 HWND hFrame
= Create();
906 ShowWindow(hFrame
, SW_SHOW
);
908 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
911 pMainFrame
->CreateChild(path
, mode
);
916 HWND
MDIMainFrame::Create(LPCITEMIDLIST pidl
, int mode
)
918 HWND hFrame
= Create();
922 ShowWindow(hFrame
, SW_SHOW
);
924 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
927 pMainFrame
->CreateChild(pidl
, mode
);
933 ChildWindow
* MDIMainFrame::CreateChild(LPCTSTR path
, int mode
)
935 return reinterpret_cast<ChildWindow
*>(SendMessage(_hwnd
, PM_OPEN_WINDOW
, mode
, (LPARAM
)path
));
938 ChildWindow
* MDIMainFrame::CreateChild(LPCITEMIDLIST pidl
, int mode
)
940 return reinterpret_cast<ChildWindow
*>(SendMessage(_hwnd
, PM_OPEN_WINDOW
, mode
|OWM_PIDL
, (LPARAM
)pidl
));
944 BOOL
MDIMainFrame::TranslateMsg(MSG
* pmsg
)
946 if (_hmdiclient
&& TranslateMDISysAccel(_hmdiclient
, pmsg
))
949 return super::TranslateMsg(pmsg
);
952 LRESULT
MDIMainFrame::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
955 case PM_OPEN_WINDOW
: {
956 CONTEXT("MDIMainFrame PM_OPEN_WINDOW");
958 TCHAR buffer
[MAX_PATH
];
960 ShellPath shell_path
= DesktopFolderPath();
963 if (wparam
& OWM_PIDL
) {
964 // take over PIDL from lparam
965 shell_path
.assign((LPCITEMIDLIST
)lparam
); // create as "rooted" window
966 FileSysShellPath
fsp(shell_path
);
970 LOG(FmtString(TEXT("MDIMainFrame PM_OPEN_WINDOW: path=%s"), path
));
971 lstrcpy(buffer
, path
);
975 // take over path from lparam
976 path
= (LPCTSTR
)lparam
;
977 shell_path
= path
; // create as "rooted" window
980 ///@todo read paths and window placements from registry
981 if (!GetCurrentDirectory(MAX_PATH
, buffer
))
987 if (path
&& _tcsstr(path
, TEXT("://"))) { // "http://...", "ftp://", ...
988 OBJ_CONTEXT("create WebChild window", path
);
990 return (LRESULT
)GET_WINDOW(ChildWindow
, create_webchildwindow(WebChildWndInfo(_hmdiclient
, path
)));
992 OBJ_CONTEXT("create ShellChildWndInfo", path
);
994 // Shell Namespace as default view
995 ShellChildWndInfo
create_info(_hmdiclient
, path
, shell_path
);
997 if (wparam
& OWM_ROOTED
)
998 create_info
._root_shell_path
= shell_path
;
1000 create_info
._root_shell_path
= DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
1002 create_info
._pos
.showCmd
= wparam
&OWM_SEPARATE
? SW_SHOWNORMAL
: SW_SHOWMAXIMIZED
;
1003 create_info
._pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
1004 create_info
._pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
1005 create_info
._pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
1006 create_info
._pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
1008 create_info
._open_mode
= wparam
;
1010 // FileChildWindow::create(_hmdiclient, create_info);
1011 return (LRESULT
)MDIShellBrowserChild::create(create_info
);
1013 return TRUE
;} // success
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 case IDW_COMMANDBAR
:
1177 TCHAR url
[BUFFER_LEN
];
1180 if (GetWindowText(_haddressedit
, url
, BUFFER_LEN
))
1185 ExecuteCommandbar(dir
);
1189 ///@todo There are even more menu items!
1192 if (super::Command(id
, code
) == 0)
1195 return DefFrameProc(_hwnd
, _hmdiclient
, WM_COMMAND
, MAKELONG(id
,code
), 0);
1202 void MDIMainFrame::frame_get_clientspace(PRECT prect
)
1204 super::frame_get_clientspace(prect
);
1207 if (IsWindowVisible(_hdrivebar
)) {
1208 ClientRect
rt(_hdrivebar
);
1209 prect
->top
+= rt
.bottom
+2;
1214 void MDIMainFrame::resize_frame(int cx
, int cy
)
1217 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
1219 RECT rect
= {0, 0, cx
, cy
};
1222 int height
= SendMessage(_hwndrebar
, RB_GETBARHEIGHT
, 0, 0);
1226 if (IsWindowVisible(_htoolbar
)) {
1227 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
1228 WindowRect
rt(_htoolbar
);
1229 rect
.top
= rt
.bottom
;
1230 // rect.bottom -= rt.bottom;
1233 if (IsWindowVisible(_hextrabar
)) {
1234 SendMessage(_hextrabar
, WM_SIZE
, 0, 0);
1235 WindowRect
rt(_hextrabar
);
1236 int new_top
= --rect
.top
+ rt
.bottom
;
1237 MoveWindow(_hextrabar
, 0, rect
.top
, rt
.right
, new_top
, TRUE
);
1239 // rect.bottom -= rt.bottom;
1243 if (IsWindowVisible(_hdrivebar
)) {
1244 SendMessage(_hdrivebar
, WM_SIZE
, 0, 0);
1245 WindowRect
rt(_hdrivebar
);
1246 int new_top
= --rect
.top
+ rt
.bottom
;
1247 MoveWindow(_hdrivebar
, 0, rect
.top
, rt
.right
, new_top
, TRUE
);
1249 // rect.bottom -= rt.bottom;
1254 if (IsWindowVisible(_hstatusbar
)) {
1255 int parts
[] = {300, 500};
1257 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
1258 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1259 ClientRect
rt(_hstatusbar
);
1260 rect
.bottom
-= rt
.bottom
;
1263 if (IsWindowVisible(_haddressedit
) || IsWindowVisible(_hcommandedit
)) {
1264 ClientRect
rt(_haddressedit
);
1265 rect
.bottom
-= rt
.bottom
;
1267 int mid
= (rect
.right
-rect
.left
) / 2; ///@todo use split bar
1268 SetWindowPos(_haddressedit
, 0, 0, rect
.bottom
, mid
, rt
.bottom
, SWP_NOACTIVATE
|SWP_NOZORDER
);
1269 SetWindowPos(_hcommandedit
, 0, mid
+1, rect
.bottom
, rect
.right
-(mid
+1), rt
.bottom
, SWP_NOACTIVATE
|SWP_NOZORDER
);
1272 if (IsWindowVisible(_hsidebar
)) {
1273 WindowRect
rt(_hsidebar
);
1274 rect
.left
+= rt
.right
-rt
.left
;
1276 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
1279 MoveWindow(_hmdiclient
, rect
.left
-1, rect
.top
-1, rect
.right
-rect
.left
+1, rect
.bottom
-rect
.top
+1, TRUE
);
1282 bool MDIMainFrame::activate_drive_window(LPCTSTR path
)
1284 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
1287 _tsplitpath_s(path
, drv1
, COUNTOF(drv1
), NULL
, 0, NULL
, 0, NULL
, 0);
1289 // search for a already open window for the same drive
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 _tsplitpath_s(child
->get_root()._path
, drv2
, COUNTOF(drv2
), NULL
, 0, NULL
, 0, NULL
, 0);
1296 if (!lstrcmpi(drv2
, drv1
)) {
1297 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1299 if (IsMinimized(child_wnd
))
1300 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1310 bool MDIMainFrame::activate_child_window(LPCTSTR filesys
)
1314 // search for a already open window of the given file system name
1315 for(child_wnd
=GetNextWindow(_hmdiclient
,GW_CHILD
); child_wnd
; child_wnd
=GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
1316 FileChildWindow
* child
= (FileChildWindow
*) SendMessage(child_wnd
, PM_GET_FILEWND_PTR
, 0, 0);
1319 if (!lstrcmpi(child
->get_root()._fs
, filesys
)) {
1320 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1322 if (IsMinimized(child_wnd
))
1323 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1328 ShellBrowser
* shell_child
= (ShellBrowser
*) SendMessage(child_wnd
, PM_GET_SHELLBROWSER_PTR
, 0, 0);
1331 if (!lstrcmpi(shell_child
->get_root()._fs
, filesys
)) {
1332 SendMessage(_hmdiclient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
1334 if (IsMinimized(child_wnd
))
1335 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
1346 bool MDIMainFrame::go_to(LPCTSTR url
, bool new_window
)
1349 HWND hwndClient
= (HWND
) SendMessage(_hmdiclient
, WM_MDIGETACTIVE
, 0, 0);
1352 if (SendMessage(hwndClient
, PM_JUMP_TO_URL
, 0, (LPARAM
)url
))
1356 if (CreateChild(url
))
1359 return super::go_to(url
, new_window
);
1365 SDIMainFrame::SDIMainFrame(HWND hwnd
)
1368 _split_pos
= DEFAULT_SPLIT_POS
;
1369 _last_split
= DEFAULT_SPLIT_POS
;
1371 /* wait for PM_OPEN_WINDOW message before creating a shell view
1372 update_shell_browser();*/
1375 HWND
SDIMainFrame::Create()
1377 HMENU hMenuFrame
= LoadMenu(g_Globals
._hInstance
, MAKEINTRESOURCE(IDM_SDIFRAME
));
1379 return Window::Create(WINDOW_CREATOR(SDIMainFrame
), 0,
1380 (LPCTSTR
)(int)g_Globals
._hframeClass
, ResString(IDS_TITLE
), WS_OVERLAPPEDWINDOW
,
1381 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
1382 0/*hwndDesktop*/, hMenuFrame
);
1385 HWND
SDIMainFrame::Create(LPCITEMIDLIST pidl
, int mode
)
1387 HWND hFrame
= Create();
1391 ShowWindow(hFrame
, SW_SHOW
);
1393 SDIMainFrame
* pFrame
= GET_WINDOW(SDIMainFrame
, hFrame
);
1396 pFrame
->jump_to(pidl
, mode
);
1401 HWND
SDIMainFrame::Create(LPCTSTR path
, int mode
)
1403 HWND hFrame
= Create();
1407 ShowWindow(hFrame
, SW_SHOW
);
1409 MDIMainFrame
* pMainFrame
= GET_WINDOW(MDIMainFrame
, hFrame
);
1412 pMainFrame
->CreateChild(path
, mode
);
1417 LRESULT
SDIMainFrame::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1421 resize_frame(LOWORD(lparam
), HIWORD(lparam
));
1425 PaintCanvas
canvas(_hwnd
);
1428 ClientRect
rt(_hwnd
);
1429 rt
.left
= _split_pos
-SPLIT_WIDTH
/2;
1430 rt
.right
= _split_pos
+SPLIT_WIDTH
/2+1;
1433 WindowRect
right_rect(_right_hwnd
);
1434 ScreenToClient(_hwnd
, &right_rect
);
1435 rt
.top
= right_rect
.top
;
1436 rt
.bottom
= right_rect
.bottom
;
1439 HBRUSH lastBrush
= SelectBrush(canvas
, GetStockBrush(COLOR_SPLITBAR
));
1440 Rectangle(canvas
, rt
.left
, rt
.top
-1, rt
.right
, rt
.bottom
+1);
1441 SelectObject(canvas
, lastBrush
);
1447 if (LOWORD(lparam
) == HTCLIENT
) {
1450 ScreenToClient(_hwnd
, &pt
);
1452 if (pt
.x
>=_split_pos
-SPLIT_WIDTH
/2 && pt
.x
<_split_pos
+SPLIT_WIDTH
/2+1) {
1453 SetCursor(LoadCursor(0, IDC_SIZEWE
));
1459 case WM_LBUTTONDOWN
:
1461 int x
= GET_X_LPARAM(lparam
);
1463 ClientRect
rt(_hwnd
);
1465 if (x
>=_split_pos
-SPLIT_WIDTH
/2 && x
<_split_pos
+SPLIT_WIDTH
/2+1) {
1466 _last_split
= _split_pos
;
1473 if (GetCapture() == _hwnd
)
1478 if (wparam
== VK_ESCAPE
)
1479 if (GetCapture() == _hwnd
) {
1480 _split_pos
= _last_split
;
1484 SetCursor(LoadCursor(0, IDC_ARROW
));
1489 if (GetCapture() == _hwnd
) {
1490 int x
= GET_X_LPARAM(lparam
);
1492 ClientRect
rt(_hwnd
);
1494 if (x
>=0 && x
<rt
.right
) {
1497 rt
.left
= x
-SPLIT_WIDTH
/2;
1498 rt
.right
= x
+SPLIT_WIDTH
/2+1;
1499 InvalidateRect(_hwnd
, &rt
, FALSE
);
1500 UpdateWindow(_left_hwnd
);
1501 UpdateWindow(_hwnd
);
1502 UpdateWindow(_right_hwnd
);
1507 case PM_OPEN_WINDOW
: {
1508 CONTEXT("SDIMainFrame PM_OPEN_WINDOW");
1510 TCHAR buffer
[MAX_PATH
];
1512 ShellPath shell_path
= DesktopFolderPath();
1515 if (wparam
& OWM_PIDL
) {
1516 // take over PIDL from lparam
1517 shell_path
.assign((LPCITEMIDLIST
)lparam
); // create as "rooted" window
1518 FileSysShellPath
fsp(shell_path
);
1522 LOG(FmtString(TEXT("SDIMainFrame PM_OPEN_WINDOW: path=%s"), path
));
1523 lstrcpy(buffer
, path
);
1527 // take over path from lparam
1528 path
= (LPCTSTR
)lparam
;
1529 shell_path
= path
; // create as "rooted" window
1532 ///@todo read paths and window placements from registry
1533 if (!GetCurrentDirectory(MAX_PATH
, buffer
))
1540 if (wparam
& OWM_ROOTED
)
1541 _shellpath_info
._root_shell_path
= shell_path
;
1543 _shellpath_info
._root_shell_path
= DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
1545 jump_to(shell_path
, wparam
); ///@todo content of 'path' not used any more
1546 return TRUE
;} // success
1549 return super::WndProc(nmsg
, wparam
, lparam
);
1555 int SDIMainFrame::Command(int id
, int code
)
1559 MainFrameBase::Create(ExplorerCmd(_url
, true));
1562 case IDW_COMMANDBAR
:
1564 ExecuteCommandbar(_url
);
1568 return super::Command(id
, code
);
1574 void SDIMainFrame::resize_frame(int cx
, int cy
)
1577 return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
1579 RECT rect
= {0, 0, cx
, cy
};
1582 int height
= ClientRect(_hwndrebar
).bottom
;
1586 if (IsWindowVisible(_htoolbar
)) {
1587 SendMessage(_htoolbar
, WM_SIZE
, 0, 0);
1588 WindowRect
rt(_htoolbar
);
1589 rect
.top
= rt
.bottom
;
1590 // rect.bottom -= rt.bottom;
1594 if (IsWindowVisible(_hstatusbar
)) {
1595 int parts
[] = {300, 500};
1597 SendMessage(_hstatusbar
, WM_SIZE
, 0, 0);
1598 SendMessage(_hstatusbar
, SB_SETPARTS
, 2, (LPARAM
)&parts
);
1599 ClientRect
rt(_hstatusbar
);
1600 rect
.bottom
-= rt
.bottom
;
1603 if (IsWindowVisible(_haddressedit
) || IsWindowVisible(_hcommandedit
)) {
1604 ClientRect
rt(_haddressedit
);
1605 rect
.bottom
-= rt
.bottom
;
1607 int mid
= (rect
.right
-rect
.left
) / 2; ///@todo use split bar
1608 SetWindowPos(_haddressedit
, 0, 0, rect
.bottom
, mid
, rt
.bottom
, SWP_NOACTIVATE
|SWP_NOZORDER
);
1609 SetWindowPos(_hcommandedit
, 0, mid
+1, rect
.bottom
, rect
.right
-(mid
+1), rt
.bottom
, SWP_NOACTIVATE
|SWP_NOZORDER
);
1612 if (IsWindowVisible(_hsidebar
)) {
1613 WindowRect
rt(_hsidebar
);
1614 rect
.left
+= rt
.right
-rt
.left
;
1616 SetWindowPos(_hsidebar
, 0, -1, rect
.top
-1, rt
.right
-rt
.left
, rect
.bottom
-rect
.top
+1, SWP_NOACTIVATE
|SWP_NOZORDER
);
1624 void SDIMainFrame::resize_children()
1626 HDWP hdwp
= BeginDeferWindowPos(2);
1628 int cx
= _clnt_rect
.left
;
1631 cx
= _split_pos
+ SPLIT_WIDTH
/2;
1633 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
);
1640 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
);
1642 EndDeferWindowPos(hdwp
);
1645 void SDIMainFrame::update_clnt_rect()
1647 ClientRect
rect(_hwnd
);
1649 resize_frame(rect
.right
, rect
.bottom
);
1652 void SDIMainFrame::update_shell_browser()
1654 int split_pos
= DEFAULT_SPLIT_POS
;
1656 if (_shellBrowser
.get()) {
1657 split_pos
= _split_pos
;
1658 delete _shellBrowser
.release();
1661 // create explorer treeview
1662 if (_shellpath_info
._open_mode
& OWM_EXPLORE
) {
1664 ClientRect
rect(_hwnd
);
1666 _left_hwnd
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, NULL
,
1667 WS_CHILD
|WS_TABSTOP
|WS_VISIBLE
|TVS_HASLINES
|TVS_LINESATROOT
|TVS_HASBUTTONS
|TVS_NOTOOLTIPS
|TVS_SHOWSELALWAYS
,
1668 0, rect
.top
, split_pos
-SPLIT_WIDTH
/2, rect
.bottom
-rect
.top
,
1669 _hwnd
, (HMENU
)IDC_FILETREE
, g_Globals
._hInstance
, 0);
1671 // display tree window as long as the shell view is not yet visible
1672 resize_frame(rect
.right
, rect
.bottom
);
1673 MoveWindow(_left_hwnd
, rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
1677 DestroyWindow(_left_hwnd
);
1682 _shellBrowser
= auto_ptr
<ShellBrowser
>(new ShellBrowser(_hwnd
, _hwnd
, _left_hwnd
, _right_hwnd
,
1683 _shellpath_info
, this, _cm_ifs
));
1686 _shellBrowser
->Init();
1688 // update _clnt_rect and set size of new created shell view windows
1692 void SDIMainFrame::entry_selected(Entry
* entry
)
1695 _shellBrowser
->select_folder(entry
, false);
1697 _shellBrowser
->UpdateFolderView(entry
->get_shell_folder());
1699 // set size of new created shell view windows
1702 TCHAR path
[MAX_PATH
];
1704 if (entry
->get_path(path
, COUNTOF(path
))) {
1708 url
.printf(TEXT("shell://%s"), path
);
1710 url
.printf(TEXT("file://%s"), path
);
1716 void SDIMainFrame::set_url(LPCTSTR url
)
1721 SetWindowText(_haddressedit
, url
); //SendMessage(_hwndFrame, PM_URL_CHANGED, 0, (LPARAM)url);
1725 void SDIMainFrame::jump_to(LPCTSTR path
, int mode
)
1727 if (_shellBrowser.get() && (_shellpath_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) {
1728 _shellBrowser->jump_to(path);
1730 _shellpath_info._shell_path = path;
1732 _shellpath_info
._open_mode
= mode
;
1733 _shellpath_info
._shell_path
= path
;
1735 update_shell_browser();
1739 void SDIMainFrame::jump_to(LPCITEMIDLIST path
, int mode
)
1741 if (_shellBrowser
.get() && (_shellpath_info
._open_mode
&~OWM_PIDL
)==(mode
&~OWM_PIDL
)) {
1742 ShellPath shell_path
= path
;
1744 _shellBrowser
->jump_to(shell_path
);
1746 _shellpath_info
._shell_path
= shell_path
;
1748 _shellpath_info
._open_mode
= mode
;
1749 _shellpath_info
._shell_path
= path
;
1751 update_shell_browser();