update for HEAD-2003091401
[reactos.git] / subsys / system / explorer / shell / mainframe.cpp
1 /*
2  * Copyright 2003 Martin Fuchs
3  *
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.
8  *
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.
13  *
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
17  */
18
19
20  //
21  // Explorer clone
22  //
23  // mainframe.cpp
24  //
25  // Martin Fuchs, 23.07.2003
26  //
27
28
29 #include "../utility/utility.h"
30
31 #include "../explorer.h"
32 #include "../globals.h"
33
34 #include "../explorer_intres.h"
35
36
37 MainFrame::MainFrame(HWND hwnd)
38  :      super(hwnd)
39 {
40         _hMenuFrame = GetMenu(hwnd);
41         _hMenuWindow = GetSubMenu(_hMenuFrame, GetMenuItemCount(_hMenuFrame)-2);
42
43         _menu_info._hMenuView = GetSubMenu(_hMenuFrame, 3);
44         _menu_info._hMenuOptions = GetSubMenu(_hMenuFrame, 4);
45
46         _hAccel = LoadAccelerators(g_Globals._hInstance, MAKEINTRESOURCE(IDA_EXPLORER));
47
48
49         CLIENTCREATESTRUCT ccs;
50
51         ccs.hWindowMenu = _hMenuWindow;
52         ccs.idFirstChild = IDW_FIRST_CHILD;
53
54 #ifndef _NO_MDI
55         _hmdiclient = CreateWindowEx(0, TEXT("MDICLIENT"), NULL,
56                                         WS_CHILD|WS_CLIPCHILDREN|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE|WS_BORDER,
57                                         0, 0, 0, 0,
58                                         hwnd, 0, g_Globals._hInstance, &ccs);
59 #endif
60
61         TBBUTTON toolbarBtns[] = {
62                 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
63                 {0, ID_WINDOW_NEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
64                 {1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
65                 {2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
66                 {3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
67 /*TODO
68                 {4, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
69                 {5, ID_... , TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
70 */      };
71
72         _htoolbar = CreateToolbarEx(hwnd, WS_CHILD|WS_VISIBLE,
73                 IDW_TOOLBAR, 2, g_Globals._hInstance, IDB_TOOLBAR, toolbarBtns,
74                 sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON));
75
76         CheckMenuItem(_menu_info._hMenuOptions, ID_VIEW_TOOL_BAR, MF_BYCOMMAND|MF_CHECKED);
77
78
79         TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0};
80         int btn = 1;
81         PTSTR p;
82
83         _hdrivebar = CreateToolbarEx(hwnd, WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_LIST,
84                                 IDW_DRIVEBAR, 2, g_Globals._hInstance, IDB_DRIVEBAR, &drivebarBtn,
85                                 1, 16, 13, 16, 13, sizeof(TBBUTTON));
86         CheckMenuItem(_menu_info._hMenuOptions, ID_VIEW_DRIVE_BAR, MF_BYCOMMAND|MF_CHECKED);
87
88
89         GetLogicalDriveStrings(BUFFER_LEN, _drives);
90
91         drivebarBtn.fsStyle = BTNS_BUTTON;
92
93 #ifdef _linux_
94          // insert unix file system button
95         SendMessage(_hdrivebar, TB_ADDSTRING, 0, (LPARAM)TEXT("/\0"));
96
97         drivebarBtn.idCommand = ID_DRIVE_UNIX_FS;
98         SendMessage(_hdrivebar, TB_INSERTBUTTON, btn++, (LPARAM)&drivebarBtn);
99         ++drivebarBtn.iString;
100 #endif
101
102          // insert explorer window button
103         SendMessage(_hdrivebar, TB_ADDSTRING, 0, (LPARAM)TEXT("Explore\0"));
104
105         drivebarBtn.idCommand = ID_DRIVE_DESKTOP;
106         SendMessage(_hdrivebar, TB_INSERTBUTTON, btn++, (LPARAM)&drivebarBtn);
107         ++drivebarBtn.iString;
108
109          // insert shell namespace button
110         SendMessage(_hdrivebar, TB_ADDSTRING, 0, (LPARAM)TEXT("Shell\0"));
111
112         drivebarBtn.idCommand = ID_DRIVE_SHELL_NS;
113         SendMessage(_hdrivebar, TB_INSERTBUTTON, btn++, (LPARAM)&drivebarBtn);
114         ++drivebarBtn.iString;
115
116          // register windows drive root strings
117         SendMessage(_hdrivebar, TB_ADDSTRING, 0, (LPARAM)_drives);
118
119         drivebarBtn.idCommand = ID_DRIVE_FIRST;
120
121         for(p=_drives; *p; ) {
122                  // insert drive letter
123                 TCHAR b[3] = {tolower(*p)};
124                 SendMessage(_hdrivebar, TB_ADDSTRING, 0, (LPARAM)b);
125
126                 switch(GetDriveType(p)) {
127                         case DRIVE_REMOVABLE:   drivebarBtn.iBitmap = 1;        break;
128                         case DRIVE_CDROM:               drivebarBtn.iBitmap = 3;        break;
129                         case DRIVE_REMOTE:              drivebarBtn.iBitmap = 4;        break;
130                         case DRIVE_RAMDISK:     drivebarBtn.iBitmap = 5;        break;
131                         default:/*DRIVE_FIXED*/ drivebarBtn.iBitmap = 2;
132                 }
133
134                 SendMessage(_hdrivebar, TB_INSERTBUTTON, btn++, (LPARAM)&drivebarBtn);
135                 ++drivebarBtn.idCommand;
136                 ++drivebarBtn.iString;
137
138                 while(*p++);
139         }
140
141
142         /* CreateStatusWindow does not accept WS_BORDER
143                 _hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0,
144                                                 WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0,
145                                                 hwnd, (HMENU)IDW_STATUSBAR, g_Globals._hInstance, 0);*/
146
147         _hstatusbar = CreateStatusWindow(WS_CHILD|WS_VISIBLE, 0, hwnd, IDW_STATUSBAR);
148         CheckMenuItem(_menu_info._hMenuOptions, ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
149 }
150
151
152 MainFrame::~MainFrame()
153 {
154          // don't exit desktop when closing file manager window
155         if (!g_Globals._desktop_mode)
156                 PostQuitMessage(0);
157 }
158
159
160 HWND MainFrame::Create()
161 {
162         HMENU hMenuFrame = LoadMenu(g_Globals._hInstance, MAKEINTRESOURCE(IDM_MAINFRAME));
163
164         return super::Create(WINDOW_CREATOR(MainFrame), 0,
165                                 (LPCTSTR)(int)g_Globals._hframeClass, ResString(IDS_TITLE), WS_OVERLAPPEDWINDOW,
166                                 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
167                                 0/*hwndDesktop*/, hMenuFrame);
168 }
169
170 HWND MainFrame::Create(LPCTSTR path, BOOL mode_explore)
171 {
172         HWND hMainFrame = Create();
173         if (!hMainFrame)
174                 return 0;
175
176         ShowWindow(hMainFrame, SW_SHOW);
177
178         MainFrame* pMainFrame = GET_WINDOW(MainFrame, hMainFrame);
179
180         if (pMainFrame)
181                 pMainFrame->CreateChild(path, mode_explore);
182
183         return hMainFrame;
184 }
185
186
187 ChildWindow* MainFrame::CreateChild(LPCTSTR path, BOOL mode_explore)
188 {
189         return reinterpret_cast<ChildWindow*>(SendMessage(_hwnd, PM_OPEN_WINDOW, mode_explore, (LPARAM)path));
190 }
191
192
193 LRESULT MainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
194 {
195         switch(nmsg) {
196           case PM_TRANSLATE_MSG: {
197                 MSG* pmsg = (MSG*) lparam;
198
199 #ifndef _NO_MDI
200                 if (_hmdiclient && TranslateMDISysAccel(_hmdiclient, pmsg))
201                         return TRUE;
202 #endif
203
204                 if (TranslateAccelerator(_hwnd, _hAccel, pmsg))
205                         return TRUE;
206
207                 return FALSE;}
208
209           case WM_CLOSE:
210                 DestroyWindow(_hwnd);
211                 g_Globals._hMainWnd = 0;
212                 break;
213
214           case WM_DESTROY:
215                 break;
216
217           case WM_SIZE:
218                 resize_frame(LOWORD(lparam), HIWORD(lparam));
219                 break;  // do not pass message to DefFrameProc
220
221           case WM_GETMINMAXINFO: {
222                 LPMINMAXINFO lpmmi = (LPMINMAXINFO)lparam;
223
224                 lpmmi->ptMaxTrackSize.x <<= 1;/*2*GetSystemMetrics(SM_CXSCREEN) / SM_CXVIRTUALSCREEN */
225                 lpmmi->ptMaxTrackSize.y <<= 1;/*2*GetSystemMetrics(SM_CYSCREEN) / SM_CYVIRTUALSCREEN */
226                 break;}
227
228           case PM_FRM_CALC_CLIENT:
229                 frame_get_clientspace((PRECT)lparam);
230                 return TRUE;
231
232           case PM_FRM_GET_MENUINFO:
233                 return (LPARAM)&_menu_info;
234
235           case PM_OPEN_WINDOW: {
236                 TCHAR buffer[MAX_PATH];
237                 LPCTSTR path;
238                 ShellPath shell_path = DesktopFolder();
239
240                 if (lparam) {
241                          // take over path from lparam
242                         path = (LPCTSTR)lparam;
243                         shell_path = path;      // create as "rooted" window
244                 } else {
245                         //TODO: read paths and window placements from registry
246                         GetCurrentDirectory(MAX_PATH, buffer);
247                         path = buffer;
248                 }
249
250                  // Shell Namespace as default view
251                 ShellChildWndInfo create_info(path, shell_path);
252
253                 create_info._pos.showCmd = SW_SHOWMAXIMIZED;
254                 create_info._pos.rcNormalPosition.left = 0;
255                 create_info._pos.rcNormalPosition.top = 0;
256                 create_info._pos.rcNormalPosition.right = 600;
257                 create_info._pos.rcNormalPosition.bottom = 280;
258
259                 create_info._mode_explore = wparam? true: false;
260
261         //      FileChildWindow::create(_hmdiclient, create_info);
262                 return (LRESULT)ShellBrowserChild::create(_hmdiclient, create_info);}
263
264           case PM_GET_CONTROLWINDOW:
265                 if (wparam == FCW_STATUS)
266                         return (LRESULT)(HWND)_hstatusbar;
267                 break;
268
269           default:
270 #ifndef _NO_MDI
271                 return DefFrameProc(_hwnd, _hmdiclient, nmsg, wparam, lparam);
272 #else
273                 return super::WNdProc(nmsg, wparam, lparam);
274 #endif
275         }
276
277         return 0;
278 }
279
280
281 int MainFrame::Command(int id, int code)
282 {
283 #ifndef _NO_MDI
284         HWND hwndClient = (HWND) SendMessage(_hmdiclient, WM_MDIGETACTIVE, 0, 0);
285
286         if (SendMessage(hwndClient, PM_DISPATCH_COMMAND, MAKELONG(id,code), 0))
287                 return 0;
288 #endif
289
290         if (id>=ID_DRIVE_FIRST && id<=ID_DRIVE_FIRST+0xFF) {
291                 TCHAR drv[_MAX_DRIVE], path[MAX_PATH];
292                 LPCTSTR root = _drives;
293
294                 for(int i=id-ID_DRIVE_FIRST; i--; root++)
295                         while(*root)
296                                 ++root;
297
298                 if (activate_drive_window(root))
299                         return 0;
300
301                 _tsplitpath(root, drv, 0, 0, 0);
302
303                 if (!SetCurrentDirectory(drv)) {
304                         display_error(_hwnd, GetLastError());
305                         return 0;
306                 }
307
308                 GetCurrentDirectory(MAX_PATH, path); //TODO: store last directory per drive
309
310 #ifndef _NO_MDI
311                 FileChildWindow::create(_hmdiclient, FileChildWndInfo(path));
312 #else
313                 //TODO: SDI implementation
314 #endif
315                 return 1;
316         }
317
318         switch(id) {
319           case ID_FILE_EXIT:
320                 SendMessage(_hwnd, WM_CLOSE, 0, 0);
321                 break;
322
323           case ID_WINDOW_NEW: {
324                 TCHAR path[MAX_PATH];
325
326                 GetCurrentDirectory(MAX_PATH, path);
327
328 #ifndef _NO_MDI
329                 FileChildWindow::create(_hmdiclient, FileChildWndInfo(path));
330 #else
331                 //TODO: SDI implementation
332 #endif
333                 break;}
334
335 #ifndef _NO_MDI
336           case ID_WINDOW_CASCADE:
337                 SendMessage(_hmdiclient, WM_MDICASCADE, 0, 0);
338                 break;
339
340           case ID_WINDOW_TILE_HORZ:
341                 SendMessage(_hmdiclient, WM_MDITILE, MDITILE_HORIZONTAL, 0);
342                 break;
343
344           case ID_WINDOW_TILE_VERT:
345                 SendMessage(_hmdiclient, WM_MDITILE, MDITILE_VERTICAL, 0);
346                 break;
347
348           case ID_WINDOW_ARRANGE:
349                 SendMessage(_hmdiclient, WM_MDIICONARRANGE, 0, 0);
350                 break;
351 #endif
352
353           case ID_VIEW_TOOL_BAR:
354                 toggle_child(_hwnd, id, _htoolbar);
355                 break;
356
357           case ID_VIEW_DRIVE_BAR:
358                 toggle_child(_hwnd, id, _hdrivebar);
359                 break;
360
361           case ID_VIEW_STATUSBAR:
362                 toggle_child(_hwnd, id, _hstatusbar);
363                 break;
364
365           case ID_EXECUTE: {
366                 ExecuteDialog dlg = {{0}, 0};
367
368                 if (DialogBoxParam(g_Globals._hInstance, MAKEINTRESOURCE(IDD_EXECUTE), _hwnd, ExecuteDialog::WndProc, (LPARAM)&dlg) == IDOK) {
369                         HINSTANCE hinst = ShellExecute(_hwnd, NULL/*operation*/, dlg.cmd/*file*/, NULL/*parameters*/, NULL/*dir*/, dlg.cmdshow);
370
371                         if ((int)hinst <= 32)
372                                 display_error(_hwnd, GetLastError());
373                 }
374                 break;}
375
376           case ID_HELP:
377                 WinHelp(_hwnd, TEXT("explorer")/*file explorer.hlp*/, HELP_INDEX, 0);
378                 break;
379
380           case ID_VIEW_FULLSCREEN:
381                 CheckMenuItem(_menu_info._hMenuOptions, id, toggle_fullscreen()?MF_CHECKED:0);
382                 break;
383
384 #ifdef _linux_
385           case ID_DRIVE_UNIX_FS: {
386                 TCHAR path[MAX_PATH];
387                 FileChildWindow* child;
388
389                 if (activate_fs_window(TEXT("unixfs")))
390                         break;
391
392                 getcwd(path, MAX_PATH);
393
394 #ifndef _NO_MDI
395                 FileChildWindow::create(_hmdiclient, FileChildWndInfo(path));
396 #else
397                 //TODO: SDI implementation
398 #endif
399                 break;}
400 #endif
401           case ID_DRIVE_SHELL_NS: {
402                 TCHAR path[MAX_PATH];
403
404                 if (activate_fs_window(TEXT("Shell")))
405                         break;
406
407                 GetCurrentDirectory(MAX_PATH, path);
408
409 #ifndef _NO_MDI
410                 FileChildWindow::create(_hmdiclient, ShellChildWndInfo(path,DesktopFolder()));
411 #else
412                 //TODO: SDI implementation
413 #endif
414                 break;}
415
416           case ID_DRIVE_DESKTOP: {
417                 TCHAR path[MAX_PATH];
418
419         /*TODO
420                 if (activate_fs_window(TEXT("Desktop")))
421                         break;
422         */
423
424                 GetCurrentDirectory(MAX_PATH, path);
425
426                 ShellBrowserChild::create(_hmdiclient, ShellChildWndInfo(path,DesktopFolder()));
427                 break;}
428
429         //TODO: There are even more menu items!
430
431           case ID_ABOUT:
432                 ShellAbout(_hwnd, ResString(IDS_TITLE), NULL, 0);
433                 break;
434
435           default:
436                 /*TODO: if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE)
437                         STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE);
438                 else */if ((id<IDW_FIRST_CHILD || id>=IDW_FIRST_CHILD+0x100) &&
439                         (id<SC_SIZE || id>SC_RESTORE))
440                         MessageBox(_hwnd, TEXT("Not yet implemented"), ResString(IDS_TITLE), MB_OK);
441
442 #ifndef _NO_MDI
443                 return DefFrameProc(_hwnd, _hmdiclient, WM_COMMAND, MAKELONG(id,code), 0);
444 #else
445                 return 0;
446 #endif
447         }
448
449         return 1;
450 }
451
452
453 void MainFrame::resize_frame_rect(PRECT prect)
454 {
455         int new_top;
456
457         if (IsWindowVisible(_htoolbar)) {
458                 SendMessage(_htoolbar, WM_SIZE, 0, 0);
459                 ClientRect rt(_htoolbar);
460                 prect->top = rt.bottom+3;
461                 prect->bottom -= rt.bottom+3;
462         }
463
464         if (IsWindowVisible(_hdrivebar)) {
465                 SendMessage(_hdrivebar, WM_SIZE, 0, 0);
466                 ClientRect rt(_hdrivebar);
467                 new_top = --prect->top + rt.bottom+3;
468                 MoveWindow(_hdrivebar, 0, prect->top, rt.right, new_top, TRUE);
469                 prect->top = new_top;
470                 prect->bottom -= rt.bottom+2;
471         }
472
473         if (IsWindowVisible(_hstatusbar)) {
474                 int parts[] = {300, 500};
475
476                 SendMessage(_hstatusbar, WM_SIZE, 0, 0);
477                 SendMessage(_hstatusbar, SB_SETPARTS, 2, (LPARAM)&parts);
478                 ClientRect rt(_hstatusbar);
479                 prect->bottom -= rt.bottom;
480         }
481
482 #ifndef _NO_MDI
483         MoveWindow(_hmdiclient, prect->left-1,prect->top-1,prect->right+2,prect->bottom+1, TRUE);
484 #endif
485 }
486
487 void MainFrame::resize_frame(int cx, int cy)
488 {
489         RECT rect;
490
491         rect.left       = 0;
492         rect.top        = 0;
493         rect.right      = cx;
494         rect.bottom = cy;
495
496         resize_frame_rect(&rect);
497 }
498
499 void MainFrame::resize_frame_client()
500 {
501         ClientRect rect(_hwnd);
502
503         resize_frame_rect(&rect);
504 }
505
506 void MainFrame::frame_get_clientspace(PRECT prect)
507 {
508         if (!IsIconic(_hwnd))
509                 GetClientRect(_hwnd, prect);
510         else {
511                 WINDOWPLACEMENT wp;
512
513                 GetWindowPlacement(_hwnd, &wp);
514
515                 prect->left = prect->top = 0;
516                 prect->right = wp.rcNormalPosition.right-wp.rcNormalPosition.left-
517                                                 2*(GetSystemMetrics(SM_CXSIZEFRAME)+GetSystemMetrics(SM_CXEDGE));
518                 prect->bottom = wp.rcNormalPosition.bottom-wp.rcNormalPosition.top-
519                                                 2*(GetSystemMetrics(SM_CYSIZEFRAME)+GetSystemMetrics(SM_CYEDGE))-
520                                                 GetSystemMetrics(SM_CYCAPTION)-GetSystemMetrics(SM_CYMENUSIZE);
521         }
522
523         if (IsWindowVisible(_htoolbar)) {
524                 ClientRect rt(_htoolbar);
525                 prect->top += rt.bottom+2;
526         }
527
528         if (IsWindowVisible(_hdrivebar)) {
529                 ClientRect rt(_hdrivebar);
530                 prect->top += rt.bottom+2;
531         }
532
533         if (IsWindowVisible(_hstatusbar)) {
534                 ClientRect rt(_hstatusbar);
535                 prect->bottom -= rt.bottom;
536         }
537 }
538
539 BOOL MainFrame::toggle_fullscreen()
540 {
541         RECT rt;
542
543         if ((_fullscreen._mode=!_fullscreen._mode)) {
544                 GetWindowRect(_hwnd, &_fullscreen._orgPos);
545                 _fullscreen._wasZoomed = IsZoomed(_hwnd);
546
547                 Frame_CalcFrameClient(_hwnd, &rt);
548                 ClientToScreen(_hwnd, (LPPOINT)&rt.left);
549                 ClientToScreen(_hwnd, (LPPOINT)&rt.right);
550
551                 rt.left = _fullscreen._orgPos.left-rt.left;
552                 rt.top = _fullscreen._orgPos.top-rt.top;
553                 rt.right = GetSystemMetrics(SM_CXSCREEN)+_fullscreen._orgPos.right-rt.right;
554                 rt.bottom = GetSystemMetrics(SM_CYSCREEN)+_fullscreen._orgPos.bottom-rt.bottom;
555
556                 MoveWindow(_hwnd, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top, TRUE);
557         } else {
558                 MoveWindow(_hwnd, _fullscreen._orgPos.left, _fullscreen._orgPos.top,
559                                                         _fullscreen._orgPos.right-_fullscreen._orgPos.left,
560                                                         _fullscreen._orgPos.bottom-_fullscreen._orgPos.top, TRUE);
561
562                 if (_fullscreen._wasZoomed)
563                         ShowWindow(_hwnd, WS_MAXIMIZE);
564         }
565
566         return _fullscreen._mode;
567 }
568
569 void MainFrame::fullscreen_move()
570 {
571         RECT rt, pos;
572         GetWindowRect(_hwnd, &pos);
573
574         Frame_CalcFrameClient(_hwnd, &rt);
575         ClientToScreen(_hwnd, (LPPOINT)&rt.left);
576         ClientToScreen(_hwnd, (LPPOINT)&rt.right);
577
578         rt.left = pos.left-rt.left;
579         rt.top = pos.top-rt.top;
580         rt.right = GetSystemMetrics(SM_CXSCREEN)+pos.right-rt.right;
581         rt.bottom = GetSystemMetrics(SM_CYSCREEN)+pos.bottom-rt.bottom;
582
583         MoveWindow(_hwnd, rt.left, rt.top, rt.right-rt.left, rt.bottom-rt.top, TRUE);
584 }
585
586
587 void MainFrame::toggle_child(HWND hwnd, UINT cmd, HWND hchild)
588 {
589         BOOL vis = IsWindowVisible(hchild);
590
591         CheckMenuItem(_menu_info._hMenuOptions, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED);
592
593         ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
594
595         if (_fullscreen._mode)
596                 fullscreen_move();
597
598         resize_frame_client();
599 }
600
601 #ifndef _NO_MDI
602 bool MainFrame::activate_drive_window(LPCTSTR path)
603 {
604         TCHAR drv1[_MAX_DRIVE], drv2[_MAX_DRIVE];
605         HWND child_wnd;
606
607         _tsplitpath(path, drv1, 0, 0, 0);
608
609          // search for a already open window for the same drive
610         for(child_wnd=::GetNextWindow(_hmdiclient,GW_CHILD); child_wnd; child_wnd=::GetNextWindow(child_wnd, GW_HWNDNEXT)) {
611                 FileChildWindow* child = (FileChildWindow*) SendMessage(child_wnd, PM_GET_FILEWND_PTR, 0, 0);
612
613                 if (child) {
614                         _tsplitpath(child->get_root()._path, drv2, 0, 0, 0);
615
616                         if (!lstrcmpi(drv2, drv1)) {
617                                 SendMessage(_hmdiclient, WM_MDIACTIVATE, (WPARAM)child_wnd, 0);
618
619                                 if (IsMinimized(child_wnd))
620                                         ShowWindow(child_wnd, SW_SHOWNORMAL);
621
622                                 return true;
623                         }
624                 }
625         }
626
627         return false;
628 }
629
630 bool MainFrame::activate_fs_window(LPCTSTR filesys)
631 {
632         HWND child_wnd;
633
634          // search for a already open window of the given file system name
635         for(child_wnd=::GetNextWindow(_hmdiclient,GW_CHILD); child_wnd; child_wnd=::GetNextWindow(child_wnd, GW_HWNDNEXT)) {
636                 FileChildWindow* child = (FileChildWindow*) SendMessage(child_wnd, PM_GET_FILEWND_PTR, 0, 0);
637
638                 if (child) {
639                         if (!lstrcmpi(child->get_root()._fs, filesys)) {
640                                 SendMessage(_hmdiclient, WM_MDIACTIVATE, (WPARAM)child_wnd, 0);
641
642                                 if (IsMinimized(child_wnd))
643                                         ShowWindow(child_wnd, SW_SHOWNORMAL);
644
645                                 return true;
646                         }
647                 }
648         }
649
650         return false;
651 }
652 #endif