6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
33 //#include <shellapi.h>
49 ////////////////////////////////////////////////////////////////////////////////
50 // Global and Local Variables:
53 BOOL bInMenuLoop
= FALSE
; // Tells us if we are in the menu loop
54 int nOldWidth
; // Holds the previous client area width
55 int nOldHeight
; // Holds the previous client area height
57 static HHOOK hcbthook
;
58 static ChildWnd
* newchild
= NULL
;
61 ////////////////////////////////////////////////////////////////////////////////
62 // Local module support methods
65 static void resize_frame_rect(HWND hWnd
, PRECT prect
)
70 if (IsWindowVisible(Globals
.hToolBar
)) {
71 SendMessage(Globals
.hToolBar
, WM_SIZE
, 0, 0);
72 GetClientRect(Globals
.hToolBar
, &rt
);
73 prect
->top
= rt
.bottom
+3;
74 prect
->bottom
-= rt
.bottom
+3;
76 if (IsWindowVisible(Globals
.hDriveBar
)) {
77 SendMessage(Globals
.hDriveBar
, WM_SIZE
, 0, 0);
78 GetClientRect(Globals
.hDriveBar
, &rt
);
79 // new_top = --prect->top + rt.bottom+3;
80 new_top
= --prect
->top
+ rt
.bottom
+0;
81 MoveWindow(Globals
.hDriveBar
, 0, prect
->top
, rt
.right
, new_top
, TRUE
);
83 // prect->bottom -= rt.bottom+2;
84 prect
->bottom
-= rt
.bottom
-1;
86 if (IsWindowVisible(Globals
.hStatusBar
)) {
88 // int parts[] = {300, 500};
89 // SendMessage(Globals.hStatusBar, WM_SIZE, 0, 0);
90 // SendMessage(Globals.hStatusBar, SB_SETPARTS, 2, (LPARAM)&parts);
91 GetClientRect(Globals
.hStatusBar
, &rt
);
92 prect
->bottom
-= rt
.bottom
;
94 MoveWindow(Globals
.hMDIClient
, prect
->left
-1,prect
->top
-1,prect
->right
+2,prect
->bottom
+1, TRUE
);
97 static void resize_frame(HWND hWnd
, int cx
, int cy
)
99 RECT rect
= {0, 0, cx
, cy
};
101 resize_frame_rect(hWnd
, &rect
);
104 void resize_frame_client(HWND hWnd
)
108 GetClientRect(hWnd
, &rect
);
109 resize_frame_rect(hWnd
, &rect
);
112 ////////////////////////////////////////////////////////////////////////////////
114 static LRESULT CALLBACK
CBTProc(int code
, WPARAM wParam
, LPARAM lParam
)
116 if (code
== HCBT_CREATEWND
&& newchild
) {
117 ChildWnd
* pChildWnd
= newchild
;
119 pChildWnd
->hWnd
= (HWND
)wParam
;
120 SetWindowLong(pChildWnd
->hWnd
, GWL_USERDATA
, (LPARAM
)pChildWnd
);
122 return CallNextHookEx(hcbthook
, code
, wParam
, lParam
);
127 BOOL FindChildWindow(int cmd)
129 TCHAR drv[_MAX_DRIVE];
130 LPCTSTR root = Globals.drives;
132 for(i = cmd - ID_DRIVE_FIRST; i--; root++)
135 if (activate_drive_window(root))
137 _tsplitpath(root, drv, 0, 0, 0);
138 if (!SetCurrentDirectory(drv)) {
139 display_error(hWnd, GetLastError());
146 static ChildWnd
* alloc_child_window(LPCTSTR path
)
148 TCHAR drv
[_MAX_DRIVE
+1], dir
[_MAX_DIR
], name
[_MAX_FNAME
], ext
[_MAX_EXT
];
151 // ChildWnd* pChildWnd = (ChildWnd*)malloc(sizeof(ChildWnd));
152 // memset(pChildWnd, 0, sizeof(ChildWnd));
153 ChildWnd
* pChildWnd
= (ChildWnd
*)malloc(sizeof(ChildWnd
)+sizeof(Root
));
154 memset(pChildWnd
, 0, sizeof(ChildWnd
)+sizeof(Root
));
155 pChildWnd
->pRoot
= (Root
*)((BYTE
*)pChildWnd
+ sizeof(ChildWnd
));
156 pChildWnd
->pRoot
= (Root
*)&pChildWnd
[1];
157 root
= pChildWnd
->pRoot
;
159 // root = &pChildWnd->root;
160 // pChildWnd->left.treePane = TRUE;
161 // pChildWnd->left.visible_cols = 0;
162 // pChildWnd->right.treePane = FALSE;
163 //#ifndef _NO_EXTENSIONS
164 // pChildWnd->right.visible_cols = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_INDEX|COL_LINKS;
166 // pChildWnd->right.visible_cols = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES;
168 pChildWnd
->pos
.length
= sizeof(WINDOWPLACEMENT
);
169 pChildWnd
->pos
.flags
= 0;
170 pChildWnd
->pos
.showCmd
= SW_SHOWNORMAL
;
171 pChildWnd
->pos
.rcNormalPosition
.left
= CW_USEDEFAULT
;
172 pChildWnd
->pos
.rcNormalPosition
.top
= CW_USEDEFAULT
;
173 pChildWnd
->pos
.rcNormalPosition
.right
= CW_USEDEFAULT
;
174 pChildWnd
->pos
.rcNormalPosition
.bottom
= CW_USEDEFAULT
;
175 pChildWnd
->nFocusPanel
= 0;
176 pChildWnd
->nSplitPos
= 300;
177 pChildWnd
->sortOrder
= SORT_NAME
;
178 // pChildWnd->header_wdths_ok = FALSE;
179 lstrcpy(pChildWnd
->szPath
, path
);
180 _tsplitpath(path
, drv
, dir
, name
, ext
);
181 #if !defined(_NO_EXTENSIONS) && defined(__linux__)
183 root
->drive_type
= GetDriveType(path
);
184 lstrcat(drv
, _T("/"));
185 lstrcpy(root
->volname
, _T("root fs"));
187 lstrcpy(root
->fs
, _T("unixfs"));
188 lstrcpy(root
->path
, _T("/"));
189 entry
= read_tree_unix(root
, path
, pChildWnd
->sortOrder
);
193 root
->drive_type
= GetDriveType(path
);
194 lstrcat(drv
, _T("\\"));
195 GetVolumeInformation(drv
, root
->volname
, _MAX_FNAME
, 0, 0, &root
->fs_flags
, root
->fs
, _MAX_DIR
);
196 lstrcpy(root
->path
, drv
);
197 entry
= read_tree_win(root
, path
, pChildWnd
->sortOrder
);
199 //@@lstrcpy(root->entry.data.cFileName, drv);
200 wsprintf(root
->entry
.data
.cFileName
, _T("%s - %s"), drv
, root
->fs
);
201 root
->entry
.data
.dwFileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
202 pChildWnd
->left
.root
= &root
->entry
;
203 set_curdir(pChildWnd
, entry
);
207 HWND
CreateChildWindow(int drv_id
)
209 //TCHAR drv[_MAX_DRIVE];
210 TCHAR path
[MAX_PATH
];
211 ChildWnd
* pChildWnd
= NULL
;
213 LPCTSTR root = Globals.drives;
215 for(i = cmd - ID_DRIVE_FIRST; i--; root++)
218 if (activate_drive_window(root))
220 _tsplitpath(root, drv, 0, 0, 0);
221 if (!SetCurrentDirectory(drv)) {
222 display_error(hWnd, GetLastError());
226 GetCurrentDirectory(MAX_PATH
, path
);
227 // pChildWnd = (ChildWnd*)malloc(sizeof(ChildWnd));
228 pChildWnd
= alloc_child_window(path
);
229 // if (!create_child_window(pChildWnd))
232 if (pChildWnd
!= NULL
) {
233 MDICREATESTRUCT mcs
= {
234 szChildClass
, path
, hInst
,
235 // CW_USEDEFAULT, CW_USEDEFAULT,
236 // CW_USEDEFAULT, CW_USEDEFAULT,
238 WS_MAXIMIZE
, (LPARAM
)pChildWnd
239 // 0/*style*/, 0/*lParam*/
241 hcbthook
= SetWindowsHookEx(WH_CBT
, CBTProc
, 0, GetCurrentThreadId());
242 newchild
= pChildWnd
;
243 pChildWnd
->hWnd
= (HWND
)SendMessage(Globals
.hMDIClient
, WM_MDICREATE
, 0, (LPARAM
)&mcs
);
244 UnhookWindowsHookEx(hcbthook
);
245 if (pChildWnd
->hWnd
!= NULL
) {
246 return pChildWnd
->hWnd
;
249 newchild
= pChildWnd
= NULL
;
255 static BOOL CALLBACK
CloseEnumProc(HWND hWnd
, LPARAM lParam
)
257 if (!GetWindow(hWnd
, GW_OWNER
)) {
258 SendMessage(GetParent(hWnd
), WM_MDIRESTORE
, (WPARAM
)hWnd
, 0);
259 if (SendMessage(hWnd
, WM_QUERYENDSESSION
, 0, 0)) {
260 SendMessage(GetParent(hWnd
), WM_MDIDESTROY
, (WPARAM
)hWnd
, 0);
266 static void OnEnterMenuLoop(HWND hWnd
)
270 // Update the status bar pane sizes
272 SendMessage(Globals
.hStatusBar
, SB_SETPARTS
, 1, (long)&nParts
);
274 SendMessage(Globals
.hStatusBar
, SB_SETTEXT
, (WPARAM
)0, (LPARAM
)_T(""));
277 static void OnExitMenuLoop(HWND hWnd
)
284 // Update the status bar pane sizes
285 GetClientRect(hWnd, &rc);
288 nParts[2] = rc.right;
289 SendMessage(Globals.hStatusBar, SB_SETPARTS, 3, (long)nParts);
290 SendMessage(Globals.hStatusBar, SB_SETTEXT, 0, (LPARAM)_T(""));
292 SendMessage(Globals
.hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)_T(""));
294 SetupStatusBar(TRUE
);
298 static void OnMenuSelect(HWND hWnd
, UINT nItemID
, UINT nFlags
, HMENU hSysMenu
)
302 if (hSysMenu
== NULL
) return;
304 _tcscpy(str
, _T(""));
305 if (nFlags
& MF_POPUP
) {
308 //EnableMenuItem(hSysMenu, uIDEnableItem, MF_BYCOMMAND|MF_ENABLED);
311 // EnableMenuItem(hSysMenu, ID_DISK_COPY_DISK, MF_BYCOMMAND|MF_GRAYED);
312 EnableMenuItem(hSysMenu
, ID_DISK_COPY_DISK
, MF_BYCOMMAND
|MF_ENABLED
);
316 case ID_OPTIONS_MENU
:
317 case ID_SECURITY_MENU
:
322 // if (hSysMenu != GetMenu(hWnd)) {
323 // if (nItemID == 2) nItemID = 5;
326 if (LoadString(Globals
.hInstance
, nItemID
, str
, 100)) {
327 // load appropriate string
329 // first newline terminates actual string
330 lpsz
= _tcschr(lpsz
, '\n');
334 SendMessage(Globals
.hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)str
);
338 static BOOL
activate_drive_window(LPCTSTR path
)
340 TCHAR drv1
[_MAX_DRIVE
], drv2
[_MAX_DRIVE
];
343 _tsplitpath(path
, drv1
, 0, 0, 0);
345 // search for a already open window for the same drive
346 for (child_wnd
= GetNextWindow(Globals
.hMDIClient
,GW_CHILD
);
348 child_wnd
= GetNextWindow(child_wnd
, GW_HWNDNEXT
)) {
349 ChildWnd
* pChildWnd
= (ChildWnd
*) GetWindowLong(child_wnd
, GWL_USERDATA
);
351 //_tsplitpath(pChildWnd->root.path, drv2, 0, 0, 0);
352 _tsplitpath(pChildWnd
->pRoot
->path
, drv2
, 0, 0, 0);
353 if (!lstrcmpi(drv2
, drv1
)) {
354 SendMessage(Globals
.hMDIClient
, WM_MDIACTIVATE
, (WPARAM
)child_wnd
, 0);
355 if (IsMinimized(child_wnd
))
356 ShowWindow(child_wnd
, SW_SHOWNORMAL
);
364 static void toggle_child(HWND hWnd
, UINT cmd
, HWND hchild
)
366 BOOL vis
= IsWindowVisible(hchild
);
368 CheckMenuItem(Globals
.hMenuOptions
, cmd
, vis
?MF_BYCOMMAND
:MF_BYCOMMAND
|MF_CHECKED
);
369 ShowWindow(hchild
, vis
?SW_HIDE
:SW_SHOW
);
370 #ifndef _NO_EXTENSIONS
371 if (g_fullscreen
.mode
)
372 fullscreen_move(hWnd
);
374 resize_frame_client(hWnd
);
377 static BOOL
cmd_drive_select(HWND hWnd
, UINT cmd
)
379 TCHAR drv
[_MAX_DRIVE
];
380 //TCHAR path[MAX_PATH];
381 //ChildWnd* pChildWnd;
382 LPCTSTR root
= Globals
.drives
;
384 for (i
= cmd
- ID_DRIVE_FIRST
; i
--; root
++)
387 if (activate_drive_window(root
)) {
390 _tsplitpath(root
, drv
, 0, 0, 0);
391 if (!SetCurrentDirectory(drv
)) {
392 display_error(hWnd
, GetLastError());
395 //GetCurrentDirectory(MAX_PATH, path); //@@ letztes Verzeichnis pro Laufwerk speichern
396 //CreateChildWindow(path);
397 CreateChildWindow(cmd
- ID_DRIVE_FIRST
);
398 // pChildWnd = alloc_child_window(path);
399 // if (!create_child_window(pChildWnd))
404 static BOOL
OnComboBoxCmd(HWND hWnd
, WPARAM wParam
)
408 switch (HIWORD(wParam
)) {
410 index
= SendMessage(Globals
.hDriveCombo
, CB_GETCURSEL
, 0, 0);
411 cmd_drive_select(hWnd
, index
+ ID_DRIVE_FIRST
);
419 ////////////////////////////////////////////////////////////////////////////////
421 // FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
423 // PURPOSE: Processes WM_COMMAND messages for the main frame window.
427 static BOOL
_CmdWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
429 UINT cmd
= LOWORD(wParam
);
431 // HWND hwndClient = (HWND)SendMessage(Globals.hMDIClient, WM_MDIGETACTIVE, 0, 0);
433 // if (SendMessage(hwndClient, WM_DISPATCH_COMMAND, wParam, lParam))
436 if ((HWND
)lParam
== Globals
.hDriveCombo
) {
437 return OnComboBoxCmd(hWnd
, wParam
);
439 if (cmd
>= ID_DRIVE_FIRST
&& cmd
<= (ID_DRIVE_FIRST
+ 0xFF)) {
440 cmd_drive_select(hWnd
, cmd
);
443 case ID_WINDOW_CLOSEALL
:
444 EnumChildWindows(Globals
.hMDIClient
, &CloseEnumProc
, 0);
446 case ID_WINDOW_CLOSE
:
447 hChildWnd
= (HWND
) SendMessage(Globals
.hMDIClient
, WM_MDIGETACTIVE
, 0, 0);
448 if (!SendMessage(hChildWnd
, WM_QUERYENDSESSION
, 0, 0))
449 SendMessage(Globals
.hMDIClient
, WM_MDIDESTROY
, (WPARAM
)hChildWnd
, 0);
451 case ID_DISK_COPY_DISK
:
454 case ID_DISK_LABEL_DISK
:
457 case ID_DISK_FORMAT_DISK
:
460 // SHFormatDrive(hWnd, 0 /* A: */, SHFMT_ID_DEFAULT, 0);
462 UINT OldMode
= SetErrorMode(0); // Get the current Error Mode settings.
463 SetErrorMode(OldMode
& ~SEM_FAILCRITICALERRORS
); // Force O/S to handle
464 // Call SHFormatDrive here.
465 SHFormatDrive(hWnd
, 0 /* A: */, SHFMT_ID_DEFAULT
, 0);
466 SetErrorMode(OldMode
); // Put it back the way it was.
470 case ID_DISK_CONNECT_NETWORK_DRIVE
:
471 MapNetworkDrives(hWnd
, TRUE
);
473 case ID_DISK_DISCONNECT_NETWORK_DRIVE
:
474 MapNetworkDrives(hWnd
, FALSE
);
476 case ID_DISK_SHARE_AS
:
477 ModifySharing(hWnd
, TRUE
);
479 case ID_DISK_STOP_SHARING
:
480 ModifySharing(hWnd
, FALSE
);
482 case ID_DISK_SELECT_DRIVE
:
485 case ID_VIEW_BY_FILE_TYPE
:
487 struct ExecuteDialog dlg
= {{0}};
488 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_DIALOG_VIEW_TYPE
), hWnd
, ViewFileTypeWndProc
, (LPARAM
)&dlg
) == IDOK
) {
492 case ID_OPTIONS_CONFIRMATION
:
494 struct ExecuteDialog dlg
= {{0}};
495 if (DialogBoxParam(Globals
.hInstance
, MAKEINTRESOURCE(IDD_DIALOG_OPTIONS_CONFIRMATON
), hWnd
, OptionsConfirmationWndProc
, (LPARAM
)&dlg
) == IDOK
) {
499 case ID_OPTIONS_FONT
:
501 case ID_OPTIONS_CUSTOMISE_TOOLBAR
:
502 SendMessage(Globals
.hToolBar
, TB_CUSTOMIZE
, 0, 0);
504 case ID_OPTIONS_TOOLBAR
:
505 toggle_child(hWnd
, cmd
, Globals
.hToolBar
);
507 case ID_OPTIONS_DRIVEBAR
:
508 toggle_child(hWnd
, cmd
, Globals
.hDriveBar
);
510 case ID_OPTIONS_STATUSBAR
:
511 toggle_child(hWnd
, cmd
, Globals
.hStatusBar
);
513 case ID_OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT
:
514 if (Globals
.Options
& OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT
) {
515 Globals
.Options
&= ~OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT
;
516 CheckMenuItem(Globals
.hMenuOptions
, cmd
, MF_BYCOMMAND
);
518 Globals
.Options
|= OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT
;
519 CheckMenuItem(Globals
.hMenuOptions
, cmd
, MF_BYCOMMAND
| MF_CHECKED
);
522 case ID_OPTIONS_MINIMISE_ON_USE
:
523 if (Globals
.Options
& ID_OPTIONS_MINIMISE_ON_USE
) {
524 Globals
.Options
&= ~ID_OPTIONS_MINIMISE_ON_USE
;
525 CheckMenuItem(Globals
.hMenuOptions
, cmd
, MF_BYCOMMAND
);
527 Globals
.Options
|= ID_OPTIONS_MINIMISE_ON_USE
;
528 CheckMenuItem(Globals
.hMenuOptions
, cmd
, MF_BYCOMMAND
| MF_CHECKED
);
531 case ID_OPTIONS_SAVE_ON_EXIT
:
532 if (Globals
.Options
& OPTIONS_SAVE_ON_EXIT
) {
533 Globals
.Options
&= ~OPTIONS_SAVE_ON_EXIT
;
534 CheckMenuItem(Globals
.hMenuOptions
, cmd
, MF_BYCOMMAND
);
536 Globals
.Options
|= OPTIONS_SAVE_ON_EXIT
;
537 CheckMenuItem(Globals
.hMenuOptions
, cmd
, MF_BYCOMMAND
| MF_CHECKED
);
540 case ID_WINDOW_NEW_WINDOW
:
541 CreateChildWindow(-1);
543 case ID_WINDOW_CASCADE
:
544 SendMessage(Globals
.hMDIClient
, WM_MDICASCADE
, 0, 0);
546 case ID_WINDOW_TILE_HORZ
:
547 SendMessage(Globals
.hMDIClient
, WM_MDITILE
, MDITILE_HORIZONTAL
, 0);
549 case ID_WINDOW_TILE_VERT
:
550 SendMessage(Globals
.hMDIClient
, WM_MDITILE
, MDITILE_VERTICAL
, 0);
552 case ID_WINDOW_ARRANGE_ICONS
:
553 SendMessage(Globals
.hMDIClient
, WM_MDIICONARRANGE
, 0, 0);
555 case ID_WINDOW_REFRESH
:
558 case ID_HELP_CONTENTS
:
559 WinHelp(hWnd
, _T("winfile"), HELP_CONTENTS
, 0);
561 case ID_HELP_SEARCH_HELP
:
562 WinHelp(hWnd
, _T("winfile"), HELP_FINDER
, 0);
564 case ID_HELP_HOW_TO_USE_HELP
:
565 WinHelp(hWnd
, _T("winfile"), HELP_HELPONHELP
, 0);
569 ShellAbout(hWnd
, szTitle
, _T(""), LoadIcon(Globals
.hInstance
, (LPCTSTR
)IDI_WINFILE
));
576 if ((cmd<IDW_FIRST_CHILD || cmd>=IDW_FIRST_CHILD+0x100) &&
577 (cmd<SC_SIZE || cmd>SC_RESTORE)) {
578 MessageBox(hWnd, _T("Not yet implemented"), _T("Winefile"), MB_OK);
580 return DefFrameProc(hWnd, Globals.hMDIClient, message, wParam, lParam);
583 hChildWnd = (HWND)SendMessage(Globals.hMDIClient, WM_MDIGETACTIVE, 0, 0);
584 if (IsWindow(hChildWnd))
585 SendMessage(hChildWnd, WM_COMMAND, wParam, lParam);
587 return DefFrameProc(hWnd, Globals.hMDIClient, message, wParam, lParam);
596 static TBBUTTON tbButtonNew
[] = {
597 {0, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, TBSTYLE_BUTTON
},
598 {0, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, TBSTYLE_BUTTON
},
599 {0, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, TBSTYLE_BUTTON
},
600 {0, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, TBSTYLE_BUTTON
},
601 {0, ID_WINDOW_CASCADE
, TBSTATE_ENABLED
, TBSTYLE_BUTTON
},
604 static LRESULT
MsgNotify(HWND hwnd
, UINT uMessage
, WPARAM wparam
, LPARAM lparam
)
609 static int nResetCount
;
610 static LPTBBUTTON lpSaveButtons
;
614 lpnmhdr
= (LPNMHDR
)lparam
;
616 // The following code allows the toolbar to be customized.
617 // If you return FALSE the Customize Toolbar dialog flashes
620 if (lpnmhdr->code == TBN_QUERYINSERT || lpnmhdr->code == TBN_QUERYDELETE) {
624 if (lpnmhdr->code == TBN_GETBUTTONINFO) {
625 LPTBNOTIFY lpTbNotify = (LPTBNOTIFY)lparam;
628 // int tbButtonNew[20] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 };
629 TBBUTTON tbButtonNew[] = {
630 {0, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
631 {0, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
632 {0, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
633 {0, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
634 {0, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
637 // 20 = total number of buttons.
638 // tbButton and tbButtonNew send information about
639 // the other 12 buttons in tbButtonNew.
640 if (lpTbNotify->iItem < 5) {
641 lpTbNotify->tbButton = tbButtonNew[lpTbNotify->iItem];
642 // LoadString(hInst, 4000+lpTbNotify->iItem, szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
643 LoadString(hInst, lpTbNotify->iItem, szBuffer, sizeof(szBuffer)/sizeof(TCHAR));
644 lstrcpy (lpTbNotify->pszText, szBuffer);
645 lpTbNotify->cchText = sizeof(szBuffer)/sizeof(TCHAR);
652 switch (lpnmhdr
->code
) {
653 case TBN_QUERYINSERT
:
654 case TBN_QUERYDELETE
:
657 case TBN_GETBUTTONINFO
:
659 LPTBNOTIFY lpTbNotify
= (LPTBNOTIFY
)lparam
;
662 typedef struct _TBBUTTON {
669 } TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON;
671 // 20 = total number of buttons.
672 // tbButton and tbButtonNew send information about
673 // the other 12 buttons in tbButtonNew.
674 if (lpTbNotify
->iItem
< 12) {
675 lpTbNotify
->tbButton
= tbButtonNew
[lpTbNotify
->iItem
];
676 LoadString(hInst
, lpTbNotify
->iItem
+ 32769, szBuffer
, sizeof(szBuffer
)/sizeof(TCHAR
));
677 lstrcpy(lpTbNotify
->pszText
, szBuffer
);
678 lpTbNotify
->cchText
= sizeof(szBuffer
)/sizeof(TCHAR
);
686 case TBN_BEGINADJUST
: // Start customizing the toolbar.
688 LPTBNOTIFY lpTB
= (LPTBNOTIFY
)lparam
;
691 // Allocate memory to store the button information.
692 nResetCount
= SendMessage(lpTB
->hdr
.hwndFrom
, TB_BUTTONCOUNT
, 0, 0);
693 lpSaveButtons
= (LPTBBUTTON
)GlobalAlloc(GPTR
, sizeof(TBBUTTON
) * nResetCount
);
695 // Save the current configuration so if the user presses
696 // reset, the original toolbar can be restored.
697 for (i
= 0; i
< nResetCount
; i
++) {
698 SendMessage(lpTB
->hdr
.hwndFrom
, TB_GETBUTTON
, i
, (LPARAM
)(lpSaveButtons
+ i
));
705 LPTBNOTIFY lpTB
= (LPTBNOTIFY
)lparam
;
708 // Remove all of the existing buttons starting with the last and working down.
709 nCount
= SendMessage(lpTB
->hdr
.hwndFrom
, TB_BUTTONCOUNT
, 0, 0);
710 for (i
= nCount
- 1; i
>= 0; i
--) {
711 SendMessage(lpTB
->hdr
.hwndFrom
, TB_DELETEBUTTON
, i
, 0);
714 // Restore the buttons that were saved.
715 SendMessage(lpTB
->hdr
.hwndFrom
, TB_ADDBUTTONS
, (WPARAM
)nResetCount
, (LPARAM
)lpSaveButtons
);
720 // Free the memory allocated during TBN_BEGINADJUST
721 GlobalFree((HGLOBAL
)lpSaveButtons
);
727 static LRESULT
OnDriveBoxNotify(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
729 LPNMHDR nmhdr
= (LPNMHDR
)lParam
;
731 // if (nmhdr->code == NM_HOVER || nmhdr->code == NM_NCHITTEST) return 0;
733 // switch (((LPNMHDR)lParam)->code) {
734 switch (nmhdr
->code
) {
745 #if (_WIN32_IE >= 0x0300)
751 #if (_WIN32_IE >= 0x0400)
754 case NM_RELEASEDCAPTURE
:
765 ////////////////////////////////////////////////////////////////////////////////
767 // FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
769 // PURPOSE: Processes messages for the main frame window.
771 // WM_COMMAND - process the application menu
772 // WM_DESTROY - post a quit message and return
776 LRESULT CALLBACK
FrameWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
781 HMENU hMenuWindow
= GetSubMenu(Globals
.hMenuFrame
, GetMenuItemCount(Globals
.hMenuFrame
)-2);
782 CLIENTCREATESTRUCT ccs
= { hMenuWindow
, IDW_FIRST_CHILD
};
783 Globals
.hMDIClient
= CreateWindowEx(0, _T("MDICLIENT"), NULL
,
784 WS_EX_MDICHILD
|WS_CHILD
|WS_CLIPCHILDREN
|WS_VISIBLE
,
786 hWnd
, (HMENU
)0, hInst
, &ccs
);
788 CheckShellAvailable();
789 CreateNetworkMonitorThread(hWnd
);
790 CreateMonitorThread(hWnd
);
791 CreateChildWindow(-1);
792 SetTimer(hWnd
, 1, 5000, NULL
);
797 if (((LPNMHDR
)lParam
)->idFrom
== IDW_DRIVEBOX
) {
798 // return OnDriveBoxNotify(hWnd, wParam, lParam);
799 return OnDriveBoxNotify(hWnd
, wParam
, lParam
);
803 if (((LPNMHDR
)lParam
)->idFrom
== IDW_TOOLBAR
) {
804 if (MsgNotify(hWnd
, message
, wParam
, lParam
)) return TRUE
;
806 // return MsgNotify(hWnd, message, wParam, lParam);
807 switch (((LPNMHDR
)lParam
)->code
) {
809 case TTN_GETDISPINFO
:
812 lpttt
= (LPTOOLTIPTEXT
)lParam
;
813 lpttt
->hinst
= hInst
;
814 // load appropriate string
815 lpttt
->lpszText
= MAKEINTRESOURCE(lpttt
->hdr
.idFrom
);
825 if (!_CmdWndProc(hWnd
, message
, wParam
, lParam
)) {
826 // if (LOWORD(wParam) > ID_CMD_FIRST && LOWORD(wParam) < ID_CMD_LAST) {
827 HWND hChildWnd
= (HWND
)SendMessage(Globals
.hMDIClient
, WM_MDIGETACTIVE
, 0, 0);
828 if (IsWindow(hChildWnd
))
829 if (SendMessage(hChildWnd
, WM_DISPATCH_COMMAND
, wParam
, lParam
))
832 return DefFrameProc(hWnd
, Globals
.hMDIClient
, message
, wParam
, lParam
);
837 SignalMonitorEvent();
838 SignalNetworkMonitorEvent();
842 resize_frame_client(hWnd
);
844 case WM_ENTERMENULOOP
:
845 OnEnterMenuLoop(hWnd
);
847 case WM_EXITMENULOOP
:
848 OnExitMenuLoop(hWnd
);
851 OnMenuSelect(hWnd
, LOWORD(wParam
), HIWORD(wParam
), (HMENU
)lParam
);
854 WinHelp(hWnd
, _T("winfile"), HELP_QUIT
, 0);
856 DestryMonitorThread();
857 DestryNetworkMonitorThread();
860 case WM_QUERYENDSESSION
:
862 SendMessage(hWnd
, WM_COMMAND
, ID_WINDOW_CLOSEALL
, 0);
863 if (GetWindow(Globals
.hMDIClient
, GW_CHILD
) != NULL
)
867 return DefFrameProc(hWnd
, Globals
.hMDIClient
, message
, wParam
, lParam
);