mainframe.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2003, 2004, 2005 Martin Fuchs
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 
00020  //
00021  // Explorer clone
00022  //
00023  // mainframe.cpp
00024  //
00025  // Martin Fuchs, 23.07.2003
00026  //
00027 
00028 
00029 #include <precomp.h>
00030 
00031 /* We can't include webchild.h here - otherwise MinGW produces errors like: "multiple definition of `QACONTAINERFLAGS'"
00032 #include "webchild.h"
00033 */
00034 extern HWND create_webchildwindow(const WebChildWndInfo& info);
00035 
00036 #include "../resource.h"
00037 
00038 #include "../dialogs/settings.h"    // for MdiSdiDlg
00039 
00040 //#define _NO_REBAR
00041 
00042 HWND MainFrameBase::Create(const ExplorerCmd& cmd)
00043 {
00044     HWND hFrame;
00045 
00046 #ifndef _NO_MDI
00047     if (cmd._mdi)
00048         hFrame = MDIMainFrame::Create();
00049     else
00050 #endif
00051         hFrame = SDIMainFrame::Create();
00052 
00053     if (hFrame) {
00054         HWND hwndOld = g_Globals._hMainWnd;
00055 
00056         g_Globals._hMainWnd = hFrame;
00057 
00058         if (hwndOld)
00059             DestroyWindow(hwndOld);
00060 
00061         ShowWindow(hFrame, cmd._cmdShow);
00062         UpdateWindow(hFrame);
00063 
00064          // Open the first child window after initializing the application
00065         if (cmd.IsValidPath()) {
00066              // We use the static s_path variable to store the path string in order
00067              // to avoid accessing prematurely freed memory in the PostMessage handlers.
00068             static String s_path = cmd._path;
00069 
00070             PostMessage(hFrame, PM_OPEN_WINDOW, cmd._flags, (LPARAM)(LPCTSTR)s_path);
00071         } else
00072             PostMessage(hFrame, PM_OPEN_WINDOW, OWM_EXPLORE|OWM_DETAILS, 0);
00073     }
00074 
00075     return hFrame;
00076 }
00077 
00078 
00079 int MainFrameBase::OpenShellFolders(LPIDA pida, HWND hFrameWnd)
00080 {
00081     int cnt = 0;
00082 
00083     LPCITEMIDLIST parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]);
00084     ShellFolder folder(parent_pidl);
00085     LOG(FmtString(TEXT("MainFrameBase::OpenShellFolders(): parent_pidl=%s"), (LPCTSTR)FileSysShellPath(parent_pidl)));
00086 
00087     for(int i=pida->cidl; i>0; --i) {
00088         LPCITEMIDLIST pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[i]);
00089 
00090         SFGAOF attribs = SFGAO_FOLDER;
00091         HRESULT hr = folder->GetAttributesOf(1, &pidl, &attribs);
00092 
00093         if (SUCCEEDED(hr))
00094             if (attribs & SFGAO_FOLDER) {
00095                 try {
00096                     XMLPos explorer_options = g_Globals.get_cfg("general/explorer");
00097 
00098                     bool mdi = XMLBool(explorer_options, "mdi", true);
00099                     bool separateFolders = XMLBool(explorer_options, "separate-folders", true);
00100 
00101                     ShellPath pidl_abs = ShellPath(pidl).create_absolute_pidl(parent_pidl);
00102                     LOG(FmtString(TEXT("MainFrameBase::OpenShellFolders(): pidl_abs=%s"), (LPCTSTR)FileSysShellPath(pidl_abs)));
00103 
00104                     if (hFrameWnd && (mdi || !separateFolders)) {
00105                         int flags = OWM_PIDL;
00106 
00107                         if (separateFolders)
00108                             flags |= OWM_SEPARATE;
00109 
00110                         if (SendMessage(hFrameWnd, PM_OPEN_WINDOW, flags, (LPARAM)(LPCITEMIDLIST)pidl_abs))
00111                             ++cnt;
00112                     } else {
00113                         HWND hwnd;
00114 #ifndef _NO_MDI
00115                         if (mdi)
00116                             hwnd = MDIMainFrame::Create(pidl_abs, 0);
00117                         else
00118 #endif
00119                             hwnd = SDIMainFrame::Create(pidl_abs, 0);
00120 
00121                         if (hwnd)
00122                             ++cnt;
00123                     }
00124                 } catch(COMException& e) {
00125                     HandleException(e, g_Globals._hMainWnd);
00126                 }
00127             }/*TEST
00128             else { // !(attribs & SFGAO_FOLDER))
00129                 SHELLEXECUTEINFOA shexinfo;
00130 
00131                 shexinfo.cbSize = sizeof(SHELLEXECUTEINFOA);
00132                 shexinfo.fMask = SEE_MASK_INVOKEIDLIST;
00133                 shexinfo.hwnd = NULL;
00134                 shexinfo.lpVerb = NULL;
00135                 shexinfo.lpFile = NULL;
00136                 shexinfo.lpParameters = NULL;
00137                 shexinfo.lpDirectory = NULL;
00138                 shexinfo.nShow = SW_NORMAL;
00139                 shexinfo.lpIDList = ILCombine(parent_pidl, pidl);
00140 
00141                 if (ShellExecuteExA(&shexinfo))
00142                     ++cnt;
00143 
00144                 ILFree((LPITEMIDLIST)shexinfo.lpIDList);
00145             }*/
00146     }
00147 
00148     return cnt;
00149 }
00150 
00151 
00152 MainFrameBase::MainFrameBase(HWND hwnd)
00153  :  super(hwnd)
00154 {
00155     _himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK|ILC_COLOR24, 2, 0);
00156 
00157     _hMenuFrame = GetMenu(hwnd);
00158     _hMenuWindow = GetSubMenu(_hMenuFrame, GetMenuItemCount(_hMenuFrame)-3);
00159 
00160     _menu_info._hMenuView = GetSubMenu(_hMenuFrame, 1);
00161 
00162     _hAccel = LoadAccelerators(g_Globals._hInstance, MAKEINTRESOURCE(IDA_EXPLORER));
00163 
00164 
00165     TBBUTTON toolbarBtns[] = {
00166 #ifdef _NO_REBAR
00167         {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
00168 #endif
00169         {7, ID_GO_BACK, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
00170         {8, ID_GO_FORWARD, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
00171         {9, ID_GO_UP, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
00172         {10, ID_GO_HOME, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
00173         {11, ID_GO_SEARCH, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
00174         {12, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
00175         {13, ID_STOP, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}
00176     };
00177 
00178     _htoolbar = CreateToolbarEx(hwnd,
00179 #ifndef _NO_REBAR
00180         CCS_NOPARENTALIGN|CCS_NORESIZE|CCS_NODIVIDER|
00181 #endif
00182         WS_CHILD|TBSTYLE_FLAT|WS_VISIBLE, IDW_TOOLBAR, 2, g_Globals._hInstance, IDB_TOOLBAR,
00183         toolbarBtns, sizeof(toolbarBtns)/sizeof(TBBUTTON),
00184         16, 15, 16, 15, sizeof(TBBUTTON));
00185 
00186     CheckMenuItem(_menu_info._hMenuView, ID_VIEW_TOOL_BAR, MF_BYCOMMAND|MF_CHECKED);
00187 
00188 
00189      // address & command bar
00190     WindowCanvas canvas(hwnd);
00191     RECT rect = {0, 0, 0, 0};
00192     DrawText(canvas, TEXT("My"), -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT);
00193     HFONT hfont = GetStockFont(DEFAULT_GUI_FONT);
00194 
00195     _haddressedit = CreateWindow(TEXT("EDIT"), NULL, WS_CHILD|WS_VISIBLE, 0, 0, 0, rect.bottom,
00196                             hwnd, (HMENU)IDW_ADDRESSBAR, g_Globals._hInstance, 0);
00197     SetWindowFont(_haddressedit, hfont, FALSE);
00198     new EditController(_haddressedit);
00199 
00200     _hcommandedit = CreateWindow(TEXT("EDIT"), TEXT("> "), WS_CHILD|WS_VISIBLE, 0, 0, 0, rect.bottom,
00201                             hwnd, (HMENU)IDW_COMMANDBAR, g_Globals._hInstance, 0);
00202     SetWindowFont(_hcommandedit, hfont, FALSE);
00203     new EditController(_hcommandedit);
00204 
00205     /* CreateStatusWindow does not accept WS_BORDER
00206         _hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0,
00207                         WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0,
00208                         hwnd, (HMENU)IDW_STATUSBAR, g_Globals._hInstance, 0);*/
00209 
00210     _hstatusbar = CreateStatusWindow(WS_CHILD|WS_VISIBLE, 0, hwnd, IDW_STATUSBAR);
00211     CheckMenuItem(_menu_info._hMenuView, ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
00212 
00213     _hsidebar = CreateWindowEx(WS_EX_STATICEDGE, WC_TREEVIEW, TEXT("Sidebar"),
00214                     WS_CHILD|WS_TABSTOP|WS_BORDER|/*WS_VISIBLE|*/WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_SHOWSELALWAYS|TVS_INFOTIP,
00215                     -1, -1, 200, 0, _hwnd, (HMENU)IDW_SIDEBAR, g_Globals._hInstance, 0);
00216 
00217     _himl_old = TreeView_SetImageList(_hsidebar, _himl, TVSIL_NORMAL);
00218 
00219     CheckMenuItem(_menu_info._hMenuView, ID_VIEW_SIDE_BAR, MF_BYCOMMAND|MF_UNCHECKED/*MF_CHECKED*/);
00220 
00221 
00222      // create rebar window to manage toolbar and drivebar
00223 #ifndef _NO_REBAR
00224     _hwndrebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL,
00225                     WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|
00226                     RBS_VARHEIGHT|RBS_DBLCLKTOGGLE|
00227                     WS_BORDER|RBS_AUTOSIZE|RBS_BANDBORDERS,
00228                     0, 0, 0, 0, _hwnd, 0, g_Globals._hInstance, 0);
00229 
00230     int btn_hgt = HIWORD(SendMessage(_htoolbar, TB_GETBUTTONSIZE, 0, 0));
00231 
00232     REBARBANDINFO rbBand;
00233 
00234     rbBand.cbSize = sizeof(REBARBANDINFO);
00235     rbBand.fMask  = RBBIM_TEXT|RBBIM_STYLE|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_SIZE;
00236 #ifndef RBBS_HIDETITLE // missing in MinGW headers as of 25.02.2004
00237 #define RBBS_HIDETITLE  0x400
00238 #endif
00239     rbBand.fStyle = RBBS_CHILDEDGE|RBBS_GRIPPERALWAYS|RBBS_HIDETITLE;
00240 
00241     rbBand.cxMinChild = 0;
00242     rbBand.cyMinChild = 0;
00243     rbBand.cyChild = 0;
00244     rbBand.cyMaxChild = 0;
00245     rbBand.cyIntegral = btn_hgt;
00246 
00247     rbBand.lpText = NULL;//TEXT("Toolbar");
00248     rbBand.hwndChild = _htoolbar;
00249     rbBand.cxMinChild = 0;
00250     rbBand.cyMinChild = btn_hgt;
00251     rbBand.cx = 284;
00252     SendMessage(_hwndrebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);
00253 #endif
00254 }
00255 
00256 
00257 MainFrameBase::~MainFrameBase()
00258 {
00259     (void)TreeView_SetImageList(_hsidebar, _himl_old, TVSIL_NORMAL);
00260     ImageList_Destroy(_himl);
00261 
00262      // don't exit desktop when closing file manager window
00263     if (!g_Globals._desktop_mode)
00264         if (g_Globals._hMainWnd == _hwnd)   // don't quit when switching between MDI and SDI mode
00265             PostQuitMessage(0);
00266 }
00267 
00268 
00269 LRESULT MainFrameBase::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
00270 {
00271     LRESULT res;
00272 
00273     if (ProcessMessage(nmsg, wparam, lparam, &res))
00274         return res;
00275     else
00276         return super::WndProc(nmsg, wparam, lparam);
00277 }
00278 
00279 bool MainFrameBase::ProcessMessage(UINT nmsg, WPARAM wparam, LPARAM lparam, LRESULT* pres)
00280 {
00281     switch(nmsg) {
00282       case PM_TRANSLATE_MSG:
00283         *pres = TranslateMsg((MSG*)lparam);
00284         return true;
00285 
00286       case WM_SHOWWINDOW:
00287         if (wparam) {   // trigger child resizing after window creation - now we can succesfully call IsWindowVisible()
00288             int height = SendMessage(_hwndrebar, RB_GETBARHEIGHT, 0, 0);
00289             MoveWindow(_hwndrebar, 0, 0, LOWORD(lparam), height, TRUE);
00290             resize_frame_client();
00291         }
00292         return false; // goto def;
00293 
00294       case WM_CLOSE:
00295         DestroyWindow(_hwnd);
00296         g_Globals._hMainWnd = 0;
00297         break;
00298 
00299       case WM_DESTROY:
00300         break;
00301 
00302       case WM_SIZE: {
00303 #ifdef __REACTOS__  ///@todo Work around to display rebar in ROS (with flickering) as long as the control isn't fixed
00304         int height = SendMessage(_hwndrebar, RB_GETBARHEIGHT, 0, 0);
00305         MoveWindow(_hwndrebar, 0, 0, LOWORD(lparam), height, TRUE);
00306 #else
00307         resize_frame(LOWORD(lparam), HIWORD(lparam));
00308         SendMessage(_hwndrebar, WM_SIZE, 0, 0);
00309 #endif
00310         break;} // do not pass message to DefFrameProc
00311 
00312       case WM_GETMINMAXINFO: {
00313         LPMINMAXINFO lpmmi = (LPMINMAXINFO)lparam;
00314 
00315         lpmmi->ptMaxTrackSize.x <<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
00316         lpmmi->ptMaxTrackSize.y <<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
00317         break;}
00318 
00319       case PM_FRM_CALC_CLIENT:
00320         frame_get_clientspace((PRECT)lparam);
00321         *pres = TRUE;
00322         return true;
00323 
00324       case PM_FRM_GET_MENUINFO:
00325         *pres = (LPARAM)&_menu_info;
00326         return true;
00327 
00328       case PM_GET_CONTROLWINDOW:
00329         if (wparam == FCW_STATUS) {
00330             *pres = (LRESULT)(HWND)_hstatusbar;
00331             return true;
00332         }
00333         break;
00334 
00335       case PM_SETSTATUSTEXT:
00336         SendMessage(_hstatusbar, SB_SETTEXT, 0, lparam);
00337         break;
00338 
00339       case PM_URL_CHANGED:
00340         SetWindowText(_haddressedit, (LPCTSTR)lparam);
00341         break;
00342 
00343       default:
00344         return false;
00345     }
00346 
00347     *pres = 0;
00348     return true;
00349 }
00350 
00351 BOOL MainFrameBase::TranslateMsg(MSG* pmsg)
00352 {
00353     if (TranslateAccelerator(_hwnd, _hAccel, pmsg))
00354         return TRUE;
00355 
00356     return FALSE;
00357 }
00358 
00359 
00360 int MainFrameBase::Command(int id, int code)
00361 {
00362     CONTEXT("MainFrameBase::Command()");
00363 
00364     switch(id) {
00365       case ID_FILE_EXIT:
00366         SendMessage(_hwnd, WM_CLOSE, 0, 0);
00367         break;
00368 
00369       case ID_VIEW_TOOL_BAR:
00370         toggle_child(_hwnd, id, _htoolbar, 0);
00371         break;
00372 
00373       case ID_VIEW_STATUSBAR:
00374         toggle_child(_hwnd, id, _hstatusbar);
00375         break;
00376 
00377       case ID_VIEW_SIDE_BAR:
00378          // lazy initialization
00379         if (!TreeView_GetCount(_hsidebar))
00380             FillBookmarks();
00381 
00382         toggle_child(_hwnd, id, _hsidebar);
00383         break;
00384 
00385       case ID_EXECUTE: {
00386         ExecuteDialog dlg = {{0}, 0};
00387 
00388         if (DialogBoxParam(g_Globals._hInstance, MAKEINTRESOURCE(IDD_EXECUTE), _hwnd, ExecuteDialog::WndProc, (LPARAM)&dlg) == IDOK) {
00389             CONTEXT("ID_EXECUTE - ShellExecute()");
00390 
00391             HINSTANCE hinst = ShellExecute(_hwnd, NULL/*operation*/, dlg.cmd/*file*/, NULL/*parameters*/, NULL/*dir*/, dlg.cmdshow);
00392 
00393             if ((int)hinst <= 32)
00394                 display_error(_hwnd, GetLastError());
00395         }
00396         break;}
00397 
00398       case ID_HELP:
00399         WinHelp(_hwnd, TEXT("explorer")/*file explorer.hlp*/, HELP_INDEX, 0);
00400         break;
00401 
00402       case ID_VIEW_FULLSCREEN:
00403         CheckMenuItem(_menu_info._hMenuView, id, toggle_fullscreen()?MF_CHECKED:0);
00404         break;
00405 
00406       case ID_TOOLS_OPTIONS:
00407         Dialog::DoModal(IDD_MDI_SDI, WINDOW_CREATOR(MdiSdiDlg), _hwnd);
00408         break;
00409 
00410       case ID_ABOUT_WINDOWS:
00411         ShellAbout(_hwnd, ResString(IDS_TITLE), NULL, 0);
00412         break;
00413 
00414       case ID_ABOUT_EXPLORER:
00415         explorer_about(_hwnd);
00416         break;
00417 
00418       case ID_EXPLORER_FAQ:
00419         launch_file(_hwnd, TEXT("http://www.foxplanet.de/explorer/"), SW_SHOW);
00420         break;
00421 
00422       case IDW_ADDRESSBAR:
00423         if (code == 1) {
00424             TCHAR url[BUFFER_LEN];
00425 
00426             if (GetWindowText(_haddressedit, url, BUFFER_LEN))
00427                 go_to(url, false);
00428         }
00429         break;
00430 
00431       case IDW_COMMANDBAR:
00432         if (code == 1)
00433             ExecuteCommandbar(NULL);
00434         break;
00435 
00436       default:
00437         return 1;   // no command handlers in Window::Command()
00438     }
00439 
00440     return 0;
00441 }
00442 
00443 
00444 void MainFrameBase::ExecuteCommandbar(LPCTSTR dir)
00445 {
00446     TCHAR cmd[BUFFER_LEN];
00447 
00448     if (GetWindowText(_hcommandedit, cmd, BUFFER_LEN)) {
00449         CONTEXT("ExecuteCommandbar - ShellExecute()");
00450 
00451          // remove command prompt from 'cmd' string
00452         LPCTSTR p = cmd;
00453 
00454         if (*p == '>')
00455             ++p;
00456 
00457         while(*p == ' ')
00458             ++p;
00459 
00460         if (dir) {
00461              // remove "file://" from directory URL
00462             if (!_tcsnicmp(dir, TEXT("file://"), 7))
00463                 dir += 7;
00464         }
00465 
00466         ///@todo use SHGetFileInfo() with SHGFI_EXETYPE flag to determine EXE type and open console window
00467 
00468         HINSTANCE hinst = ShellExecute(_hwnd, NULL, p, NULL, dir, SW_SHOWNORMAL);
00469 
00470         if ((int)hinst <= 32)
00471             display_error(_hwnd, GetLastError());
00472     }
00473 }
00474 
00475 
00476 int MainFrameBase::Notify(int id, NMHDR* pnmh)
00477 {
00478     switch(pnmh->code) {
00479          // resize children windows when the rebar size changes
00480 
00481       case RBN_AUTOSIZE:
00482         resize_frame_client();
00483         break;
00484 
00485       case TVN_GETINFOTIP: {
00486         NMTVGETINFOTIP* pnmgit = (NMTVGETINFOTIP*)pnmh;
00487 
00488         if (pnmgit->lParam) {
00489             const BookmarkNode& node = *(BookmarkNode*)pnmgit->lParam;
00490 
00491             if (node._type == BookmarkNode::BMNT_FOLDER) {
00492                  // display tooltips for bookmark folders
00493                 if (!node._pfolder->_description.empty())
00494                     lstrcpyn(pnmgit->pszText, node._pfolder->_description.c_str(), pnmgit->cchTextMax);
00495             } else if (node._type == BookmarkNode::BMNT_BOOKMARK) {
00496                  // display tooltips for bookmark folders
00497                 String txt = node._pbookmark->_description;
00498 
00499                 if (!node._pbookmark->_url.empty()) {
00500                     if (!txt.empty())
00501                         txt += TEXT("  -  ");
00502 
00503                     txt += node._pbookmark->_url;
00504                 }
00505 
00506                 lstrcpyn(pnmgit->pszText, txt.c_str(), pnmgit->cchTextMax);
00507             }
00508         }
00509         break;}
00510 
00511       case NM_DBLCLK: {
00512         HTREEITEM hitem = TreeView_GetSelection(_hsidebar);
00513         LPARAM lparam = TreeView_GetItemData(_hsidebar, hitem);
00514 
00515         if (lparam) {
00516             const BookmarkNode& node = *(BookmarkNode*)lparam;
00517 
00518             if (node._type == BookmarkNode::BMNT_BOOKMARK) {
00519                 bool new_window = GetAsyncKeyState(VK_SHIFT)<0;
00520 
00521                 go_to(node._pbookmark->_url, new_window);
00522             }
00523         }
00524         break;}
00525     }
00526 
00527     return 0;
00528 }
00529 
00530 
00531 void MainFrameBase::resize_frame(int cx, int cy)
00532 {
00533     if (cy <= 0)
00534         return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
00535 
00536     RECT rect = {0, 0, cx, cy};
00537 
00538     if (_hwndrebar) {
00539         int height = SendMessage(_hwndrebar, RB_GETBARHEIGHT, 0, 0);
00540         rect.top += height;
00541         rect.top += 5;
00542     } else {
00543         if (IsWindowVisible(_htoolbar)) {
00544             SendMessage(_htoolbar, WM_SIZE, 0, 0);
00545             WindowRect rt(_htoolbar);
00546             rect.top = rt.bottom;
00547         //  rect.bottom -= rt.bottom;
00548         }
00549     }
00550 
00551     if (IsWindowVisible(_hstatusbar)) {
00552         int parts[] = {300, 500};
00553 
00554         SendMessage(_hstatusbar, WM_SIZE, 0, 0);
00555         SendMessage(_hstatusbar, SB_SETPARTS, 2, (LPARAM)&parts);
00556         ClientRect rt(_hstatusbar);
00557         rect.bottom -= rt.bottom;
00558     }
00559 
00560     if (IsWindowVisible(_haddressedit) || IsWindowVisible(_hcommandedit)) {
00561         ClientRect rt(_haddressedit);
00562         rect.bottom -= rt.bottom;
00563 
00564         int mid = (rect.right-rect.left) / 2;   ///@todo use split bar
00565         SetWindowPos(_haddressedit, 0, 0, rect.bottom, mid, rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
00566         SetWindowPos(_hcommandedit, 0, mid+1, rect.bottom, rect.right-(mid+1), rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
00567     }
00568 
00569     if (IsWindowVisible(_hsidebar)) {
00570         WindowRect rt(_hsidebar);
00571         rect.left += rt.right-rt.left;
00572 
00573         SetWindowPos(_hsidebar, 0, -1, rect.top-1, rt.right-rt.left, rect.bottom-rect.top+1, SWP_NOACTIVATE|SWP_NOZORDER);
00574     }
00575 }
00576 
00577 void MainFrameBase::resize_frame_client()
00578 {
00579     ClientRect rect(_hwnd);
00580 
00581     resize_frame(rect.right, rect.bottom);
00582 }
00583 
00584 void MainFrameBase::frame_get_clientspace(PRECT prect)
00585 {
00586     if (!IsIconic(_hwnd))
00587         GetClientRect(_hwnd, prect);
00588     else {
00589         WINDOWPLACEMENT wp;
00590 
00591         GetWindowPlacement(_hwnd, &wp);
00592 
00593         prect->left = prect->top = 0;
00594         prect->right = wp.rcNormalPosition.right-wp.rcNormalPosition.left-
00595                         2*(GetSystemMetrics(SM_CXSIZEFRAME)+GetSystemMetrics(SM_CXEDGE));
00596         prect->bottom = wp.rcNormalPosition.bottom-wp.rcNormalPosition.top-
00597                         2*(GetSystemMetrics(SM_CYSIZEFRAME)+GetSystemMetrics(SM_CYEDGE))-
00598                         GetSystemMetrics(SM_CYCAPTION)-GetSystemMetrics(SM_CYMENUSIZE);
00599     }
00600 
00601     if (IsWindowVisible(_htoolbar)) {
00602         ClientRect rt(_htoolbar);
00603         prect->top += rt.bottom+2;
00604     }
00605 
00606     if (IsWindowVisible(_hstatusbar)) {
00607         ClientRect rt(_hstatusbar);
00608         prect->bottom -= rt.bottom;
00609     }
00610 }
00611 
00612 BOOL MainFrameBase::toggle_fullscreen()
00613 {
00614     RECT rt;
00615 
00616     if ((_fullscreen._mode=!_fullscreen._mode)) {
00617         GetWindowRect(_hwnd, &_fullscreen._orgPos);
00618         _fullscreen._wasZoomed = IsZoomed(_hwnd);
00619 
00620         Frame_CalcFrameClient(_hwnd, &rt);
00621         ClientToScreen(_hwnd, (LPPOINT)&rt.left);
00622         ClientToScreen(_hwnd, (LPPOINT)&rt.right);
00623 
00624         rt.left = _fullscreen._orgPos.left-rt.left;
00625         rt.top = _fullscreen._orgPos.top-rt.top;
00626         rt.right = GetSystemMetrics(SM_CXSCREEN)+_fullscreen._orgPos.right-rt.right;
00627         rt.bottom = GetSystemMetrics(SM_CYSCREEN)+_fullscreen._orgPos.bottom-rt.bottom;
00628 
00629         MoveWindow(_hwnd, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top, TRUE);
00630     } else {
00631         MoveWindow(_hwnd, _fullscreen._orgPos.left, _fullscreen._orgPos.top,
00632                             _fullscreen._orgPos.right-_fullscreen._orgPos.left,
00633                             _fullscreen._orgPos.bottom-_fullscreen._orgPos.top, TRUE);
00634 
00635         if (_fullscreen._wasZoomed)
00636             ShowWindow(_hwnd, WS_MAXIMIZE);
00637     }
00638 
00639     return _fullscreen._mode;
00640 }
00641 
00642 void MainFrameBase::fullscreen_move()
00643 {
00644     RECT rt, pos;
00645     GetWindowRect(_hwnd, &pos);
00646 
00647     Frame_CalcFrameClient(_hwnd, &rt);
00648     ClientToScreen(_hwnd, (LPPOINT)&rt.left);
00649     ClientToScreen(_hwnd, (LPPOINT)&rt.right);
00650 
00651     rt.left = pos.left-rt.left;
00652     rt.top = pos.top-rt.top;
00653     rt.right = GetSystemMetrics(SM_CXSCREEN)+pos.right-rt.right;
00654     rt.bottom = GetSystemMetrics(SM_CYSCREEN)+pos.bottom-rt.bottom;
00655 
00656     MoveWindow(_hwnd, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top, TRUE);
00657 }
00658 
00659 
00660 void MainFrameBase::toggle_child(HWND hwnd, UINT cmd, HWND hchild, int band_idx)
00661 {
00662     BOOL vis = IsWindowVisible(hchild);
00663 
00664     CheckMenuItem(_menu_info._hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED);
00665 
00666     if (band_idx != -1)
00667         SendMessage(_hwndrebar, RB_SHOWBAND, band_idx, !vis);
00668     else
00669         ShowWindow(hchild, vis? SW_HIDE: SW_SHOW);
00670 
00671     if (_fullscreen._mode)
00672         fullscreen_move();
00673 
00674     resize_frame_client();
00675 }
00676 
00677 void MainFrameBase::FillBookmarks()
00678 {
00679     HiddenWindow hide(_hsidebar);
00680     WindowCanvas canvas(_hwnd);
00681 
00682     TreeView_DeleteAllItems(_hsidebar);
00683 
00684     g_Globals._icon_cache.get_icon(ICID_FAVORITES).add_to_imagelist(_himl, canvas);
00685     g_Globals._icon_cache.get_icon(ICID_BOOKMARK).add_to_imagelist(_himl, canvas);
00686     ImageList_AddAlphaIcon(_himl, SmallIcon(IDI_DOT), GetStockBrush(WHITE_BRUSH), canvas);
00687     g_Globals._icon_cache.get_icon(ICID_FOLDER).add_to_imagelist(_himl, canvas);
00688     g_Globals._icon_cache.get_icon(ICID_FOLDER).add_to_imagelist(_himl, canvas);
00689 
00690     TV_INSERTSTRUCT tvi;
00691 
00692     tvi.hParent = TVI_ROOT;
00693     tvi.hInsertAfter = TVI_LAST;
00694     tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
00695     ResString sFavorites(IDS_FAVORITES);
00696     tvi.item.pszText = sFavorites.str();
00697     tvi.item.iSelectedImage = tvi.item.iImage = 0;
00698 
00699     HTREEITEM hitem_bookmarks = TreeView_InsertItem(_hsidebar, &tvi);
00700 
00701     g_Globals._favorites.fill_tree(_hsidebar, hitem_bookmarks, _himl, canvas);
00702 
00703     TreeView_Expand(_hsidebar, hitem_bookmarks, TVE_EXPAND);
00704 }
00705 
00706 
00707 bool MainFrameBase::go_to(LPCTSTR url, bool new_window)
00708 {
00709     ///@todo SDI implementation
00710 
00711     return false;
00712 }
00713 
00714 
00715 #ifndef _NO_MDI
00716 
00717 MDIMainFrame::MDIMainFrame(HWND hwnd)
00718  :  super(hwnd)
00719 {
00720     TBBUTTON mdiBtns[] = {
00721         {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
00722         {0, ID_WINDOW_NEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
00723         {1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
00724         {2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
00725         {3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}
00726     };
00727 
00728     SendMessage(_htoolbar, TB_ADDBUTTONS, sizeof(mdiBtns)/sizeof(TBBUTTON), (LPARAM)&mdiBtns);
00729 
00730     CLIENTCREATESTRUCT ccs;
00731 
00732     ccs.hWindowMenu = _hMenuWindow;
00733     ccs.idFirstChild = IDW_FIRST_CHILD;
00734 
00735     _hmdiclient = CreateWindowEx(WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, TEXT("MDICLIENT"), NULL,
00736                     WS_CHILD|WS_CLIPCHILDREN|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE|WS_BORDER,
00737                     0, 0, 0, 0,
00738                     hwnd, 0, g_Globals._hInstance, &ccs);
00739 
00740     TBBUTTON extraBtns = {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0};
00741 
00742 #ifndef _NO_REBAR
00743     _hextrabar = CreateToolbarEx(hwnd,
00744                 CCS_NOPARENTALIGN|CCS_NORESIZE|CCS_NODIVIDER|
00745                 WS_CHILD|TBSTYLE_FLAT|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_LIST,
00746                 IDW_EXTRABAR, 2, g_Globals._hInstance, IDB_DRIVEBAR, NULL, 0,
00747                 16, 15, 16, 15, sizeof(TBBUTTON));
00748 #else
00749     _hextrabar = CreateToolbarEx(hwnd,
00750                 WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_LIST,CCS_NODIVIDER|
00751                 IDW_EXTRABAR, 2, g_Globals._hInstance, IDB_DRIVEBAR, &extraBtns, 1,
00752                 16, 13, 16, 13, sizeof(TBBUTTON));
00753 #endif
00754 
00755     CheckMenuItem(_menu_info._hMenuView, ID_VIEW_EXTRA_BAR, MF_BYCOMMAND|MF_CHECKED);
00756 
00757 
00758     extraBtns.fsStyle = BTNS_BUTTON;
00759 
00760 #ifdef __WINE__
00761      // insert unix file system button
00762     extraBtns.iString = SendMessage(_hextrabar, TB_ADDSTRING, 0, (LPARAM)TEXT("/\0"));
00763     extraBtns.idCommand = ID_DRIVE_UNIX_FS;
00764     SendMessage(_hextrabar, TB_INSERTBUTTON, INT_MAX, (LPARAM)&extraBtns);
00765 #endif
00766 
00767      // insert explorer window button
00768     extraBtns.iString = SendMessage(_hextrabar, TB_ADDSTRING, 0, (LPARAM)TEXT("Explore\0"));
00769     extraBtns.idCommand = ID_DRIVE_DESKTOP;
00770     SendMessage(_hextrabar, TB_INSERTBUTTON, INT_MAX, (LPARAM)&extraBtns);
00771 
00772      // insert shell namespace button
00773     extraBtns.iString = SendMessage(_hextrabar, TB_ADDSTRING, 0, (LPARAM)TEXT("Shell\0"));
00774     extraBtns.idCommand = ID_DRIVE_SHELL_NS;
00775     extraBtns.iBitmap = 6;
00776     SendMessage(_hextrabar, TB_INSERTBUTTON, INT_MAX, (LPARAM)&extraBtns);
00777 
00778      // insert web control button
00779     extraBtns.iString = SendMessage(_hextrabar, TB_ADDSTRING, 0, (LPARAM)TEXT("Web\0"));
00780     extraBtns.idCommand = ID_WEB_WINDOW;
00781     extraBtns.iBitmap = 7;
00782     SendMessage(_hextrabar, TB_INSERTBUTTON, INT_MAX, (LPARAM)&extraBtns);
00783 
00784     if ((HIWORD(GetVersion())>>14) == W_VER_NT) {
00785          // insert NT object namespace button
00786         extraBtns.iString = SendMessage(_hextrabar, TB_ADDSTRING, 0, (LPARAM)TEXT("NT Obj\0"));
00787         extraBtns.idCommand = ID_DRIVE_NTOBJ_NS;
00788         extraBtns.iBitmap = 8;
00789         SendMessage(_hextrabar, TB_INSERTBUTTON, INT_MAX, (LPARAM)&extraBtns);
00790     }
00791 #ifndef __REACTOS__ // don't insert reg button for ROS. Regedit should be used.
00792      // insert Registry button
00793     extraBtns.iString = SendMessage(_hextrabar, TB_ADDSTRING, 0, (LPARAM)TEXT("Reg.\0"));
00794     extraBtns.idCommand = ID_DRIVE_REGISTRY;
00795     extraBtns.iBitmap = 9;
00796     SendMessage(_hextrabar, TB_INSERTBUTTON, INT_MAX, (LPARAM)&extraBtns);
00797 #endif
00798 
00799 #ifdef _DEBUG
00800      // insert FAT direct file system access button
00801     extraBtns.iString = SendMessage(_hextrabar, TB_ADDSTRING, 0, (LPARAM)TEXT("FAT\0"));
00802     extraBtns.idCommand = ID_DRIVE_FAT;
00803     extraBtns.iBitmap = 10;
00804     SendMessage(_hextrabar, TB_INSERTBUTTON, INT_MAX, (LPARAM)&extraBtns);
00805 #endif
00806 
00807 
00808     TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0};
00809 #ifndef _NO_WIN_FS
00810     PTSTR p;
00811 
00812 #ifndef _NO_REBAR
00813     _hdrivebar = CreateToolbarEx(hwnd,
00814                 CCS_NOPARENTALIGN|CCS_NORESIZE|CCS_NODIVIDER|
00815                 WS_CHILD|WS_VISIBLE|TBSTYLE_FLAT|CCS_NOMOVEY|TBSTYLE_LIST,
00816                 IDW_DRIVEBAR, 2, g_Globals._hInstance, IDB_DRIVEBAR, NULL, 0,
00817                 16, 15, 16, 15, sizeof(TBBUTTON));
00818 #else
00819     _hdrivebar = CreateToolbarEx(hwnd,
00820                 WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_LIST|CCS_NODIVIDER,
00821                 IDW_DRIVEBAR, 2, g_Globals._hInstance, IDB_DRIVEBAR, &drivebarBtn, 1,
00822                 16, 13, 16, 13, sizeof(TBBUTTON));
00823 #endif
00824 #endif
00825 
00826     CheckMenuItem(_menu_info._hMenuView, ID_VIEW_DRIVE_BAR, MF_BYCOMMAND|MF_CHECKED);
00827 
00828 
00829 #ifndef _NO_WIN_FS
00830     GetLogicalDriveStrings(BUFFER_LEN, _drives);
00831 
00832      // register windows drive root strings
00833     SendMessage(_hdrivebar, TB_ADDSTRING, 0, (LPARAM)_drives);
00834 
00835     drivebarBtn.fsStyle = BTNS_BUTTON;
00836     drivebarBtn.idCommand = ID_DRIVE_FIRST;
00837 
00838     for(p=_drives; *p; ) {
00839         switch(GetDriveType(p)) {
00840             case DRIVE_REMOVABLE:   drivebarBtn.iBitmap = 1;    break;
00841             case DRIVE_CDROM:       drivebarBtn.iBitmap = 3;    break;
00842             case DRIVE_REMOTE:      drivebarBtn.iBitmap = 4;    break;
00843             case DRIVE_RAMDISK:     drivebarBtn.iBitmap = 5;    break;
00844             default:/*DRIVE_FIXED*/ drivebarBtn.iBitmap = 2;
00845         }
00846 
00847         SendMessage(_hdrivebar, TB_INSERTBUTTON, INT_MAX, (LPARAM)&drivebarBtn);
00848         ++drivebarBtn.idCommand;
00849         ++drivebarBtn.iString;
00850 
00851         while(*p++);
00852     }
00853 #endif
00854 
00855 
00856 #ifndef _NO_REBAR
00857     int btn_hgt = HIWORD(SendMessage(_htoolbar, TB_GETBUTTONSIZE, 0, 0));
00858 
00859     REBARBANDINFO rbBand;
00860 
00861     rbBand.cbSize = sizeof(REBARBANDINFO);
00862     rbBand.fMask  = RBBIM_TEXT|RBBIM_STYLE|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_SIZE;
00863 #ifndef RBBS_HIDETITLE // missing in MinGW headers as of 25.02.2004
00864 #define RBBS_HIDETITLE  0x400
00865 #endif
00866     rbBand.fStyle = RBBS_CHILDEDGE|RBBS_GRIPPERALWAYS|RBBS_HIDETITLE;
00867 
00868     TCHAR ExtrasBand[] = _T("Extras");
00869     rbBand.lpText = ExtrasBand;
00870     rbBand.hwndChild = _hextrabar;
00871     rbBand.cxMinChild = 0;
00872     rbBand.cyMinChild = btn_hgt;
00873     rbBand.cx = 284;
00874     SendMessage(_hwndrebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);
00875 
00876 #ifndef _NO_WIN_FS
00877     rbBand.fStyle |= RBBS_BREAK;
00878     TCHAR DrivesBand[] = _T("Drives");
00879     rbBand.lpText = DrivesBand;
00880     rbBand.hwndChild = _hdrivebar;
00881     rbBand.cxMinChild = 0;
00882     rbBand.cyMinChild = btn_hgt;
00883     rbBand.cx = 400;
00884     SendMessage(_hwndrebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);
00885 #endif
00886 #endif
00887 }
00888 
00889 
00890 HWND MDIMainFrame::Create()
00891 {
00892     HMENU hMenuFrame = LoadMenu(g_Globals._hInstance, MAKEINTRESOURCE(IDM_MDIFRAME));
00893 
00894     return Window::Create(WINDOW_CREATOR(MDIMainFrame), 0,
00895                 (LPCTSTR)(int)g_Globals._hframeClass, ResString(IDS_TITLE), WS_OVERLAPPEDWINDOW,
00896                 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
00897                 0/*hwndDesktop*/, hMenuFrame);
00898 }
00899 
00900 HWND MDIMainFrame::Create(LPCTSTR path, int mode)
00901 {
00902     HWND hFrame = Create();
00903     if (!hFrame)
00904         return 0;
00905 
00906     ShowWindow(hFrame, SW_SHOW);
00907 
00908     MDIMainFrame* pMainFrame = GET_WINDOW(MDIMainFrame, hFrame);
00909 
00910     if (pMainFrame)
00911         pMainFrame->CreateChild(path, mode);
00912 
00913     return hFrame;
00914 }
00915 
00916 HWND MDIMainFrame::Create(LPCITEMIDLIST pidl, int mode)
00917 {
00918     HWND hFrame = Create();
00919     if (!hFrame)
00920         return 0;
00921 
00922     ShowWindow(hFrame, SW_SHOW);
00923 
00924     MDIMainFrame* pMainFrame = GET_WINDOW(MDIMainFrame, hFrame);
00925 
00926     if (pMainFrame)
00927         pMainFrame->CreateChild(pidl, mode);
00928 
00929     return hFrame;
00930 }
00931 
00932 
00933 ChildWindow* MDIMainFrame::CreateChild(LPCTSTR path, int mode)
00934 {
00935     return reinterpret_cast<ChildWindow*>(SendMessage(_hwnd, PM_OPEN_WINDOW, mode, (LPARAM)path));
00936 }
00937 
00938 ChildWindow* MDIMainFrame::CreateChild(LPCITEMIDLIST pidl, int mode)
00939 {
00940     return reinterpret_cast<ChildWindow*>(SendMessage(_hwnd, PM_OPEN_WINDOW, mode|OWM_PIDL, (LPARAM)pidl));
00941 }
00942 
00943 
00944 BOOL MDIMainFrame::TranslateMsg(MSG* pmsg)
00945 {
00946     if (_hmdiclient && TranslateMDISysAccel(_hmdiclient, pmsg))
00947         return TRUE;
00948 
00949     return super::TranslateMsg(pmsg);
00950 }
00951 
00952 LRESULT MDIMainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
00953 {
00954     switch(nmsg) {
00955       case PM_OPEN_WINDOW: {
00956         CONTEXT("MDIMainFrame PM_OPEN_WINDOW");
00957 
00958         TCHAR buffer[MAX_PATH];
00959         LPCTSTR path;
00960         ShellPath shell_path = DesktopFolderPath();
00961 
00962         if (lparam) {
00963             if (wparam & OWM_PIDL) {
00964                  // take over PIDL from lparam
00965                 shell_path.assign((LPCITEMIDLIST)lparam);   // create as "rooted" window
00966                 FileSysShellPath fsp(shell_path);
00967                 path = fsp;
00968 
00969                 if (path) {
00970                     LOG(FmtString(TEXT("MDIMainFrame PM_OPEN_WINDOW: path=%s"), path));
00971                     lstrcpy(buffer, path);
00972                     path = buffer;
00973                 }
00974             } else {
00975                  // take over path from lparam
00976                 path = (LPCTSTR)lparam;
00977                 shell_path = path;  // create as "rooted" window
00978             }
00979         } else {
00980             ///@todo read paths and window placements from registry
00981             if (!GetCurrentDirectory(MAX_PATH, buffer))
00982                 *buffer = '\0';
00983 
00984             path = buffer;
00985         }
00986 
00987         if (path && _tcsstr(path, TEXT("://"))) {   // "http://...", "ftp://", ...
00988             OBJ_CONTEXT("create WebChild window", path);
00989 
00990             return (LRESULT)GET_WINDOW(ChildWindow, create_webchildwindow(WebChildWndInfo(_hmdiclient, path)));
00991         } else {
00992             OBJ_CONTEXT("create ShellChildWndInfo", path);
00993 
00994              // Shell Namespace as default view
00995             ShellChildWndInfo create_info(_hmdiclient, path, shell_path);
00996 
00997             if (wparam & OWM_ROOTED)
00998                 create_info._root_shell_path = shell_path;
00999             else
01000                 create_info._root_shell_path = DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
01001 
01002             create_info._pos.showCmd = wparam&OWM_SEPARATE? SW_SHOWNORMAL: SW_SHOWMAXIMIZED;
01003             create_info._pos.rcNormalPosition.left = CW_USEDEFAULT;
01004             create_info._pos.rcNormalPosition.top = CW_USEDEFAULT;
01005             create_info._pos.rcNormalPosition.right = CW_USEDEFAULT;
01006             create_info._pos.rcNormalPosition.bottom = CW_USEDEFAULT;
01007 
01008             create_info._open_mode = wparam;
01009 
01010         //  FileChildWindow::create(_hmdiclient, create_info);
01011             return (LRESULT)MDIShellBrowserChild::create(create_info);
01012         }
01013         return TRUE;}   // success
01014 
01015       default: {
01016         LRESULT res;
01017 
01018         if (super::ProcessMessage(nmsg, wparam, lparam, &res))
01019             return res;
01020         else
01021             return DefFrameProc(_hwnd, _hmdiclient, nmsg, wparam, lparam);
01022       }
01023     }
01024 
01025     return 0;
01026 }
01027 
01028 int MDIMainFrame::Command(int id, int code)
01029 {
01030     CONTEXT("MDIMainFrame::Command()");
01031 
01032     HWND hwndClient = (HWND) SendMessage(_hmdiclient, WM_MDIGETACTIVE, 0, 0);
01033 
01034     if (hwndClient)
01035         if (SendMessage(hwndClient, PM_DISPATCH_COMMAND, MAKELONG(id,code), 0))
01036             return 0;
01037 
01038 #ifndef _NO_WIN_FS
01039     if (id>=ID_DRIVE_FIRST && id<=ID_DRIVE_FIRST+0xFF) {
01040         TCHAR drv[_MAX_DRIVE], path[MAX_PATH];
01041         LPCTSTR root = _drives;
01042 
01043         for(int i=id-ID_DRIVE_FIRST; i--; root++)
01044             while(*root)
01045                 ++root;
01046 
01047         if (activate_drive_window(root))
01048             return 0;
01049 
01050         _tsplitpath_s(root, drv, COUNTOF(drv), NULL, 0, NULL, 0, NULL, 0);
01051 
01052         if (!SetCurrentDirectory(drv)) {
01053             display_error(_hwnd, GetLastError());
01054             return 0;
01055         }
01056 
01057         GetCurrentDirectory(MAX_PATH, path); ///@todo store last directory per drive
01058 
01059         FileChildWindow::create(FileChildWndInfo(_hmdiclient, path));
01060 
01061         return 1;
01062     }
01063 #endif
01064 
01065     switch(id) {
01066       case ID_WINDOW_NEW: {
01067         TCHAR path[MAX_PATH];
01068 
01069         GetCurrentDirectory(MAX_PATH, path);
01070 
01071         FileChildWindow::create(FileChildWndInfo(_hmdiclient, path));
01072         break;}
01073 
01074       case ID_WINDOW_CASCADE:
01075         SendMessage(_hmdiclient, WM_MDICASCADE, 0, 0);
01076         break;
01077 
01078       case ID_WINDOW_TILE_HORZ:
01079         SendMessage(_hmdiclient, WM_MDITILE, MDITILE_HORIZONTAL, 0);
01080         break;
01081 
01082       case ID_WINDOW_TILE_VERT:
01083         SendMessage(_hmdiclient, WM_MDITILE, MDITILE_VERTICAL, 0);
01084         break;
01085 
01086       case ID_WINDOW_ARRANGE:
01087         SendMessage(_hmdiclient, WM_MDIICONARRANGE, 0, 0);
01088         break;
01089 
01090       case ID_VIEW_EXTRA_BAR:
01091         toggle_child(_hwnd, id, _hextrabar, 1);
01092         break;
01093 
01094 #ifndef _NO_WIN_FS
01095       case ID_VIEW_DRIVE_BAR:
01096         toggle_child(_hwnd, id, _hdrivebar, 2);
01097         break;
01098 #endif
01099 
01100 #ifdef __WINE__
01101       case ID_DRIVE_UNIX_FS: {
01102         TCHAR path[MAX_PATH];
01103         FileChildWindow* child;
01104 
01105         getcwd(path, COUNTOF(path));
01106 
01107         if (activate_child_window(TEXT("unixfs")))
01108             break;
01109 
01110         FileChildWindow::create(_hmdiclient, FileChildWndInfo(path));
01111         break;}
01112 #endif
01113 
01114       case ID_DRIVE_DESKTOP: {
01115         TCHAR path[MAX_PATH];
01116 
01117         if (activate_child_window(TEXT("Desktop")))
01118             break;
01119 
01120         GetCurrentDirectory(MAX_PATH, path);
01121 
01122         MDIShellBrowserChild::create(ShellChildWndInfo(_hmdiclient, path, DesktopFolderPath()));
01123         break;}
01124 
01125       case ID_DRIVE_SHELL_NS: {
01126         TCHAR path[MAX_PATH];
01127         GetCurrentDirectory(MAX_PATH, path);
01128 
01129         if (activate_child_window(TEXT("Shell")))
01130             break;
01131 
01132         FileChildWindow::create(ShellChildWndInfo(_hmdiclient, path, DesktopFolderPath()));
01133         break;}
01134 
01135       case ID_DRIVE_NTOBJ_NS: {
01136         if (activate_child_window(TEXT("NTOBJ")))
01137             break;
01138 
01139         FileChildWindow::create(NtObjChildWndInfo(_hmdiclient, TEXT("\\")));
01140       break;}
01141 
01142       case ID_DRIVE_REGISTRY: {
01143         if (activate_child_window(TEXT("Registry")))
01144             break;
01145 
01146         FileChildWindow::create(RegistryChildWndInfo(_hmdiclient, TEXT("\\")));
01147       break;}
01148 
01149       case ID_DRIVE_FAT: {
01150 
01151         ///@todo prompt for image file
01152 
01153         if (activate_child_window(TEXT("FAT")))
01154             break;
01155 
01156         FileChildWindow::create(FATChildWndInfo(_hmdiclient, TEXT("FAT Image")));   //@@
01157       break;}
01158 
01159       case ID_WEB_WINDOW:
01160 #ifdef _DEBUG
01161         create_webchildwindow(WebChildWndInfo(_hmdiclient, TEXT("http://localhost")));
01162 #else
01163         create_webchildwindow(WebChildWndInfo(_hmdiclient, TEXT("http://www.reactos.org")));
01164 #endif
01165         break;
01166 
01167       case ID_EXPLORER_FAQ:
01168         create_webchildwindow(WebChildWndInfo(_hmdiclient, TEXT("http://www.foxplanet.de/explorer/")));
01169         break;
01170 
01171       case ID_VIEW_SDI:
01172         MainFrameBase::Create(ExplorerCmd());
01173         break;
01174 
01175       case IDW_COMMANDBAR:
01176         if (code == 1) {
01177             TCHAR url[BUFFER_LEN];
01178             LPCTSTR dir;
01179 
01180             if (GetWindowText(_haddressedit, url, BUFFER_LEN))
01181                 dir = url;
01182             else
01183                 dir = NULL;
01184 
01185             ExecuteCommandbar(dir);
01186         }
01187         break;
01188 
01189     ///@todo There are even more menu items!
01190 
01191       default:
01192         if (super::Command(id, code) == 0)
01193             return 0;
01194         else
01195             return DefFrameProc(_hwnd, _hmdiclient, WM_COMMAND, MAKELONG(id,code), 0);
01196     }
01197 
01198     return 0;
01199 }
01200 
01201 
01202 void MDIMainFrame::frame_get_clientspace(PRECT prect)
01203 {
01204     super::frame_get_clientspace(prect);
01205 
01206 #ifndef _NO_WIN_FS
01207     if (IsWindowVisible(_hdrivebar)) {
01208         ClientRect rt(_hdrivebar);
01209         prect->top += rt.bottom+2;
01210     }
01211 #endif
01212 }
01213 
01214 void MDIMainFrame::resize_frame(int cx, int cy)
01215 {
01216     if (cy <= 0)
01217         return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
01218 
01219     RECT rect = {0, 0, cx, cy};
01220 
01221     if (_hwndrebar) {
01222         int height = SendMessage(_hwndrebar, RB_GETBARHEIGHT, 0, 0);
01223         rect.top += height;
01224         rect.top += 5;
01225     } else {
01226         if (IsWindowVisible(_htoolbar)) {
01227             SendMessage(_htoolbar, WM_SIZE, 0, 0);
01228             WindowRect rt(_htoolbar);
01229             rect.top = rt.bottom;
01230         //  rect.bottom -= rt.bottom;
01231         }
01232 
01233         if (IsWindowVisible(_hextrabar)) {
01234             SendMessage(_hextrabar, WM_SIZE, 0, 0);
01235             WindowRect rt(_hextrabar);
01236             int new_top = --rect.top + rt.bottom;
01237             MoveWindow(_hextrabar, 0, rect.top, rt.right, new_top, TRUE);
01238             rect.top = new_top;
01239         //  rect.bottom -= rt.bottom;
01240         }
01241 
01242 #ifndef _NO_WIN_FS
01243         if (IsWindowVisible(_hdrivebar)) {
01244             SendMessage(_hdrivebar, WM_SIZE, 0, 0);
01245             WindowRect rt(_hdrivebar);
01246             int new_top = --rect.top + rt.bottom;
01247             MoveWindow(_hdrivebar, 0, rect.top, rt.right, new_top, TRUE);
01248             rect.top = new_top;
01249         //  rect.bottom -= rt.bottom;
01250         }
01251 #endif
01252     }
01253 
01254     if (IsWindowVisible(_hstatusbar)) {
01255         int parts[] = {300, 500};
01256 
01257         SendMessage(_hstatusbar, WM_SIZE, 0, 0);
01258         SendMessage(_hstatusbar, SB_SETPARTS, 2, (LPARAM)&parts);
01259         ClientRect rt(_hstatusbar);
01260         rect.bottom -= rt.bottom;
01261     }
01262 
01263     if (IsWindowVisible(_haddressedit) || IsWindowVisible(_hcommandedit)) {
01264         ClientRect rt(_haddressedit);
01265         rect.bottom -= rt.bottom;
01266 
01267         int mid = (rect.right-rect.left) / 2;   ///@todo use split bar
01268         SetWindowPos(_haddressedit, 0, 0, rect.bottom, mid, rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
01269         SetWindowPos(_hcommandedit, 0, mid+1, rect.bottom, rect.right-(mid+1), rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
01270     }
01271 
01272     if (IsWindowVisible(_hsidebar)) {
01273         WindowRect rt(_hsidebar);
01274         rect.left += rt.right-rt.left;
01275 
01276         SetWindowPos(_hsidebar, 0, -1, rect.top-1, rt.right-rt.left, rect.bottom-rect.top+1, SWP_NOACTIVATE|SWP_NOZORDER);
01277     }
01278 
01279     MoveWindow(_hmdiclient, rect.left-1, rect.top-1, rect.right-rect.left+1, rect.bottom-rect.top+1, TRUE);
01280 }
01281 
01282 bool MDIMainFrame::activate_drive_window(LPCTSTR path)
01283 {
01284     TCHAR drv1[_MAX_DRIVE], drv2[_MAX_DRIVE];
01285     HWND child_wnd;
01286 
01287     _tsplitpath_s(path, drv1, COUNTOF(drv1), NULL, 0, NULL, 0, NULL, 0);
01288 
01289      // search for a already open window for the same drive
01290     for(child_wnd=GetNextWindow(_hmdiclient,GW_CHILD); child_wnd; child_wnd=GetNextWindow(child_wnd, GW_HWNDNEXT)) {
01291         FileChildWindow* child = (FileChildWindow*) SendMessage(child_wnd, PM_GET_FILEWND_PTR, 0, 0);
01292 
01293         if (child) {
01294             _tsplitpath_s(child->get_root()._path, drv2, COUNTOF(drv2), NULL, 0, NULL, 0, NULL, 0);
01295 
01296             if (!lstrcmpi(drv2, drv1)) {
01297                 SendMessage(_hmdiclient, WM_MDIACTIVATE, (WPARAM)child_wnd, 0);
01298 
01299                 if (IsMinimized(child_wnd))
01300                     ShowWindow(child_wnd, SW_SHOWNORMAL);
01301 
01302                 return true;
01303             }
01304         }
01305     }
01306 
01307     return false;
01308 }
01309 
01310 bool MDIMainFrame::activate_child_window(LPCTSTR filesys)
01311 {
01312     HWND child_wnd;
01313 
01314      // search for a already open window of the given file system name
01315     for(child_wnd=GetNextWindow(_hmdiclient,GW_CHILD); child_wnd; child_wnd=GetNextWindow(child_wnd, GW_HWNDNEXT)) {
01316         FileChildWindow* child = (FileChildWindow*) SendMessage(child_wnd, PM_GET_FILEWND_PTR, 0, 0);
01317 
01318         if (child) {
01319             if (!lstrcmpi(child->get_root()._fs, filesys)) {
01320                 SendMessage(_hmdiclient, WM_MDIACTIVATE, (WPARAM)child_wnd, 0);
01321 
01322                 if (IsMinimized(child_wnd))
01323                     ShowWindow(child_wnd, SW_SHOWNORMAL);
01324 
01325                 return true;
01326             }
01327         } else {
01328             ShellBrowser* shell_child = (ShellBrowser*) SendMessage(child_wnd, PM_GET_SHELLBROWSER_PTR, 0, 0);
01329 
01330             if (shell_child) {
01331                 if (!lstrcmpi(shell_child->get_root()._fs, filesys)) {
01332                     SendMessage(_hmdiclient, WM_MDIACTIVATE, (WPARAM)child_wnd, 0);
01333 
01334                     if (IsMinimized(child_wnd))
01335                         ShowWindow(child_wnd, SW_SHOWNORMAL);
01336 
01337                     return true;
01338                 }
01339             }
01340         }
01341     }
01342 
01343     return false;
01344 }
01345 
01346 bool MDIMainFrame::go_to(LPCTSTR url, bool new_window)
01347 {
01348     if (!new_window) {
01349         HWND hwndClient = (HWND) SendMessage(_hmdiclient, WM_MDIGETACTIVE, 0, 0);
01350 
01351         if (hwndClient)
01352             if (SendMessage(hwndClient, PM_JUMP_TO_URL, 0, (LPARAM)url))
01353                 return true;
01354     }
01355 
01356     if (CreateChild(url))
01357         return true;
01358 
01359     return super::go_to(url, new_window);
01360 }
01361 
01362 #endif // _NO_MDI
01363 
01364 
01365 SDIMainFrame::SDIMainFrame(HWND hwnd)
01366  :  super(hwnd)
01367 {
01368     _split_pos = DEFAULT_SPLIT_POS;
01369     _last_split = DEFAULT_SPLIT_POS;
01370 
01371     /* wait for PM_OPEN_WINDOW message before creating a shell view
01372     update_shell_browser();*/
01373 }
01374 
01375 HWND SDIMainFrame::Create()
01376 {
01377     HMENU hMenuFrame = LoadMenu(g_Globals._hInstance, MAKEINTRESOURCE(IDM_SDIFRAME));
01378 
01379     return Window::Create(WINDOW_CREATOR(SDIMainFrame), 0,
01380                 (LPCTSTR)(int)g_Globals._hframeClass, ResString(IDS_TITLE), WS_OVERLAPPEDWINDOW,
01381                 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
01382                 0/*hwndDesktop*/, hMenuFrame);
01383 }
01384 
01385 HWND SDIMainFrame::Create(LPCITEMIDLIST pidl, int mode)
01386 {
01387     HWND hFrame = Create();
01388     if (!hFrame)
01389         return 0;
01390 
01391     ShowWindow(hFrame, SW_SHOW);
01392 
01393     SDIMainFrame* pFrame = GET_WINDOW(SDIMainFrame, hFrame);
01394 
01395     if (pFrame)
01396         pFrame->jump_to(pidl, mode);
01397 
01398     return hFrame;
01399 }
01400 
01401 HWND SDIMainFrame::Create(LPCTSTR path, int mode)
01402 {
01403     HWND hFrame = Create();
01404     if (!hFrame)
01405         return 0;
01406 
01407     ShowWindow(hFrame, SW_SHOW);
01408 
01409     MDIMainFrame* pMainFrame = GET_WINDOW(MDIMainFrame, hFrame);
01410 
01411     if (pMainFrame)
01412         pMainFrame->CreateChild(path, mode);
01413 
01414     return hFrame;
01415 }
01416 
01417 LRESULT SDIMainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
01418 {
01419     switch(nmsg) {
01420       case WM_SIZE:
01421         resize_frame(LOWORD(lparam), HIWORD(lparam));
01422         break;
01423 
01424       case WM_PAINT: {
01425         PaintCanvas canvas(_hwnd);
01426 
01427         if (_left_hwnd) {
01428             ClientRect rt(_hwnd);
01429             rt.left = _split_pos-SPLIT_WIDTH/2;
01430             rt.right = _split_pos+SPLIT_WIDTH/2+1;
01431 
01432             if (_right_hwnd) {
01433                 WindowRect right_rect(_right_hwnd);
01434                 ScreenToClient(_hwnd, &right_rect);
01435                 rt.top = right_rect.top;
01436                 rt.bottom = right_rect.bottom;
01437             }
01438 
01439             HBRUSH lastBrush = SelectBrush(canvas, GetStockBrush(COLOR_SPLITBAR));
01440             Rectangle(canvas, rt.left, rt.top-1, rt.right, rt.bottom+1);
01441             SelectObject(canvas, lastBrush);
01442         }
01443         break;}
01444 
01445       case WM_SETCURSOR:
01446         if (_left_hwnd)
01447             if (LOWORD(lparam) == HTCLIENT) {
01448                 POINT pt;
01449                 GetCursorPos(&pt);
01450                 ScreenToClient(_hwnd, &pt);
01451 
01452                 if (pt.x>=_split_pos-SPLIT_WIDTH/2 && pt.x<_split_pos+SPLIT_WIDTH/2+1) {
01453                     SetCursor(LoadCursor(0, IDC_SIZEWE));
01454                     return TRUE;
01455                 }
01456             }
01457         goto def;
01458 
01459       case WM_LBUTTONDOWN:
01460         if (_left_hwnd) {
01461             int x = GET_X_LPARAM(lparam);
01462 
01463             ClientRect rt(_hwnd);
01464 
01465             if (x>=_split_pos-SPLIT_WIDTH/2 && x<_split_pos+SPLIT_WIDTH/2+1) {
01466                 _last_split = _split_pos;
01467                 SetCapture(_hwnd);
01468             }
01469         }
01470         break;
01471 
01472       case WM_LBUTTONUP:
01473         if (GetCapture() == _hwnd)
01474             ReleaseCapture();
01475         break;
01476 
01477       case WM_KEYDOWN:
01478         if (wparam == VK_ESCAPE)
01479             if (GetCapture() == _hwnd) {
01480                 _split_pos = _last_split;
01481                 resize_children();
01482                 _last_split = -1;
01483                 ReleaseCapture();
01484                 SetCursor(LoadCursor(0, IDC_ARROW));
01485             }
01486         break;
01487 
01488       case WM_MOUSEMOVE:
01489         if (GetCapture() == _hwnd) {
01490             int x = GET_X_LPARAM(lparam);
01491 
01492             ClientRect rt(_hwnd);
01493 
01494             if (x>=0 && x<rt.right) {
01495                 _split_pos = x;
01496                 resize_children();
01497                 rt.left = x-SPLIT_WIDTH/2;
01498                 rt.right = x+SPLIT_WIDTH/2+1;
01499                 InvalidateRect(_hwnd, &rt, FALSE);
01500                 UpdateWindow(_left_hwnd);
01501                 UpdateWindow(_hwnd);
01502                 UpdateWindow(_right_hwnd);
01503             }
01504         }
01505         break;
01506 
01507       case PM_OPEN_WINDOW: {
01508         CONTEXT("SDIMainFrame PM_OPEN_WINDOW");
01509 
01510         TCHAR buffer[MAX_PATH];
01511         LPCTSTR path;
01512         ShellPath shell_path = DesktopFolderPath();
01513 
01514         if (lparam) {
01515             if (wparam & OWM_PIDL) {
01516                  // take over PIDL from lparam
01517                 shell_path.assign((LPCITEMIDLIST)lparam);   // create as "rooted" window
01518                 FileSysShellPath fsp(shell_path);
01519                 path = fsp;
01520 
01521                 if (path) {
01522                     LOG(FmtString(TEXT("SDIMainFrame PM_OPEN_WINDOW: path=%s"), path));
01523                     lstrcpy(buffer, path);
01524                     path = buffer;
01525                 }
01526             } else {
01527                  // take over path from lparam
01528                 path = (LPCTSTR)lparam;
01529                 shell_path = path;  // create as "rooted" window
01530             }
01531         } else {
01532             ///@todo read paths and window placements from registry
01533             if (!GetCurrentDirectory(MAX_PATH, buffer))
01534                 *buffer = '\0';
01535 
01536             path = buffer;
01537             shell_path = path;
01538         }
01539 
01540         if (wparam & OWM_ROOTED)
01541             _shellpath_info._root_shell_path = shell_path;
01542         else
01543             _shellpath_info._root_shell_path = DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);
01544 
01545         jump_to(shell_path, wparam);    ///@todo content of 'path' not used any more
01546         return TRUE;}   // success
01547 
01548       default: def:
01549         return super::WndProc(nmsg, wparam, lparam);
01550     }
01551 
01552     return 0;
01553 }
01554 
01555 int SDIMainFrame::Command(int id, int code)
01556 {
01557     switch(id) {
01558       case ID_VIEW_MDI:
01559         MainFrameBase::Create(ExplorerCmd(_url, true));
01560         break;
01561 
01562       case IDW_COMMANDBAR:
01563         if (code == 1)
01564             ExecuteCommandbar(_url);
01565         break;
01566 
01567       default:
01568         return super::Command(id, code);
01569     }
01570 
01571     return 0;
01572 }
01573 
01574 void SDIMainFrame::resize_frame(int cx, int cy)
01575 {
01576     if (cy <= 0)
01577         return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized
01578 
01579     RECT rect = {0, 0, cx, cy};
01580 
01581     if (_hwndrebar) {
01582         int height = ClientRect(_hwndrebar).bottom;
01583         rect.top += height;
01584         rect.top += 5;
01585     } else {
01586         if (IsWindowVisible(_htoolbar)) {
01587             SendMessage(_htoolbar, WM_SIZE, 0, 0);
01588             WindowRect rt(_htoolbar);
01589             rect.top = rt.bottom;
01590         //  rect.bottom -= rt.bottom;
01591         }
01592     }
01593 
01594     if (IsWindowVisible(_hstatusbar)) {
01595         int parts[] = {300, 500};
01596 
01597         SendMessage(_hstatusbar, WM_SIZE, 0, 0);
01598         SendMessage(_hstatusbar, SB_SETPARTS, 2, (LPARAM)&parts);
01599         ClientRect rt(_hstatusbar);
01600         rect.bottom -= rt.bottom;
01601     }
01602 
01603     if (IsWindowVisible(_haddressedit) || IsWindowVisible(_hcommandedit)) {
01604         ClientRect rt(_haddressedit);
01605         rect.bottom -= rt.bottom;
01606 
01607         int mid = (rect.right-rect.left) / 2;   ///@todo use split bar
01608         SetWindowPos(_haddressedit, 0, 0, rect.bottom, mid, rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
01609         SetWindowPos(_hcommandedit, 0, mid+1, rect.bottom, rect.right-(mid+1), rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
01610     }
01611 
01612     if (IsWindowVisible(_hsidebar)) {
01613         WindowRect rt(_hsidebar);
01614         rect.left += rt.right-rt.left;
01615 
01616         SetWindowPos(_hsidebar, 0, -1, rect.top-1, rt.right-rt.left, rect.bottom-rect.top+1, SWP_NOACTIVATE|SWP_NOZORDER);
01617     }
01618 
01619     _clnt_rect = rect;
01620 
01621     resize_children();
01622 }
01623 
01624 void SDIMainFrame::resize_children()
01625 {
01626     HDWP hdwp = BeginDeferWindowPos(2);
01627 
01628     int cx = _clnt_rect.left;
01629 
01630     if (_left_hwnd) {
01631         cx = _split_pos + SPLIT_WIDTH/2;
01632 
01633         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);
01634     } else {
01635         //_split_pos = -1;
01636         cx = 0;
01637     }
01638 
01639     if (_right_hwnd)
01640         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);
01641 
01642     EndDeferWindowPos(hdwp);
01643 }
01644 
01645 void SDIMainFrame::update_clnt_rect()
01646 {
01647     ClientRect rect(_hwnd);
01648 
01649     resize_frame(rect.right, rect.bottom);
01650 }
01651 
01652 void SDIMainFrame::update_shell_browser()
01653 {
01654     int split_pos = DEFAULT_SPLIT_POS;
01655 
01656     if (_shellBrowser.get()) {
01657         split_pos = _split_pos;
01658         delete _shellBrowser.release();
01659     }
01660 
01661      // create explorer treeview
01662     if (_shellpath_info._open_mode & OWM_EXPLORE) {
01663         if (!_left_hwnd) {
01664             ClientRect rect(_hwnd);
01665 
01666             _left_hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
01667                             WS_CHILD|WS_TABSTOP|WS_VISIBLE|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_NOTOOLTIPS|TVS_SHOWSELALWAYS,
01668                             0, rect.top, split_pos-SPLIT_WIDTH/2, rect.bottom-rect.top,
01669                             _hwnd, (HMENU)IDC_FILETREE, g_Globals._hInstance, 0);
01670 
01671              // display tree window as long as the shell view is not yet visible
01672             resize_frame(rect.right, rect.bottom);
01673             MoveWindow(_left_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE);
01674         }
01675     } else {
01676         if (_left_hwnd) {
01677             DestroyWindow(_left_hwnd);
01678             _left_hwnd = 0;
01679         }
01680     }
01681 
01682     _shellBrowser = auto_ptr<ShellBrowser>(new ShellBrowser(_hwnd, _hwnd, _left_hwnd, _right_hwnd,
01683                                                 _shellpath_info, this, _cm_ifs));
01684 
01685     if (_left_hwnd)
01686         _shellBrowser->Init();
01687 
01688      // update _clnt_rect and set size of new created shell view windows
01689     update_clnt_rect();
01690 }
01691 
01692 void SDIMainFrame::entry_selected(Entry* entry)
01693 {
01694     if (_left_hwnd)
01695         _shellBrowser->select_folder(entry, false);
01696 
01697     _shellBrowser->UpdateFolderView(entry->get_shell_folder());
01698 
01699      // set size of new created shell view windows
01700     resize_children();
01701 
01702     TCHAR path[MAX_PATH];
01703 
01704     if (entry->get_path(path, COUNTOF(path))) {
01705         String url;
01706 
01707         if (path[0] == ':')
01708             url.printf(TEXT("shell://%s"), path);
01709         else
01710             url.printf(TEXT("file://%s"), path);
01711 
01712         set_url(url);
01713     }
01714 }
01715 
01716 void SDIMainFrame::set_url(LPCTSTR url)
01717 {
01718     if (_url != url) {
01719         _url = url;
01720 
01721         SetWindowText(_haddressedit, url); //SendMessage(_hwndFrame, PM_URL_CHANGED, 0, (LPARAM)url);
01722     }
01723 }
01724 
01725 void SDIMainFrame::jump_to(LPCTSTR path, int mode)
01726 {/*@@todo
01727     if (_shellBrowser.get() && (_shellpath_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) {
01728         _shellBrowser->jump_to(path);
01729 
01730         _shellpath_info._shell_path = path;
01731     } else */{
01732         _shellpath_info._open_mode = mode;
01733         _shellpath_info._shell_path = path;
01734 
01735         update_shell_browser();
01736     }
01737 }
01738 
01739 void SDIMainFrame::jump_to(LPCITEMIDLIST path, int mode)
01740 {
01741     if (_shellBrowser.get() && (_shellpath_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) {
01742         ShellPath shell_path = path;
01743 
01744         _shellBrowser->jump_to(shell_path);
01745 
01746         _shellpath_info._shell_path = shell_path;
01747     } else {
01748         _shellpath_info._open_mode = mode;
01749         _shellpath_info._shell_path = path;
01750 
01751         update_shell_browser();
01752     }
01753 }

ROS Explorer Source Code Documentation
generated on 02.01.2013 by doxygen

ROS Explorer Homepage