source: trunk/dll/mainwnd.c@ 1155

Last change on this file since 1155 was 1140, checked in by Gregg Young, 17 years ago

Comments added for recent changes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 181.1 KB
Line 
1
2/***********************************************************************
3
4 $Id: mainwnd.c 1140 2008-09-01 19:52:06Z gyoung $
5
6 fm/2 main window
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2008 Steven H. Levine
10
11 11 Jun 02 SHL Drop obsolete xor code
12 16 Oct 02 SHL Handle large partitions
13 01 Aug 04 SHL Rework lstrip/rstrip usage
14 23 May 05 SHL Use QWL_USER
15 23 May 05 SHL Use datamin.h
16 25 May 05 SHL Use ULONGLONG and CommaFmtULL
17 26 May 05 SHL Comments and localize code
18 05 Jun 05 SHL Use QWL_USER
19 06 Jun 05 SHL Rework MainWMCommand for VAC3.65 compat
20 13 Aug 05 SHL Renames and comments
21 08 Dec 05 SHL DriveProc: disable menu items if drive not ready
22 17 Dec 05 SHL DriveProc: correct my stupid
23 29 May 06 SHL IDM_EDITANYARCHIVER: sanitize code
24 17 Jul 06 SHL Use Runtime_Error
25 17 Aug 06 SHL Complain nicer if state name does not exist
26 18 Feb 07 GKY More drive type and icon support
27 08 Mar 07 SHL SaveDirCnrState: do not save state of NOPRESCAN volumes
28 09 Mar 07 SHL RestoreDirCnrState/SaveDirCnrState: optimize and avoid overflows
29 30 Mar 07 GKY Remove GetPString for window class names
30 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
31 06 Apr 07 GKY Add some error checking in drag/drop
32 15 Apr 07 SHL mainwnd MAIN_SETUPLIST restore state not found reporting
33 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
34 20 Apr 07 SHL Avoid spurious add_udir error reports
35 12 May 07 SHL Use dcd->ulItemsToUnHilite
36 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
37 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
38 07 Aug 07 SHL Use BldQuotedFileName
39 16 Aug 07 SHL Update IDM_SAVEDIRCNRSTATE logic for ticket# 109
40 18 Aug 07 SHL Rework UM_FILLSETUPLIST for new setups storage
41 19 Aug 07 SHL Move #pragma alloc_text to end of file for OpenWatcom
42 19 Aug 07 SHL Rework SaveDirCnrState to return better error info
43 30 Aug 07 SHL Add accelerator support to quicklist windows
44 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
45 12 Jan 08 SHL Support drag&drop dialog toggle
46 16 Jan 08 SHL Add sync updates toggle
47 16 Jan 08 GKY Fix changing background color on toolbar
48 17 Jan 08 GKY Add presparam save & restore for individual directory containers
49 19 Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen
50 19 Jan 08 GKY Rework Utilities menu
51 05 Feb 08 SHL Restore no-prescan drives if restoring named state
52 14 Feb 08 SHL Rework to support settings menu conditional cascade
53 15 Feb 08 SHL Rework ResizeChildren to honor fNoTreeGap and resize drive tree better
54 19 Feb 08 JBS Stop deleting "State at last FM/2 Close" from INI file so it be accessed from States combo box.
55 22 Feb 08 JBS Ticket 230: Fix/improve various code related to state or presparam values in the INI file.
56 29 Feb 08 GKY Use xfree where appropriate
57 19 Jun 08 JBS Ticket 227: Allow temporary saving/deleting of the shutdown state of directory containers
58 22 Jun 08 GKY Use free_... functions for fortify checking
59 30 Jun 08 JBS Ticket 103: Fix restore of previous shutdown state when opening FM/2
60 07 Jul 08 JBS Ticket 242: Delete obsolete INI keys when re-saving a state
61 11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
62 all the details view settings (both the global variables and those in the
63 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
64 12 Jul 08 JBS Ticket 246: Allow saved directory container states to have no directory containers
65 (i.e. just a directory tree container).
66 18 Jul 08 SHL Use new Fortify feature to avoid spurious reports
67 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory
68 26 Aug 08 GKY Require unique ID plus text and help strings for all tools save toolbar on button delete
69 27 Aug 08 JBS Ticket 259: Support saving/restoring toolbars with states
70 29 Aug 08 JBS Ticket 259: Support saving/restoring target directories with states (except the shutdown state)
71 01 Sep 08 GKY Save toolbars immediately on change. Add bmps for default toolbars
72
73***********************************************************************/
74
75#include <stdlib.h>
76#include <string.h>
77#include <ctype.h>
78#include <process.h> // _beginthread
79
80#define INCL_DOS
81#define INCL_WIN
82#define INCL_SHLERRORS // PMERR_NOT_IN_IDX
83#define INCL_WINHELP
84#define INCL_GPI
85#define INCL_LONGLONG
86
87#include "fm3dlg.h"
88#include "fm3str.h"
89#include "tools.h"
90#include "comp.h"
91#include "datamin.h"
92#include "pathutil.h" // BldQuotedFileName
93#include "errutil.h" // Dos_Error...
94#include "strutil.h" // GetPString
95#include "notebook.h" // CfgDlgProc CfgMenuInit
96#include "command.h" // LINKCMDS
97#include "avl.h" // free_archivers
98#include "walkem.h" // free_setups...
99#include "fm3dll.h"
100
101#include "fortify.h"
102
103#pragma data_seg(DATA1)
104
105static PSZ pszSrcFile = __FILE__;
106
107static USHORT firsttool = 0;
108
109static BOOL CloseDirCnrChildren(HWND hwndClient);
110static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview);
111static VOID DeletePresParams(PSZ pszKeyroot);
112static VOID BuildTools(HWND hwndT, BOOL resize);
113
114static MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
115 MPARAM mp2)
116{
117 switch (msg) {
118 case WM_CREATE:
119 break;
120
121 case UM_SETUP:
122 case UM_SETUP2:
123 case UM_SETUP3:
124 case UM_SETUP4:
125 case UM_SETUP5:
126 /*
127 * feed setup messages to main window
128 */
129 PostMsg(hwndMain, msg, mp1, mp2);
130 return 0;
131
132 case UM_SETUP6:
133 /*
134 * handle bubble help requests from drive bar buttons
135 */
136 {
137 char dv[3], d;
138 HWND hwndB = (HWND) mp1;
139 USHORT id;
140
141 id = WinQueryWindowUShort(hwndB, QWS_ID);
142 *dv = 0;
143 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwndB, QW_PARENT),
144 id + 50), sizeof(dv), dv);
145 d = toupper(*dv);
146 if (isalpha(d) && d > 'B' &&
147 !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
148 DRIVE_SLOW)) &&
149 (!hwndBubble ||
150 WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
151 !WinQueryCapture(HWND_DESKTOP)) {
152
153 FSALLOCATE fsa;
154 CHAR s[90], szQty[38];
155 ULONG ulPctFree;
156 ULONGLONG ullFreeQty;
157
158 if (!DosQueryFSInfo((d - 'A') + 1,
159 FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
160 ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
161 (fsa.cSectorUnit * fsa.cbSector);
162 ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
163 (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
164 CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
165 sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
166 }
167 if ((!hwndBubble ||
168 WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
169 !WinQueryCapture(HWND_DESKTOP))
170 WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
171 }
172 }
173 return 0;
174
175 case UM_SETDIR:
176 {
177 CHAR s[8] = " :\\OS2";
178 ULONG bd;
179
180 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
181 QSV_BOOT_DRIVE,
182 (PVOID) & bd, (ULONG) sizeof(ULONG)))
183 bd = 3L;
184 *s = (CHAR) bd + '@';
185 WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1));
186 if (!mp1) {
187 s[3] = 0;
188 WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
189 }
190 PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1), MPFROMLONG(1));
191 }
192 return 0;
193
194 case UM_RESTORE:
195 switch ((ULONG)mp2) {
196 case 1:
197 TileChildren(hwndMain, TRUE);
198 break;
199 case 2:
200 CloseDirCnrChildren(hwndMain);
201 break;
202 case 0:
203 fNoTileUpdate = TRUE;
204 WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), FALSE);
205 RestoreDirCnrState(hwndMain, (char *)mp1, FALSE);
206 WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), TRUE);
207 fNoTileUpdate = FALSE;
208 //xfree((char *)mp1, pszSrcFile, __LINE__);
209// if (fAutoTile)
210// TileChildren(hwndMain, TRUE);
211 break;
212 default:
213 Runtime_Error(pszSrcFile, __LINE__, "%u unexpected", mp2);
214 }
215 return 0;
216
217 case UM_NOTIFY:
218 /*
219 * bring up notify messages for various windows
220 */
221 if (mp1)
222 return MRFROMLONG(DoNotify((char *)mp1));
223 return 0;
224
225 case WM_DESTROY:
226 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
227 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
228 break;
229 }
230 return WinDefWindowProc(hwnd, msg, mp1, mp2);
231}
232
233VOID MakeMainObjWin(VOID * args)
234{
235 HAB hab2;
236 HMQ hmq2;
237 QMSG qmsg2;
238
239 priority_bumped();
240 hab2 = WinInitialize(0);
241 if (hab2) {
242 hmq2 = WinCreateMsgQueue(hab2, 128);
243 if (hmq2) {
244 DosError(FERR_DISABLEHARDERR);
245 WinRegisterClass(hab2,
246 (PSZ) WC_OBJECTWINDOW,
247 MainObjectWndProc, 0, sizeof(PVOID));
248 MainObjectHwnd = WinCreateWindow(HWND_OBJECT,
249 WC_OBJECTWINDOW,
250 (PSZ) NULL,
251 0,
252 0L,
253 0L,
254 0L,
255 0L,
256 0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
257 if (!MainObjectHwnd)
258 Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
259 IDS_WINCREATEWINDOW);
260 else {
261 WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
262# ifdef FORTIFY
263 Fortify_EnterScope();
264# endif
265 while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
266 WinDispatchMsg(hab2, &qmsg2);
267 WinDestroyWindow(MainObjectHwnd);
268# ifdef FORTIFY
269 Fortify_LeaveScope();
270# endif
271 }
272 WinDestroyMsgQueue(hmq2);
273 }
274 WinTerminate(hab2);
275 }
276}
277
278static MRESULT EXPENTRY IdealButtonProc(HWND hwnd, ULONG msg, MPARAM mp1,
279 MPARAM mp2)
280{
281 switch (msg) {
282 case WM_MOUSEMOVE:
283 BubbleHelp(hwnd, TRUE, FALSE, FALSE, GetPString(IDS_IDEALBUTTONHELP));
284 break;
285 }
286 return PFNWPButton(hwnd, msg, mp1, mp2);
287}
288
289HWND TopWindow(HWND hwndParent, HWND exclude)
290{
291 HENUM henum;
292 HWND hwndC = (HWND) 0;
293 USHORT id;
294
295 if (hwndParent) {
296 henum = WinBeginEnumWindows(hwndMain);
297 while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
298 if (hwndC != exclude) {
299 id = WinQueryWindowUShort(hwndC, QWS_ID);
300 if (id)
301 break;
302 }
303 }
304 WinEndEnumWindows(henum);
305 }
306 return hwndC;
307}
308
309HWND TopWindowName(HWND hwndParent, HWND exclude, CHAR * ret)
310{
311 HENUM henum;
312 HWND hwndC = (HWND) 0, hwndDir, hwndClient;
313 USHORT id;
314 PCNRITEM pci = NULL;
315
316 if (ret) {
317 *ret = 0;
318 if (hwndParent) {
319 henum = WinBeginEnumWindows(hwndMain);
320 while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
321 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
322 if (hwndC != exclude && hwndC != hwndTree) {
323 id = WinQueryWindowUShort(hwndC, QWS_ID);
324 if (id) {
325 hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
326 if (hwndClient) {
327 hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
328 if (hwndDir) {
329 if (fLookInDir) {
330 pci = (PCNRITEM) WinSendMsg(hwndDir,
331 CM_QUERYRECORDEMPHASIS,
332 MPFROMLONG(CMA_FIRST),
333 MPFROMSHORT(CRA_CURSORED));
334 if (pci && (INT) pci != -1)
335 break;
336 }
337 if (WinSendMsg(hwndClient,
338 UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
339 MakeValidDir(ret);
340 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
341 WinEndEnumWindows(henum);
342 return hwndC;
343 }
344 }
345 }
346 }
347 }
348 }
349 WinEndEnumWindows(henum);
350 if (!pci || (INT) pci == -1) {
351 hwndC = hwndTree;
352 pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
353 FID_CLIENT),
354 TREE_CNR),
355 CM_QUERYRECORDEMPHASIS,
356 MPFROMLONG(CMA_FIRST),
357 MPFROMSHORT(CRA_CURSORED));
358 }
359 if (pci && (INT) pci != -1) {
360 strcpy(ret, pci->pszFileName);
361 MakeValidDir(ret);
362 }
363 else
364 strcpy(ret, pFM2SaveDirectory);
365 }
366 }
367 return hwndC;
368}
369
370ULONG CountDirCnrs(HWND hwndParent)
371{
372 HENUM henum;
373 HWND hwndF = (HWND) 0, hwndC, hwndDir;
374 ULONG ret = 0;
375
376 henum = WinBeginEnumWindows(hwndParent);
377 while ((hwndF = WinGetNextWindow(henum)) != NULLHANDLE) {
378 hwndC = WinWindowFromID(hwndF, FID_CLIENT);
379 if (hwndC) {
380 hwndDir = WinWindowFromID(hwndC, DIR_CNR);
381 if (hwndDir)
382 ret++;
383 }
384 }
385 WinEndEnumWindows(henum);
386 return ret;
387}
388
389HWND FindDirCnrByName(CHAR * directory, BOOL restore)
390{
391 HENUM henum;
392 HWND hwndF = (HWND) 0, hwndC, hwndDir;
393 CHAR retstr[CCHMAXPATH];
394
395 if (hwndMain) {
396 henum = WinBeginEnumWindows(hwndMain);
397 while ((hwndF = WinGetNextWindow(henum)) != NULLHANDLE) {
398 hwndC = WinWindowFromID(hwndF, FID_CLIENT);
399 if (hwndC) {
400 hwndDir = WinWindowFromID(hwndC, DIR_CNR);
401 if (hwndDir) {
402 *retstr = 0;
403 WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
404 if (*retstr && !stricmp(retstr, directory)) {
405 if (restore)
406 WinSetWindowPos(hwndF,
407 HWND_TOP,
408 0,
409 0,
410 0,
411 0,
412 SWP_RESTORE | SWP_SHOW |
413 SWP_ACTIVATE | SWP_ZORDER);
414 break;
415 }
416 }
417 }
418 }
419 WinEndEnumWindows(henum);
420 }
421 return hwndF;
422}
423
424static VOID SetToggleChecks(HWND hwndMenu)
425{
426 WinCheckMenuItem(hwndMenu, IDM_TEXTTOOLS, fTextTools);
427 WinCheckMenuItem(hwndMenu, IDM_TOOLTITLES, fToolTitles);
428 WinCheckMenuItem(hwndMenu, IDM_USERLIST, fUserComboBox);
429 WinCheckMenuItem(hwndMenu, IDM_TOOLSUBMENU, fToolbar);
430 WinCheckMenuItem(hwndMenu, IDM_AUTOVIEWSUBMENU, fAutoView);
431 WinCheckMenuItem(hwndMenu, IDM_AUTOVIEWFILE, !fComments);
432 WinCheckMenuItem(hwndMenu, IDM_AUTOVIEWCOMMENTS, fComments);
433 WinCheckMenuItem(hwndMenu, IDM_MOREBUTTONS, fMoreButtons);
434 WinCheckMenuItem(hwndMenu, IDM_DRIVEBAR, fDrivebar);
435 WinCheckMenuItem(hwndMenu, IDM_AUTOTILE, fAutoTile);
436 WinCheckMenuItem(hwndMenu, IDM_TILEBACKWARDS, fTileBackwards);
437 WinCheckMenuItem(hwndMenu, IDM_TOGGLEDRAGDIALOG, fDragndropDlg);
438 WinCheckMenuItem(hwndMenu, IDM_SYNCUPDATES, fSyncUpdates);
439}
440
441static VOID ResizeTools(HWND hwnd)
442{
443 register ULONG butx = 18L;
444 INT attrib = SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_NOREDRAW,
445 noattrib;
446 register TOOL *tool, *starttool;
447 SWP *swp;
448 register ULONG numtools, x;
449
450 if (!fToolbar)
451 return;
452 noattrib = attrib;
453 noattrib &= (~(SWP_SHOW | SWP_ZORDER));
454 noattrib |= SWP_HIDE;
455 /* count tools */
456 tool = toolhead;
457 for (numtools = 0L; tool; numtools++)
458 tool = tool->next;
459 /* allocate swp array for WinSetMultWindowPos */
460 swp = xmallocz(sizeof(SWP) * (numtools + 2), pszSrcFile, __LINE__);
461 if (swp) {
462 for (x = 0; x < numtools + 2L; x++) {
463 swp[x].hwndInsertBehind = HWND_TOP;
464 swp[x].fl = attrib;
465 swp[x].y = (fToolTitles) ? 14L : 3L;
466 swp[x].cx = 32L;
467 swp[x].cy = 32L;
468 }
469 swp[0].x = swp[1].x = 2L;
470 swp[0].y = (fTextTools) ? 14L : 18L;
471 swp[1].y = (fTextTools) ? 1L : 2L;
472 swp[0].cx = swp[1].cx = 14L;
473 swp[0].cy = swp[1].cy = 14L;
474 swp[0].hwnd = WinWindowFromID(hwnd, IDM_TOOLLEFT);
475 swp[1].hwnd = WinWindowFromID(hwnd, IDM_TOOLRIGHT);
476 x = 2L;
477 tool = find_tool(firsttool);
478 if (!tool)
479 tool = toolhead;
480 starttool = tool;
481 while (tool) {
482 if (!(tool->flags & T_INVISIBLE)) {
483 swp[x].x = butx;
484 if (fTextTools || (tool->flags & T_TEXT)) {
485 butx += 55L;
486 swp[x].cx = 54L;
487 swp[x].cy = 24L;
488 swp[x].y = 3L;
489 }
490 else
491 butx += 33L;
492 if (tool->flags & T_SEPARATOR)
493 butx += 12;
494 }
495 else
496 swp[x].fl = noattrib;
497 swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
498 x++;
499 tool = tool->next;
500 }
501 tool = toolhead;
502 while (tool && tool != starttool) {
503 swp[x].x = butx;
504 if (!(tool->flags & T_INVISIBLE)) {
505 if (fTextTools || (tool->flags & T_TEXT)) {
506 butx += 55L;
507 swp[x].cx = 54L;
508 swp[x].cy = 24L;
509 swp[x].y = 3L;
510 }
511 else
512 butx += 33L;
513 if (tool->flags & T_SEPARATOR)
514 butx += 12;
515 }
516 else
517 swp[x].fl = noattrib;
518 swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
519 x++;
520 tool = tool->next;
521 }
522 WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), swp, numtools + 2L);
523 if (!fTextTools && fToolTitles) {
524 for (x = 2L; x < numtools + 2L; x++) {
525 if (fTextTools || !fToolTitles)
526 swp[x].fl = noattrib;
527 else {
528 tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
529 if (tool && (tool->flags & T_TEXT))
530 swp[x].fl = noattrib;
531 else {
532 swp[x].hwndInsertBehind = HWND_TOP;
533 swp[x].y = 1L;
534 swp[x].cy = 10L;
535 }
536 }
537 swp[x].hwnd = WinWindowFromID(hwnd,
538 WinQueryWindowUShort(swp[x].hwnd,
539 QWS_ID) + 25000);
540 }
541 WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), &swp[2], numtools);
542 }
543 free(swp);
544 }
545 WinInvalidateRect(hwnd, NULL, TRUE);
546}
547
548static MRESULT EXPENTRY DropDownListProc(HWND hwnd, ULONG msg, MPARAM mp1,
549 MPARAM mp2)
550{
551 PFNWP oldproc = (PFNWP) INSTDATA(hwnd);
552 USHORT id;
553
554 static HWND hwndMenu = (HWND)0;
555 static BOOL emphasized = FALSE;
556
557 switch (msg) {
558 case WM_MOUSEMOVE:
559 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
560 break;
561
562 case WM_CHAR:
563 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
564 break;
565
566 case WM_MENUEND:
567 if (hwndMenu == (HWND) mp2) {
568 WinDestroyWindow(hwndMenu);
569 hwndMenu = (HWND) 0;
570 }
571 break;
572
573 case WM_FOCUSCHANGE:
574 {
575 HAB hab = WinQueryAnchorBlock(hwnd);
576 HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
577 HWND hwndFrame = WinQueryWindow(hwndParent, QW_PARENT);
578 static HACCEL haccelSaved = NULLHANDLE;
579 static HACCEL haccelDriveList = NULLHANDLE;
580 static HACCEL haccelSetupList = NULLHANDLE;
581 static HACCEL haccelUserList = NULLHANDLE;
582 static HACCEL haccelCmdList = NULLHANDLE;
583 static HACCEL haccelButtonList = NULLHANDLE;
584 // DbgMsg(pszSrcFile, __LINE__, "WM_FOCUSCHANGE %u", SHORT1FROMMP(mp2));
585 id = WinQueryWindowUShort(hwndParent, QWS_ID);
586 if (SHORT1FROMMP(mp2)) {
587 // If getting focus 1st time - save original accelerator
588 if (haccelSaved == NULLHANDLE) {
589 haccelSaved = WinQueryAccelTable(hab, hwndFrame);
590 if (haccelSaved == NULLHANDLE)
591 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
592 // else
593 // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
594 }
595 if (haccelSaved != NULLHANDLE) {
596 switch (id) {
597 case MAIN_DRIVELIST:
598 if (haccelDriveList == NULLHANDLE) {
599 haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
600 if (haccelDriveList == NULLHANDLE)
601 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
602 }
603 if (haccelDriveList != NULLHANDLE) {
604 if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
605 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
606 // else
607 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
608 }
609 break;
610 case MAIN_SETUPLIST:
611 if (haccelSetupList == NULLHANDLE) {
612 haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
613 if (haccelSetupList == NULLHANDLE)
614 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
615 }
616 if (haccelSetupList != NULLHANDLE) {
617 if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
618 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
619 // else
620 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
621 }
622 break;
623 case MAIN_CMDLIST:
624 if (haccelCmdList == NULLHANDLE) {
625 haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
626 if (haccelCmdList == NULLHANDLE)
627 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
628 }
629 if (haccelCmdList != NULLHANDLE) {
630 if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
631 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
632 // else
633 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
634 }
635 break;
636 case MAIN_USERLIST:
637 if (haccelUserList == NULLHANDLE) {
638 haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
639 if (haccelUserList == NULLHANDLE)
640 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
641 }
642 if (haccelUserList != NULLHANDLE) {
643 if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
644 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
645 // else
646 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
647 }
648 break;
649 case MAIN_BUTTONLIST:
650 if (haccelButtonList == NULLHANDLE) {
651 haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
652 if (haccelButtonList == NULLHANDLE)
653 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
654 }
655 if (haccelButtonList != NULLHANDLE) {
656 if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
657 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
658 // else
659 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
660 }
661 break;
662 } // switch
663 }
664 }
665 else {
666 // Losing focus
667 switch (id) {
668 case MAIN_DRIVELIST:
669 case MAIN_SETUPLIST:
670 case MAIN_CMDLIST:
671 case MAIN_USERLIST:
672 case MAIN_BUTTONLIST:
673 if (haccelSaved != NULLHANDLE) {
674 if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
675 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
676 // else
677 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
678 }
679 break;
680 } // switch
681 }
682 }
683 break; // WM_FOCUSCHANGE
684
685 case WM_CONTEXTMENU:
686 {
687 MRESULT ret = MRFROMSHORT(TRUE);
688
689 if (hwndMenu)
690 WinDestroyWindow(hwndMenu);
691 hwndMenu = (HWND) 0;
692 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
693 switch (id) {
694 case MAIN_CMDLIST:
695 WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
696 QW_PARENT),
697 QW_PARENT),
698 FID_CLIENT),
699 WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
700 break;
701 case MAIN_USERLIST:
702 case MAIN_SETUPLIST:
703 hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
704 if (hwndMenu)
705 PopupMenu(hwnd,
706 WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
707 QW_PARENT),
708 QW_PARENT),
709 FID_CLIENT), hwndMenu);
710 break;
711 default:
712 ret = FALSE;
713 break;
714 } // switch
715 return ret;
716 }
717
718 case WM_CONTROL:
719 if (hwndStatus2) {
720 switch (SHORT1FROMMP(mp1)) {
721 case CBID_EDIT:
722 id = WinQueryWindowUShort(hwnd, QWS_ID);
723 switch (SHORT2FROMMP(mp1)) {
724 case EN_SETFOCUS:
725 switch (id) {
726 case MAIN_CMDLIST:
727 WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
728 break;
729 case MAIN_SETUPLIST:
730 WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
731 break;
732 case MAIN_USERLIST:
733 WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
734 break;
735 case MAIN_DRIVELIST:
736 WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
737 break;
738 case MAIN_BUTTONLIST:
739 WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
740 break;
741 default:
742 break;
743 }
744 break;
745
746 default:
747 break;
748 }
749 }
750 break;
751
752 default:
753 break;
754 }
755 break;
756
757 case WM_BEGINDRAG:
758 id = WinQueryWindowUShort(hwnd, QWS_ID);
759 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%u %s %u",id,(id == CBID_EDIT) ? "TRUE" : "FALSE",WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID) == MAIN_USERLIST);
760 if (id == CBID_EDIT &&
761 WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
762 MAIN_USERLIST) {
763
764 CHAR path[CCHMAXPATH];
765
766 *path = 0;
767 WinQueryWindowText(hwnd, CCHMAXPATH, path);
768 bstrip(path);
769 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Dragging: %s",path);
770 if (*path && !IsRoot(path))
771 DragOne(hwnd, (HWND) 0, path, FALSE);
772 return 0;
773 }
774 break;
775
776 case DM_DRAGOVER:
777 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
778 if (id == MAIN_USERLIST) {
779 if (!emphasized) {
780 emphasized = TRUE;
781 DrawTargetEmphasis(hwnd, emphasized);
782 }
783 if (AcceptOneDrop(hwnd, mp1, mp2))
784 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
785 return MRFROM2SHORT(DOR_NEVERDROP, 0);
786 }
787 break;
788
789 case DM_DRAGLEAVE:
790 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
791 if (id == MAIN_USERLIST) {
792 if (emphasized) {
793 emphasized = FALSE;
794 DrawTargetEmphasis(hwnd, emphasized);
795 }
796 }
797 break;
798
799 case DM_DROPHELP:
800 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
801 if (id == MAIN_USERLIST) {
802 DropHelp(mp1, mp2, hwnd, GetPString(IDS_USERLISTDROPHELP));
803 return 0;
804 }
805 break;
806
807 case DM_DROP:
808 id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
809 if (id == MAIN_USERLIST) {
810
811 char szFrom[CCHMAXPATH + 2];
812
813 if (emphasized) {
814 emphasized = FALSE;
815 DrawTargetEmphasis(hwnd, emphasized);
816 }
817 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
818 MakeValidDir(szFrom);
819 WinSetWindowText(hwnd, szFrom);
820 PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
821 QW_PARENT),
822 QW_PARENT),
823 FID_CLIENT),
824 UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
825 return 0;
826 }
827 }
828 break;
829
830 case WM_DESTROY:
831 if (hwndMenu)
832 WinDestroyWindow(hwndMenu);
833 hwndMenu = (HWND) 0;
834 break;
835 }
836
837 return oldproc(hwnd, msg, mp1, mp2);
838}
839
840void BubbleHelp(HWND hwnd, BOOL other, BOOL drive, BOOL above, char *help)
841{
842 if (help && *help &&
843 ((drive && fDrivebarHelp) ||
844 (other && fOtherHelp) || (!other && !drive && fToolbarHelp))) {
845 if ((!hwndBubble ||
846 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
847 !WinQueryCapture(HWND_DESKTOP))
848 MakeBubble(hwnd, above, help);
849 }
850}
851
852VOID MakeBubble(HWND hwnd, BOOL above, CHAR * help)
853{
854 if (!hwnd || !help || !*help)
855 return;
856
857 if (hwndBubble)
858 WinDestroyWindow(hwndBubble);
859
860 {
861 HWND hwndActive;
862 char ucClassname[8];
863
864 hwndActive = WinQueryActiveWindow(HWND_DESKTOP);
865 if (hwndActive) {
866 /* don't bring up help if window isn't active */
867 if (!WinIsChild(hwnd, hwndActive))
868 return;
869 }
870 hwndActive = WinQueryFocus(HWND_DESKTOP);
871 if (WinQueryClassName(hwndActive, sizeof(ucClassname), ucClassname)) {
872 /* don't bring up help if a menu is active */
873 if (!strcmp(ucClassname, "#4"))
874 return;
875 }
876 }
877
878 hwndBubble = WinCreateWindow(HWND_DESKTOP,
879 WC_BUBBLE,
880 help,
881 WS_CLIPSIBLINGS | SS_TEXT |
882 DT_CENTER | DT_VCENTER,
883 0,
884 0,
885 0,
886 0,
887 HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
888 if (!hwndBubble)
889 Win_Error2(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
890 IDS_WINCREATEWINDOW);
891 else {
892 HPS hps;
893 POINTL aptl[TXTBOX_COUNT], ptl, tptl;
894 LONG lxScreen, sx, sy, extra = 0, lyScreen;
895 char *p, *pp, *wp;
896 SWP swp;
897
898 WinQueryWindowPos(hwnd, &swp);
899 lyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
900 lxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
901 WinSetWindowULong(hwndBubble, QWL_USER, hwnd);
902 SetPresParams(hwndBubble, NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
903 hps = WinGetPS(hwndBubble);
904 p = help;
905 tptl.x = tptl.y = 0;
906 while (p && *p) {
907 wp = NULL;
908 pp = strchr(p, '\r');
909 if (pp) {
910 wp = pp;
911 *pp = 0;
912 pp++;
913 }
914 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
915 tptl.x = max(aptl[TXTBOX_TOPRIGHT].x, tptl.x);
916 if (tptl.y)
917 tptl.y += extra;
918 else
919 extra = aptl[TXTBOX_TOPLEFT].y / 4;
920 tptl.y += aptl[TXTBOX_TOPLEFT].y;
921 if (wp)
922 *wp = '\r';
923 p = pp;
924 }
925 WinSetWindowULong(hwndBubble, QWL_USER + 4, extra);
926 WinReleasePS(hps);
927 ptl.x = ptl.y = 0;
928 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptl, 1);
929 if (above) {
930 sy = ptl.y + swp.cy + 4;
931 if (sy + tptl.y + 12 > lyScreen) {
932 above = FALSE;
933 sy = ptl.y - (tptl.y + 14);
934 }
935 }
936 else
937 sy = ptl.y - (tptl.y + 14);
938 if (ptl.x > (lxScreen / 2))
939 sx = (ptl.x - tptl.x) - 16;
940 else
941 sx = ptl.x + (54 * (above == FALSE)) + 2;
942 if (sx < 0)
943 sx = 0;
944 if (sx + tptl.x + 14 > lxScreen)
945 sx = lxScreen - (tptl.x + 14);
946 if (sy < 0) {
947 sy = ptl.y + swp.cy + 4;
948 if (sy + tptl.y + 12 > lyScreen)
949 sy = 0;
950 }
951 WinSetWindowPos(hwndBubble, HWND_TOP, sx, sy,
952 tptl.x + 14,
953 tptl.y + 12,
954 SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
955 SWP_MOVE | SWP_SIZE);
956 }
957}
958
959MRESULT EXPENTRY BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
960{
961 switch (msg) {
962 case WM_SETFOCUS:
963 if (mp2)
964 PostMsg(hwnd, UM_FOCUSME, mp1, MPVOID);
965 break;
966
967 case UM_FOCUSME:
968 WinSetFocus(HWND_DESKTOP, (HWND) mp1);
969 return 0;
970
971 case WM_MOUSEMOVE:
972 WinShowWindow(hwnd, FALSE);
973 break;
974
975 case UM_TIMER:
976 {
977 POINTL ptl;
978
979 WinQueryPointerPos(HWND_DESKTOP, &ptl);
980 if (WinWindowFromPoint(HWND_DESKTOP, &ptl, TRUE) !=
981 WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
982 WinDestroyWindow(hwnd);
983 }
984 return 0;
985
986 case WM_PAINT:
987 {
988 HPS hps;
989 SWP swp;
990 POINTL ptl, aptl[TXTBOX_COUNT];
991 CHAR *s, *p, *pp, *wp;
992 ULONG extra, tlen, y;
993
994 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
995 if (hps) {
996 WinQueryWindowPos(hwnd, &swp);
997 GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
998 GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
999 GpiSetBackMix(hps, BM_LEAVEALONE);
1000 GpiSetMix(hps, FM_OVERPAINT);
1001 ptl.x = ptl.y = 0;
1002 GpiMove(hps, &ptl);
1003 ptl.x = swp.cx - 1;
1004 ptl.y = swp.cy - 1;
1005 GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
1006 tlen = WinQueryWindowTextLength(hwnd);
1007 if (tlen) {
1008 s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
1009 if (s) {
1010 WinQueryWindowText(hwnd, tlen + 1, s);
1011 if (*s) {
1012 p = s;
1013 y = swp.cy - 3;
1014 extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
1015 GpiSetColor(hps, 0);
1016 GpiSetMix(hps, FM_OVERPAINT);
1017 while (p && *p) {
1018 wp = NULL;
1019 pp = strchr(p, '\r');
1020 if (pp) {
1021 wp = pp;
1022 *pp = 0;
1023 pp++;
1024 }
1025 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
1026 ptl.x = 7;
1027 y -= aptl[TXTBOX_TOPLEFT].y;
1028 if (p != s)
1029 y -= extra;
1030 ptl.y = y;
1031 GpiCharStringAt(hps, &ptl, strlen(p), p);
1032 if (wp)
1033 *wp = '\r';
1034 p = pp;
1035 }
1036 }
1037 free(s);
1038 }
1039 }
1040 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
1041 GpiSetColor(hps, CLR_WHITE);
1042 ptl.x = 1;
1043 ptl.y = 1;
1044 GpiMove(hps, &ptl);
1045 ptl.y = swp.cy - 2;
1046 GpiLine(hps, &ptl);
1047 ptl.x = swp.cx - 2;
1048 GpiLine(hps, &ptl);
1049 ptl.x = 2;
1050 ptl.y = 2;
1051 GpiMove(hps, &ptl);
1052 ptl.y = swp.cy - 3;
1053 GpiLine(hps, &ptl);
1054 ptl.x = swp.cx - 3;
1055 GpiLine(hps, &ptl);
1056 GpiSetColor(hps, CLR_BROWN);
1057 ptl.x = 1;
1058 ptl.y = 1;
1059 GpiMove(hps, &ptl);
1060 ptl.x = swp.cx - 2;
1061 GpiLine(hps, &ptl);
1062 ptl.y = swp.cy - 2;
1063 GpiLine(hps, &ptl);
1064 ptl.x = 2;
1065 ptl.y = 2;
1066 GpiMove(hps, &ptl);
1067 ptl.x = swp.cx - 3;
1068 GpiLine(hps, &ptl);
1069 ptl.y = swp.cy - 3;
1070 GpiLine(hps, &ptl);
1071 }
1072 WinEndPaint(hps);
1073 }
1074 }
1075 return 0;
1076
1077 case WM_CLOSE:
1078 WinDestroyWindow(hwnd);
1079 return 0;
1080
1081 case WM_DESTROY:
1082 hwndBubble = (HWND) 0;
1083 break;
1084 }
1085 return PFNWPStatic(hwnd, msg, mp1, mp2);
1086}
1087
1088MRESULT EXPENTRY LEDProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1089{
1090 switch (msg) {
1091 case WM_CREATE:
1092 {
1093 MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2);
1094 HBITMAP hbmold = (HBITMAP) 0;
1095 HPS hps = (HPS) 0;
1096
1097 switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
1098 case MAIN_LED:
1099 hps = WinGetPS(hwnd);
1100 hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
1101 if (!fBlueLED) {
1102 hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
1103 hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
1104 }
1105 else {
1106 hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
1107 hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
1108 }
1109 if (hbmLEDoff && hbmLEDon)
1110 WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
1111 else {
1112 if (hbmLEDoff)
1113 GpiDeleteBitmap(hbmLEDoff);
1114 if (hbmLEDon)
1115 GpiDeleteBitmap(hbmLEDon);
1116 }
1117 if (hbmold &&
1118 hbmLEDon &&
1119 hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
1120 GpiDeleteBitmap(hbmold);
1121 if (hps)
1122 WinReleasePS(hps);
1123 break;
1124 default:
1125 SetPresParams(hwnd,
1126 &RGBGREY,
1127 &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
1128 break;
1129 }
1130 return mr;
1131 }
1132
1133 case WM_SETFOCUS:
1134 if (mp2)
1135 PostMsg(hwnd, UM_FOCUSME, mp1, MPVOID);
1136 break;
1137
1138 case UM_FOCUSME:
1139 WinSetFocus(HWND_DESKTOP, (HWND) mp1);
1140 return 0;
1141
1142 case WM_MOUSEMOVE:
1143 BubbleHelp(hwnd, TRUE, FALSE, FALSE, GetPString(IDS_LEDHELP));
1144 if (!fNoFinger) {
1145 WinSetPointer(HWND_DESKTOP, hptrFinger);
1146 return MRFROMLONG(TRUE);
1147 }
1148 break;
1149
1150 case WM_BUTTON1CLICK:
1151 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
1152 WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
1153 break;
1154
1155 case WM_BUTTON2CLICK:
1156 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
1157 WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
1158 break;
1159
1160 case WM_CHORD:
1161 case WM_BUTTON3CLICK:
1162 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
1163 WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
1164 break;
1165 }
1166 return PFNWPStatic(hwnd, msg, mp1, mp2);
1167}
1168
1169MRESULT EXPENTRY ChildButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1170{
1171 USHORT id;
1172 TOOL *tool;
1173
1174 static HWND hwndMenu = (HWND) 0;
1175
1176 switch (msg) {
1177 case WM_BUTTON1DOWN:
1178 case WM_BUTTON2DOWN:
1179 case WM_BUTTON3DOWN:
1180 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1181 break;
1182
1183 case WM_MOUSEMOVE:
1184 if (fToolbarHelp) {
1185 if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
1186 && !WinQueryCapture(HWND_DESKTOP)) {
1187 id = WinQueryWindowUShort(hwnd, QWS_ID);
1188 tool = find_tool(id);
1189 if (tool && tool->help && *tool->help) {
1190
1191 char s[128];
1192
1193 strcpy(s, tool->help);
1194 if (tool->flags & T_DROPABLE)
1195 strcat(s, GetPString(IDS_DROPONMETEXT));
1196 MakeBubble(hwnd, FALSE, s);
1197 }
1198 }
1199 }
1200 break;
1201
1202 case WM_COMMAND:
1203 switch (SHORT1FROMMP(mp1)) {
1204 case IDM_HELP:
1205 if (hwndHelp)
1206 WinSendMsg(hwndHelp,
1207 HM_DISPLAY_HELP,
1208 MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
1209 break;
1210
1211 case IDM_HIDEANYTOOL: /* hide any tool */
1212 case IDM_HIDETOOL: /* hide tool */
1213 if (SHORT1FROMMP(mp1) == IDM_HIDETOOL)
1214 id = WinQueryWindowUShort(hwnd, QWS_ID);
1215 else
1216 id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
1217 PickToolProc, FM3ModHandle,
1218 PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
1219 if (id) {
1220 tool = find_tool(id);
1221 if (tool) {
1222 tool->flags |= T_INVISIBLE;
1223 save_tools(NULL);
1224 }
1225 }
1226 break;
1227
1228 case IDM_SHOWTOOLS: /* show all tools */
1229 tool = toolhead;
1230 while (tool) {
1231 tool->flags &= (~T_INVISIBLE);
1232 tool = tool->next;
1233 }
1234 save_tools(NULL);
1235 break;
1236
1237 case IDM_DELETEANYTOOL: /* delete any button */
1238 case IDM_DELETETOOL: /* delete button */
1239 if (SHORT1FROMMP(mp1) == IDM_DELETETOOL)
1240 id = WinQueryWindowUShort(hwnd, QWS_ID);
1241 else
1242 id =
1243 (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
1244 PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
1245 if (id)
1246 PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
1247 MPFROM2SHORT(id, 0), MPVOID);
1248 return 0;
1249
1250 case IDM_EDITANYTOOL: /* edit any button */
1251 case IDM_EDITTOOL: /* edit button */
1252 if (SHORT1FROMMP(mp1) == IDM_EDITTOOL)
1253 id = WinQueryWindowUShort(hwnd, QWS_ID);
1254 else
1255 id =
1256 (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
1257 PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
1258 if (id) {
1259 tool = find_tool(id);
1260 if (tool) {
1261 if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
1262 ADDBTN_FRAME, (PVOID) tool))
1263 WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
1264 QW_PARENT),
1265 QW_PARENT), FID_CLIENT),
1266 WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
1267 MPFROM2SHORT(id, 0));
1268 }
1269 }
1270 break;
1271
1272 case IDM_ADDTOOL: /* add tool */
1273 id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
1274 ADDBTN_FRAME, MPVOID);
1275 if (id && id != (USHORT) - 1)
1276 WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
1277 QW_PARENT),
1278 QW_PARENT), FID_CLIENT),
1279 WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
1280 MPFROM2SHORT(id, 0));
1281 break;
1282
1283 case IDM_REORDERTOOLS: /* reorder tools */
1284 WinDlgBox(HWND_DESKTOP,
1285 hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
1286 break;
1287
1288 case IDM_SAVETOOLS:
1289 case IDM_LOADTOOLS:
1290 if (WinDlgBox(HWND_DESKTOP,
1291 hwnd,
1292 ToolIODlgProc,
1293 FM3ModHandle,
1294 SVBTN_FRAME,
1295 (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
1296 "TRUE" : NULL))
1297 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
1298 break;
1299 }
1300 ResizeTools(WinQueryWindow(hwnd, QW_PARENT));
1301 return 0;
1302
1303 case WM_MENUEND:
1304 if (hwndMenu == (HWND) mp2) {
1305 WinDestroyWindow(hwndMenu);
1306 hwndMenu = (HWND) 0;
1307 }
1308 break;
1309
1310 case WM_CONTEXTMENU:
1311 DosEnterCritSec();
1312 if (!hwndMenu)
1313 hwndMenu = WinLoadMenu(hwnd, FM3ModHandle, ID_BUTTONMENU);
1314 DosExitCritSec();
1315 SetPresParams(hwndMenu, NULL, NULL, NULL, GetPString(IDS_10SYSPROTEXT));
1316 if (PopupMenu(hwnd, hwnd, hwndMenu))
1317 WinShowWindow(hwndMenu, TRUE);
1318 return MRFROMSHORT(TRUE);
1319
1320 case DM_DRAGOVER:
1321 {
1322 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
1323
1324 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */
1325 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
1326 id = WinQueryWindowUShort(hwnd, QWS_ID);
1327 tool = find_tool(id);
1328 if (!tool) {
1329 DrgFreeDraginfo(pDInfo);
1330 return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */
1331 }
1332 if (!(tool->flags & T_DROPABLE)) {
1333 DrgFreeDraginfo(pDInfo);
1334 return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */
1335 }
1336 {
1337 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
1338
1339 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
1340 0); /* Index to DRAGITEM */
1341 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
1342 DRM_OS2FILE, /* mechanisms and data */
1343 NULL)) { /* formats */
1344 if (!(tool->flags & T_EMPHASIZED)) {
1345 tool->flags |= T_EMPHASIZED;
1346 DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
1347 DrgFreeDraginfo(pDInfo);
1348 }
1349 return (MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
1350 DO_MOVE)); /* Move operation valid */
1351 }
1352 DrgFreeDraginfo(pDInfo);
1353 }
1354 }
1355 return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */
1356
1357 case DM_DROPHELP:
1358 id = WinQueryWindowUShort(hwnd, QWS_ID);
1359 tool = find_tool(id);
1360 PFNWPButton(hwnd, msg, mp1, mp2);
1361 DropHelp(mp1, mp2, hwnd, GetPString(IDS_TOOLDROPHELP));
1362 return 0;
1363
1364 case DM_DRAGLEAVE:
1365 id = WinQueryWindowUShort(hwnd, QWS_ID);
1366 tool = find_tool(id);
1367 if (tool && (tool->flags & T_DROPABLE)) {
1368 if (tool->flags & T_EMPHASIZED) {
1369 tool->flags &= (~T_EMPHASIZED);
1370 DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
1371 }
1372 }
1373 break;
1374
1375 case DM_DROP:
1376 id = WinQueryWindowUShort(hwnd, QWS_ID);
1377 tool = find_tool(id);
1378 if (tool && (tool->flags & T_DROPABLE) != 0) {
1379 LISTINFO *li;
1380 CNRDRAGINFO cdi;
1381
1382 if (tool->flags & T_EMPHASIZED) {
1383 DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
1384 tool->flags &= (~T_EMPHASIZED);
1385 }
1386 memset(&cdi, 0, sizeof(cdi));
1387 cdi.pDragInfo = mp1;
1388 li = DoFileDrop(hwnd, NULL, FALSE, mp1, MPFROMP(&cdi));
1389 CheckPmDrgLimit(cdi.pDragInfo);
1390 if (li) {
1391 li->type = id;
1392 if (!li->list || !li->list[0])
1393 FreeListInfo(li);
1394 else {
1395 HWND hwndActive;
1396
1397 hwndActive = TopWindow(hwndMain, (HWND) 0);
1398 if (hwndActive) {
1399 if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
1400 FreeListInfo(li);
1401 }
1402 else
1403 FreeListInfo(li);
1404 }
1405 }
1406 }
1407 return 0;
1408
1409 case WM_CLOSE:
1410 WinDestroyWindow(hwnd);
1411 return 0;
1412 }
1413 return PFNWPButton(hwnd, msg, mp1, mp2);
1414}
1415
1416static VOID BuildTools(HWND hwndT, BOOL resize)
1417{
1418 TOOL *tool;
1419 ULONG ctrlxpos = 18L;
1420 CHAR s[33];
1421 HENUM henum;
1422 HWND hwndTool;
1423
1424 henum = WinBeginEnumWindows(hwndT);
1425 while ((hwndTool = WinGetNextWindow(henum)) != NULLHANDLE)
1426 if (!WinDestroyWindow(hwndTool))
1427 Runtime_Error(pszSrcFile, __LINE__, "Unable to destroy toolbar button");
1428 WinEndEnumWindows(henum);
1429 if (!fToolbar) {
1430 load_quicktools();
1431 load_tools(NULL);
1432 return;
1433 }
1434 if (!toolhead)
1435 load_tools(NULL);
1436 tool = toolhead;
1437 while (tool) {
1438 sprintf(s, "#%u", tool->id);
1439 hwndTool = (HWND) 0;
1440 if (!fTextTools) {
1441 if (!(tool->flags & T_MYICON)) {
1442 hwndTool = WinCreateWindow(hwndT,
1443 WC_TOOLBUTTONS,
1444 s,
1445 BS_NOPOINTERFOCUS |
1446 BS_BITMAP | BS_PUSHBUTTON,
1447 ctrlxpos,
1448 14,
1449 32,
1450 32, hwndT, HWND_TOP, tool->id, NULL, NULL);
1451 }
1452 if (!hwndTool) {
1453 HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
1454
1455 if (hbm) {
1456 BTNCDATA btc;
1457
1458 memset(&btc, 0, sizeof(btc));
1459 btc.cb = sizeof(btc);
1460 btc.hImage = hbm;
1461 hwndTool = WinCreateWindow(hwndT,
1462 WC_TOOLBUTTONS,
1463 NullStr,
1464 BS_NOPOINTERFOCUS |
1465 BS_BITMAP | BS_PUSHBUTTON,
1466 ctrlxpos,
1467 14,
1468 32,
1469 32,
1470 hwndT, HWND_TOP, tool->id, &btc, NULL);
1471 if (!hwndTool)
1472 GpiDeleteBitmap(hbm);
1473 }
1474 }
1475 if (hwndTool)
1476 tool->flags &= (~T_TEXT);
1477 }
1478 if (!hwndTool) {
1479 hwndTool = WinCreateWindow(hwndT,
1480 WC_TOOLBUTTONS,
1481 (!tool->text && tool->id >= IDM_COMMANDSTART
1482 && tool->id <
1483 IDM_QUICKTOOLSTART) ? command_title(tool->
1484 id -
1485 IDM_COMMANDSTART)
1486 : tool->text,
1487 BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
1488 2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
1489 NULL);
1490 if (!hwndTool)
1491 Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
1492 IDS_WINCREATEWINDOW);
1493 tool->flags |= T_TEXT;
1494 }
1495 if (fToolTitles && !fTextTools) {
1496 hwndTool = WinCreateWindow(hwndT,
1497 WC_STATIC,
1498 tool->text,
1499 SS_TEXT | DT_LEFT | DT_VCENTER,
1500 ctrlxpos,
1501 1,
1502 32,
1503 10,
1504 hwndT,
1505 HWND_TOP, tool->id + 25000, NULL, NULL);
1506 if (!hwndTool)
1507 Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
1508 IDS_WINCREATEWINDOW);
1509 else {
1510 SetPresParams(hwndTool,
1511 &RGBGREY,
1512 &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
1513 }
1514 }
1515 ctrlxpos += ((tool->flags & T_TEXT) ? 55L : 33L);
1516 SetPresParams(WinWindowFromID(hwndT, tool->id),
1517 NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
1518 tool = tool->next;
1519 } // while tool
1520
1521 hwndTool = WinCreateWindow(hwndT,
1522 WC_BUTTON,
1523 "#6010",
1524 BS_NOPOINTERFOCUS |
1525 BS_BITMAP | BS_PUSHBUTTON,
1526 1,
1527 19,
1528 14,
1529 13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
1530 if (!hwndTool)
1531 Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
1532 IDS_WINCREATEWINDOW);
1533 hwndTool =
1534 WinCreateWindow(hwndT, WC_BUTTON, "#6011",
1535 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
1536 13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
1537 if (!hwndTool)
1538 Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
1539 IDS_WINCREATEWINDOW);
1540 if (resize)
1541 ResizeTools(hwndT);
1542}
1543
1544static MRESULT EXPENTRY CommandLineProc(HWND hwnd, ULONG msg, MPARAM mp1,
1545 MPARAM mp2)
1546{
1547 PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
1548 static BOOL lbup = FALSE;
1549
1550 switch (msg) {
1551 case UM_FOCUSME:
1552 WinSetFocus(HWND_DESKTOP, hwnd);
1553 return 0;
1554
1555 case WM_SETFOCUS:
1556 if (!mp2 && !lbup) {
1557
1558 PID pid;
1559 TID tid;
1560
1561 if (WinQueryWindowUShort((HWND) mp1, QWS_ID) == COMMAND_BUTTON)
1562 break;
1563 if (!WinQueryWindowProcess((HWND) mp1, &pid, &tid) || pid == mypid)
1564 WinDestroyWindow(hwnd);
1565 }
1566 break;
1567
1568 case UM_RESCAN:
1569 {
1570 PSZ pszCmdLine;
1571
1572 pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1573 if (pszCmdLine) {
1574 lbup = TRUE;
1575 if (WinDlgBox(HWND_DESKTOP,
1576 hwnd,
1577 CmdLine2DlgProc,
1578 FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) {
1579 lstrip(pszCmdLine);
1580 WinSetWindowText(hwnd, pszCmdLine);
1581 }
1582 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
1583 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
1584 free(pszCmdLine);
1585 }
1586 }
1587 return 0;
1588
1589 case UM_SETUP:
1590 lbup = FALSE;
1591 return 0;
1592
1593 case WM_BUTTON1DBLCLK:
1594 PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
1595 return 0;
1596
1597 case WM_COMMAND:
1598 switch (SHORT1FROMMP(mp1)) {
1599 case COMMAND_BUTTON:
1600 if (!lbup)
1601 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1602 break;
1603 }
1604 return 0;
1605
1606 case UM_OPENWINDOWFORME:
1607 {
1608 static char directory[CCHMAXPATH], cl[1000];
1609 char **list = NULL;
1610 ULONG len;
1611 HWND hwndCnr;
1612
1613 *directory = *cl = 0;
1614 strcpy(cl, GetCmdSpec(FALSE));
1615 strcat(cl, " /C ");
1616 len = strlen(cl);
1617 WinQueryWindowText(hwnd, 1000 - len, cl + len);
1618 bstrip(cl + len);
1619 if (strlen(cl) > len) {
1620 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
1621 UM_SETUP, MPFROMP(cl + len), MPVOID);
1622 WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
1623 bstrip(directory);
1624 if (*directory && (IsRoot(directory) || !IsFile(directory))) {
1625 if (!FM2Command(directory, cl + len)) {
1626 hwndCnr = TopWindow(hwndMain, (HWND) 0);
1627 if (hwndCnr) {
1628 hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
1629 if (hwndCnr) {
1630 hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
1631 if (hwndCnr)
1632 list = BuildList(hwndCnr);
1633 }
1634 }
1635 WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
1636 if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
1637 save_cmdlines(FALSE);
1638 ExecOnList(hwndCnr,
1639 cl,
1640 WINDOWED | ((fKeepCmdLine) ?
1641 SEPARATEKEEP : SEPARATE),
1642 directory, list, NULL, pszSrcFile, __LINE__);
1643 xfree(list, pszSrcFile, __LINE__);
1644 WinDestroyWindow(hwnd);
1645 break;
1646 }
1647 }
1648 }
1649 WinSendMsg(hwnd, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
1650 }
1651 return 0;
1652
1653 case WM_CHAR:
1654 if (!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) {
1655 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1656 if ((SHORT1FROMMP(mp2) & 255) == '\r')
1657 PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
1658 else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
1659 WinDestroyWindow(hwnd);
1660 else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
1661 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1662 }
1663 }
1664 else if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
1665 ((SHORT2FROMMP(mp2) == VK_UP ||
1666 SHORT2FROMMP(mp2) == VK_DOWN) ||
1667 (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
1668 return 0;
1669 break;
1670
1671 case WM_DESTROY:
1672 PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_RESCAN, MPVOID, MPVOID);
1673 lbup = FALSE;
1674 break;
1675 }
1676 return oldproc(hwnd, msg, mp1, mp2);
1677}
1678
1679MRESULT EXPENTRY DriveBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1680{
1681 switch (msg) {
1682 case WM_CREATE:
1683 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
1684 break;
1685
1686 case UM_SETUP:
1687 {
1688 RGB2 rgb;
1689
1690 memset(&rgb, 0, sizeof(rgb));
1691 rgb.bRed = (BYTE)128;
1692 SetPresParams(hwnd,
1693 &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
1694 SetTargetDir(hwnd, TRUE);
1695 }
1696 return 0;
1697
1698 case WM_SETFOCUS:
1699 case UM_FOCUSME:
1700 case WM_BUTTON1DOWN:
1701 case WM_BUTTON1UP:
1702 case WM_BUTTON2DOWN:
1703 case WM_BUTTON2UP:
1704 case WM_BUTTON3DOWN:
1705 case WM_BUTTON3UP:
1706 return CommonTextButton(hwnd, msg, mp1, mp2);
1707
1708 case WM_MOUSEMOVE:
1709 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1710 break;
1711
1712 case UM_CLICKED:
1713 case UM_CLICKED3:
1714 PostMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_SETTARGET, 0), MPVOID);
1715 return 0;
1716
1717 case WM_CHAR:
1718 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1719 break;
1720
1721 case WM_CONTROLPOINTER:
1722 if (!fNoFinger &&
1723 (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
1724 SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
1725 return MRFROMLONG(hptrFinger);
1726 break;
1727
1728 case WM_COMMAND:
1729 {
1730 CHAR dv[4];
1731
1732 *dv = 0;
1733 WinQueryWindowText(WinWindowFromID(hwnd, SHORT1FROMMP(mp1) + 50),
1734 2, dv);
1735 if (isalpha(*dv)) {
1736
1737 HWND hwndActive;
1738
1739 dv[1] = ':';
1740 dv[2] = '\\';
1741 dv[3] = 0;
1742 hwndActive = TopWindow(hwnd, (HWND) 0);
1743 if (hwndActive)
1744 WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
1745 UM_DRIVECMD, MPFROMP(dv), MPVOID);
1746 }
1747 }
1748 return 0;
1749
1750 case WM_PAINT:
1751 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
1752 break;
1753
1754 case WM_CLOSE:
1755 WinDestroyWindow(hwnd);
1756 return 0;
1757 }
1758 return PFNWPStatic(hwnd, msg, mp1, mp2);
1759}
1760
1761MRESULT EXPENTRY DriveProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1762{
1763 USHORT id;
1764 CHAR szDrv[CCHMAXPATH];
1765
1766 static BOOL emphasized = FALSE;
1767 static HWND hwndMenu = NULLHANDLE;
1768 static USHORT helpid = 0;
1769
1770 switch (msg) {
1771 case WM_MOUSEMOVE:
1772 if (fDrivebarHelp &&
1773 (!hwndBubble ||
1774 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
1775 !WinQueryCapture(HWND_DESKTOP)) {
1776 id = WinQueryWindowUShort(hwnd, QWS_ID);
1777 if (helpid != id) {
1778 helpid = id;
1779 PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
1780 }
1781 else
1782 helpid = 0;
1783 }
1784 break;
1785
1786 case UM_SETUP6:
1787 if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) {
1788 if ((char *)mp1 &&
1789 (!hwndBubble ||
1790 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
1791 !WinQueryCapture(HWND_DESKTOP)) {
1792
1793 RECTL rcl;
1794 POINTL ptl;
1795
1796 WinQueryPointerPos(HWND_DESKTOP, &ptl);
1797 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
1798 WinQueryWindowRect(hwnd, &rcl);
1799 if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
1800 BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
1801 }
1802 }
1803 return 0;
1804
1805 case WM_MENUEND:
1806 if (hwndMenu == (HWND) mp2) {
1807 WinDestroyWindow(hwndMenu);
1808 hwndMenu = (HWND) 0;
1809 }
1810 break;
1811
1812 case WM_CONTEXTMENU:
1813 if (hwndMenu)
1814 WinDestroyWindow(hwndMenu);
1815 hwndMenu = (HWND) 0;
1816 id = WinQueryWindowUShort(hwnd, QWS_ID);
1817 *szDrv = 0;
1818 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1819 id + 50), sizeof(szDrv), szDrv);
1820 if (isalpha(*szDrv)) {
1821 hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES);
1822 if (hwndMenu) {
1823 BOOL rdy;
1824 CHAR chDrv = *szDrv;
1825 UINT iDrv;
1826
1827 strcpy(szDrv + 2, "\\");
1828 MakeValidDir(szDrv);
1829 // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
1830 rdy = toupper(*szDrv) == toupper(chDrv);
1831 iDrv = toupper(*szDrv) - 'A';
1832 if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
1833 WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
1834
1835 if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
1836 WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
1837 WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
1838 WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
1839 WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
1840 }
1841 if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
1842 WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
1843 WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
1844 WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
1845 }
1846 if (!rdy) {
1847 WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
1848 WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
1849 WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
1850 WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
1851 WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
1852 }
1853 /* fixme to be gone?
1854 if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
1855 WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
1856 }
1857 */
1858 PopupMenu(hwnd, hwnd, hwndMenu);
1859 }
1860 }
1861 return MRFROMSHORT(TRUE);
1862
1863 case WM_BUTTON2CLICK:
1864 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1865 if (!(shiftstate & KC_CTRL))
1866 break;
1867
1868 case WM_CHORD:
1869 case WM_BUTTON3CLICK:
1870 id = WinQueryWindowUShort(hwnd, QWS_ID);
1871 *szDrv = 0;
1872 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1873 id + 50), sizeof(szDrv), szDrv);
1874 if (isalpha(*szDrv)) {
1875 strcat(szDrv, "\\");
1876 if (!FindDirCnrByName(szDrv, TRUE))
1877 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
1878 }
1879 break;
1880
1881 case WM_COMMAND:
1882 PostMsg(hwnd, UM_COMMAND, mp1, mp2);
1883 return 0;
1884
1885 case UM_COMMAND:
1886 id = WinQueryWindowUShort(hwnd, QWS_ID);
1887 *szDrv = 0;
1888 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1889 id + 50), sizeof(szDrv), szDrv);
1890 if (isalpha(*szDrv)) {
1891 strcat(szDrv, "\\");
1892 CommonDriveCmd(hwnd, szDrv, SHORT1FROMMP(mp1));
1893 }
1894 return 0;
1895
1896 case DM_DRAGOVER:
1897 id = WinQueryWindowUShort(hwnd, QWS_ID);
1898 *szDrv = 0;
1899 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1900 id + 50), sizeof(szDrv), szDrv);
1901 if (isalpha(*szDrv) &&
1902 !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
1903 if (!emphasized) {
1904 emphasized = TRUE;
1905 DrawTargetEmphasis(hwnd, emphasized);
1906 }
1907 if (AcceptOneDrop(hwnd, mp1, mp2))
1908 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
1909 return MRFROM2SHORT(DOR_NEVERDROP, 0);
1910 }
1911 break;
1912
1913 case DM_DRAGLEAVE:
1914 id = WinQueryWindowUShort(hwnd, QWS_ID);
1915 *szDrv = 0;
1916 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1917 id + 50), sizeof(szDrv), szDrv);
1918 if (isalpha(*szDrv) &&
1919 !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
1920 if (emphasized) {
1921 emphasized = FALSE;
1922 DrawTargetEmphasis(hwnd, emphasized);
1923 }
1924 }
1925 break;
1926
1927 case DM_DROPHELP:
1928 id = WinQueryWindowUShort(hwnd, QWS_ID);
1929 *szDrv = 0;
1930 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1931 id + 50), sizeof(szDrv), szDrv);
1932 if (isalpha(*szDrv) &&
1933 !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
1934 DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP));
1935 return 0;
1936 }
1937 break;
1938
1939 case DM_DROP:
1940 id = WinQueryWindowUShort(hwnd, QWS_ID);
1941 *szDrv = 0;
1942 WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1943 id + 50), sizeof(szDrv), szDrv);
1944 if (isalpha(*szDrv) &&
1945 !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
1946
1947 CNRDRAGINFO cnd;
1948 LISTINFO *li;
1949 ULONG action = UM_ACTION;
1950
1951 if (emphasized) {
1952 emphasized = FALSE;
1953 DrawTargetEmphasis(hwnd, emphasized);
1954 }
1955 memset(&cnd, 0, sizeof(cnd));
1956 cnd.pDragInfo = (PDRAGINFO) mp1;
1957 cnd.pRecord = NULL;
1958 li = DoFileDrop(hwnd,
1959 NULL,
1960 TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
1961 CheckPmDrgLimit(cnd.pDragInfo);
1962 if (li) {
1963 strcpy(li->targetpath, szDrv);
1964 strcat(li->targetpath, "\\");
1965 if (li->list && li->list[0] && IsRoot(li->list[0]))
1966 li->type = DO_LINK;
1967 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
1968
1969 CHECKLIST cl;
1970
1971 memset(&cl, 0, sizeof(cl));
1972 cl.size = sizeof(cl);
1973 cl.flags = li->type;
1974 cl.list = li->list;
1975 cl.cmd = li->type;
1976 cl.prompt = li->targetpath;
1977 li->type = WinDlgBox(HWND_DESKTOP,
1978 hwndMain,
1979 DropListProc,
1980 FM3ModHandle, DND_FRAME, MPFROMP(&cl));
1981 if (li->type == DID_ERROR)
1982 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
1983 "Drag & Drop Dialog");
1984 if (!li->type) {
1985 FreeListInfo(li);
1986 return 0;
1987 }
1988 li->list = cl.list;
1989 if (!li->list || !li->list[0]) {
1990 FreeListInfo(li);
1991 return 0;
1992 }
1993 }
1994 else {
1995 if (!WinDlgBox(HWND_DESKTOP,
1996 hwndMain,
1997 WalkDlgProc,
1998 FM3ModHandle,
1999 WALK_FRAME,
2000 MPFROMP(li->targetpath)) || !*li->targetpath) {
2001 FreeListInfo(li);
2002 return 0;
2003 }
2004 }
2005 switch (li->type) {
2006 case DND_LAUNCH:
2007 strcat(li->targetpath, " %a");
2008 ExecOnList(hwndMain,
2009 li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
2010 pszSrcFile, __LINE__);
2011 FreeList(li->list);
2012 li->list = NULL;
2013 break;
2014 case DO_LINK:
2015 if (fLinkSetsIcon) {
2016 li->type = IDM_SETICON;
2017 action = UM_MASSACTION;
2018 }
2019 else
2020 li->type = IDM_COMPARE;
2021 break;
2022 case DND_EXTRACT:
2023 if (*li->targetpath && !IsFile(li->targetpath))
2024 li->type = IDM_EXTRACT;
2025 break;
2026 case DND_MOVE:
2027 li->type = IDM_MOVE;
2028 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2029 action = UM_MASSACTION;
2030 li->type = IDM_ARCHIVEM;
2031 }
2032 break;
2033 case DND_WILDMOVE:
2034 li->type = IDM_WILDMOVE;
2035 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2036 action = UM_MASSACTION;
2037 li->type = IDM_ARCHIVEM;
2038 }
2039 break;
2040 case DND_OBJECT:
2041 li->type = IDM_OBJECT;
2042 action = UM_MASSACTION;
2043 break;
2044 case DND_SHADOW:
2045 li->type = IDM_SHADOW;
2046 action = UM_MASSACTION;
2047 break;
2048 case DND_COMPARE:
2049 li->type = IDM_COMPARE;
2050 break;
2051 case DND_SETICON:
2052 action = UM_MASSACTION;
2053 li->type = IDM_SETICON;
2054 break;
2055 case DND_COPY:
2056 li->type = IDM_COPY;
2057 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2058 action = UM_MASSACTION;
2059 li->type = IDM_ARCHIVE;
2060 }
2061 break;
2062 case DND_WILDCOPY:
2063 li->type = IDM_WILDCOPY;
2064 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2065 action = UM_MASSACTION;
2066 li->type = IDM_ARCHIVE;
2067 }
2068 break;
2069 default:
2070 if (*li->arcname && li->info) {
2071 action = UM_MASSACTION;
2072 li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
2073 IDM_FAKEEXTRACT;
2074 }
2075 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2076 action = UM_MASSACTION;
2077 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2078 }
2079 else
2080 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2081 break;
2082 }
2083 if (!li->list || !li->list[0])
2084 FreeListInfo(li);
2085 else
2086 WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
2087 }
2088 return 0;
2089 }
2090 break;
2091
2092 case WM_DESTROY:
2093 if (hwndMenu)
2094 WinDestroyWindow(hwndMenu);
2095 hwndMenu = (HWND) 0;
2096 break;
2097 }
2098 return PFNWPButton(hwnd, msg, mp1, mp2);
2099}
2100
2101VOID BuildDriveBarButtons(HWND hwndT)
2102{
2103 register ULONG x, y = 0;
2104 ULONG ulDriveNum, ulDriveMap, iconid;
2105 CHAR s[8];
2106 HENUM henum;
2107 HWND hwndB;
2108
2109 henum = WinBeginEnumWindows(hwndT);
2110
2111 while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE)
2112 WinDestroyWindow(hwndB);
2113
2114 WinEndEnumWindows(henum);
2115 if (fDrivebar) {
2116 DosError(FERR_DISABLEHARDERR);
2117 DosQCurDisk(&ulDriveNum, &ulDriveMap);
2118 for (x = 0; x < 26; x++) {
2119 if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
2120 if (x > 1) {
2121 if (driveflags[x] & DRIVE_CDROM)
2122 iconid = CDROM_ICON;
2123 else
2124 iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
2125 REMOVABLE_ICON :
2126 (driveflags[x] & DRIVE_VIRTUAL) ?
2127 VIRTUAL_ICON :
2128 (driveflags[x] & DRIVE_REMOTE) ?
2129 REMOTE_ICON :
2130 (driveflags[x] & DRIVE_RAMDISK) ?
2131 RAMDISK_ICON :
2132 (driveflags[x] & DRIVE_ZIPSTREAM) ?
2133 ZIPSTREAM_ICON :DRIVE_ICON;
2134 }
2135 else
2136 iconid = FLOPPY_ICON;
2137 sprintf(s, "#%lu", iconid);
2138 hwndB = WinCreateWindow(hwndT,
2139 WC_DRIVEBUTTONS,
2140 s,
2141 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
2142 0,
2143 0,
2144 28,
2145 18,
2146 hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
2147 if (!hwndB)
2148 Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
2149 IDS_WINCREATEWINDOW);
2150 else {
2151 WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
2152 sprintf(s, "%c:", (CHAR) x + 'A');
2153 hwndB = WinCreateWindow(hwndT,
2154 WC_STATIC,
2155 s,
2156 SS_TEXT | DT_LEFT | DT_VCENTER,
2157 0,
2158 0,
2159 10,
2160 18,
2161 hwndT,
2162 HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
2163 if (!hwndB)
2164 Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
2165 IDS_WINCREATEWINDOW);
2166 else {
2167 SetPresParams(hwndB,
2168 &RGBGREY,
2169 &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
2170 WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
2171 }
2172 y++;
2173 }
2174 }
2175 } // for
2176 } // if drivebar
2177 PostMsg(WinQueryWindow(hwndT, QW_PARENT),
2178 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
2179}
2180
2181VOID ResizeDrives(HWND hwndT, long xwidth)
2182{
2183 register ULONG ctrlxpos = 2, ctrlypos = 0, ctrlxsize;
2184 HENUM henum;
2185 HWND hwndB;
2186 RECTL rcl;
2187
2188 DriveLines = 0;
2189 if (!fDrivebar)
2190 return;
2191 if (!xwidth) {
2192 WinQueryWindowRect(hwndT, &rcl);
2193 xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP,
2194 SV_CYSIZEBORDER) * 2) + 2);
2195 }
2196 henum = WinBeginEnumWindows(hwndT);
2197 while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) {
2198 if (WinQueryWindowUShort(hwndB, QWS_ID) > IDM_DRIVEA + 27)
2199 ctrlxsize = 10;
2200 else
2201 ctrlxsize = 28;
2202 WinSetWindowPos(hwndB,
2203 HWND_TOP,
2204 ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
2205 ctrlxpos += (ctrlxsize + 2);
2206 if (ctrlxsize == 10) {
2207 if (ctrlxpos + (42 + ((fShowTarget && DriveLines == 0) ?
2208 256 : 0)) > xwidth) {
2209 ctrlxpos = 2;
2210 ctrlypos += 18;
2211 DriveLines++;
2212 }
2213 }
2214 }
2215 if (ctrlxpos == 2 && DriveLines)
2216 DriveLines--;
2217}
2218
2219MRESULT EXPENTRY StatusProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2220{
2221 static HWND hwndE = (HWND) 0, hwndB = (HWND) 0;
2222 static CHAR lastcmd[1024] = "";
2223
2224 switch (msg) {
2225 case WM_CREATE:
2226 {
2227 MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2);
2228
2229 SetPresParams(hwnd,
2230 &RGBGREY,
2231 &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
2232 return mr;
2233 }
2234
2235 case WM_PRESPARAMCHANGED:
2236 if (fRunning) {
2237
2238 ULONG AttrFound, AttrValue[64], cbRetLen;
2239
2240 cbRetLen = WinQueryPresParam(hwnd,
2241 (ULONG) mp1,
2242 0,
2243 &AttrFound,
2244 (ULONG) sizeof(AttrValue), &AttrValue, 0);
2245 if (cbRetLen) {
2246 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
2247 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
2248 }
2249 }
2250 break;
2251
2252 case WM_CONTEXTMENU:
2253 PostMsg(hwndMain, UM_CONTEXTMENU, MPVOID, MPVOID);
2254 return MRFROMSHORT(TRUE);
2255
2256 case WM_BEGINDRAG:
2257 if (hwndTree) {
2258
2259 SWP swp;
2260 ULONG fl = SWP_ACTIVATE | SWP_SHOW | SWP_ZORDER;
2261
2262 WinQueryWindowPos(hwndTree, &swp);
2263 if (!(swp.fl & SWP_MAXIMIZE))
2264 fl |= SWP_RESTORE;
2265 WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl);
2266 }
2267 break;
2268
2269 case UM_SETUP:
2270 if (mp1)
2271 strcpy(lastcmd, (CHAR *)mp1);
2272 return 0;
2273
2274 case UM_RESCAN:
2275 if (hwndE && WinIsWindow(WinQueryAnchorBlock(hwnd), hwndE))
2276 WinDestroyWindow(hwndE);
2277 if (hwndB && WinIsWindow(WinQueryAnchorBlock(hwnd), hwndB))
2278 WinDestroyWindow(hwndB);
2279 hwndE = hwndB = (HWND) 0;
2280 return 0;
2281
2282 case WM_COMMAND:
2283 switch (SHORT1FROMMP(mp1)) {
2284 case COMMAND_BUTTON:
2285 PostMsg(hwndE, msg, mp1, mp2);
2286 break;
2287 }
2288 return 0;
2289
2290 case WM_MOUSEMOVE:
2291 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
2292 {
2293 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
2294 char *s = NULL;
2295
2296 if (fOtherHelp) {
2297 if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
2298 && !WinQueryCapture(HWND_DESKTOP)) {
2299 switch (id) {
2300 case IDM_ATTRS:
2301 if (WinQueryWindowTextLength(hwnd))
2302 s = GetPString(IDS_ATTRSBUTTONHELP);
2303 break;
2304 case IDM_INFO:
2305 if (WinQueryWindowTextLength(hwnd))
2306 s = GetPString(IDS_INFOBUTTONHELP);
2307 break;
2308 case IDM_RENAME:
2309 if (WinQueryWindowTextLength(hwnd))
2310 s = GetPString(IDS_NAMEBUTTONHELP);
2311 break;
2312 case MAIN_STATUS2:
2313 if (!hwndE)
2314 s = GetPString(IDS_STATUS2HELP);
2315 break;
2316 default:
2317 break;
2318 }
2319 if (s)
2320 MakeBubble(hwnd, FALSE, s);
2321 else if (hwndBubble)
2322 WinDestroyWindow(hwndBubble);
2323 }
2324 }
2325 switch (id) {
2326 case IDM_ATTRS:
2327 case IDM_INFO:
2328 case IDM_RENAME:
2329 case MAIN_STATUS2:
2330 return CommonTextProc(hwnd, msg, mp1, mp2);
2331 default:
2332 break;
2333 }
2334 }
2335 break;
2336
2337 case WM_BUTTON2DOWN:
2338 case WM_BUTTON2UP:
2339 case UM_FOCUSME:
2340 return CommonTextButton(hwnd, msg, mp1, mp2);
2341
2342 case WM_BUTTON1DOWN:
2343 case WM_BUTTON1UP:
2344 case WM_BUTTON3DOWN:
2345 case WM_BUTTON3UP:
2346 {
2347 USHORT id;
2348
2349 id = WinQueryWindowUShort(hwnd, QWS_ID);
2350 switch (id) {
2351 case IDM_ATTRS:
2352 case IDM_INFO:
2353 case IDM_RENAME:
2354 case MAIN_STATUS2:
2355 return CommonTextButton(hwnd, msg, mp1, mp2);
2356 default:
2357 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
2358 break;
2359 }
2360 }
2361 break;
2362
2363 case WM_SETFOCUS:
2364 if (mp2) {
2365
2366 USHORT id;
2367
2368 id = WinQueryWindowUShort(hwnd, QWS_ID);
2369 if (id == MAIN_STATUS2 && hwndE)
2370 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2371 else
2372 return CommonTextButton(hwnd, msg, mp1, mp2);
2373 }
2374 break;
2375
2376 case WM_BUTTON1CLICK:
2377 {
2378 USHORT id;
2379
2380 id = WinQueryWindowUShort(hwnd, QWS_ID);
2381 if (id == MAIN_STATUS) {
2382 if (SHORT2FROMMP(mp2) & KC_CTRL)
2383 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2384 FID_CLIENT),
2385 WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
2386 else if (hwndTree)
2387 PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
2388 }
2389 }
2390 break;
2391
2392 case UM_CLICKED:
2393 case UM_CLICKED3:
2394 {
2395 USHORT id;
2396
2397 id = WinQueryWindowUShort(hwnd, QWS_ID);
2398 if (id == MAIN_STATUS2 && !hwndE) {
2399
2400 SWP swp;
2401 CHAR directory[CCHMAXPATH];
2402 PFNWP oldproce;
2403
2404 *directory = 0;
2405 TopWindowName(hwndMain, (HWND) 0, directory);
2406 WinQueryWindowPos(hwnd, &swp);
2407 hwndB = WinCreateWindow(hwnd,
2408 WC_BUTTON,
2409 "+",
2410 WS_VISIBLE | BS_PUSHBUTTON |
2411 BS_NOPOINTERFOCUS,
2412 swp.cx - swp.cy,
2413 0,
2414 swp.cy,
2415 swp.cy,
2416 hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
2417 if (!hwndB)
2418 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
2419 hwndE = WinCreateWindow(hwnd,
2420 WC_ENTRYFIELD,
2421 NULL,
2422 WS_VISIBLE | ES_AUTOSCROLL,
2423 0,
2424 0,
2425 swp.cx - swp.cy,
2426 swp.cy,
2427 hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
2428 if (!hwndE)
2429 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
2430 if (!hwndE || !hwndB) {
2431 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2432 return 0;
2433 }
2434 WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
2435 WinSetWindowText(hwndStatus, directory);
2436 if (*lastcmd)
2437 WinSetWindowText(hwndE, lastcmd);
2438 else
2439 WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
2440 oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
2441 if (oldproce)
2442 WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
2443 PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
2444 PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
2445 return 0;
2446 }
2447 if (msg == UM_CLICKED3 || (SHORT2FROMMP(mp2) & KC_CTRL)) {
2448 switch (id) {
2449 case IDM_ATTRS:
2450 id = IDM_SORTSIZE;
2451 break;
2452 case IDM_INFO:
2453 id = IDM_SORTLWDATE;
2454 break;
2455 case IDM_RENAME:
2456 id = IDM_SORTFILENAME;
2457 break;
2458 }
2459 }
2460 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
2461 WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
2462 }
2463 return 0;
2464
2465 case WM_PAINT:
2466 {
2467 USHORT id;
2468
2469 id = WinQueryWindowUShort(hwnd, QWS_ID);
2470 switch (id) {
2471 case IDM_ATTRS:
2472 case IDM_INFO:
2473 case IDM_RENAME:
2474 case MAIN_STATUS2:
2475 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
2476 break;
2477 default:
2478 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
2479 break;
2480 }
2481 if (id == IDM_RENAME) {
2482
2483 HPS hps;
2484
2485 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
2486 if (hps) {
2487 PaintSTextWindow(hwnd, hps);
2488 WinEndPaint(hps);
2489 }
2490 return 0;
2491 }
2492 }
2493 break;
2494
2495 }
2496 return PFNWPStatic(hwnd, msg, mp1, mp2);
2497}
2498
2499MRESULT EXPENTRY ToolBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2500{
2501 switch (msg) {
2502 case WM_CREATE:
2503 hwndToolback = hwnd;
2504 RestorePresParams(hwnd, "ToolBar");
2505 break;
2506
2507 case WM_MOUSEMOVE:
2508 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
2509 break;
2510
2511 case WM_CONTROLPOINTER:
2512 if (!fNoFinger && SHORT1FROMMP(mp1) < 25000)
2513 return MRFROMLONG(hptrFinger);
2514 break;
2515
2516 case WM_CHAR:
2517 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
2518 break;
2519
2520 case WM_COMMAND:
2521 case UM_COMMAND:
2522 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2523 FID_CLIENT), msg, mp1, mp2);
2524
2525 case WM_PAINT:
2526
2527 PaintRecessedWindow(hwnd, (HPS)0, TRUE, FALSE);
2528
2529 {
2530 HPS hps;
2531 RECTL rcl;
2532 ULONG lColor = NULL;
2533
2534 hps = WinBeginPaint(hwnd, (HPS)0, NULL);
2535 if (hps) {
2536 GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
2537 WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
2538 sizeof(lColor), &lColor, 0);
2539 if (!lColor)
2540 lColor = CLR_PALEGRAY;
2541 WinQueryWindowRect(hwnd, &rcl);
2542 WinFillRect(hps, &rcl, lColor);
2543 WinEndPaint(hps);
2544 }
2545
2546 }
2547 break;
2548
2549 case WM_PRESPARAMCHANGED:
2550 PresParamChanged(hwnd, "ToolBar", mp1, mp2);
2551 WinInvalidateRect(hwnd, NULL, TRUE);
2552 break;
2553
2554 case UM_SETUP:
2555 {
2556 USHORT id;
2557 TOOL *tool;
2558
2559 id = SHORT1FROMMP(mp1);
2560 tool = find_tool(id);
2561 if (tool) {
2562 del_tool(tool);
2563 WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
2564 if (fToolTitles)
2565 WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
2566 ResizeTools(hwnd);
2567 save_tools(NULL);
2568 }
2569 }
2570 return 0;
2571
2572 case UM_SETUP2: /* Used to load a new a toolbar */
2573 BuildTools(hwnd, TRUE);
2574 return 0;
2575
2576 case WM_CHORD:
2577 {
2578 USHORT id;
2579
2580 id = (USHORT) WinDlgBox(HWND_DESKTOP,
2581 hwnd,
2582 AddToolProc,
2583 FM3ModHandle, ADDBTN_FRAME, MPVOID);
2584 if (id && id != (USHORT) - 1)
2585 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2586 FID_CLIENT),
2587 WM_COMMAND,
2588 MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
2589 }
2590 break;
2591
2592 case WM_CONTEXTMENU:
2593 if (WinDlgBox(HWND_DESKTOP,
2594 hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
2595 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
2596 return MRFROMSHORT(TRUE);
2597
2598 case WM_CLOSE:
2599 WinDestroyWindow(hwnd);
2600 return 0;
2601
2602 case WM_DESTROY:
2603 break;
2604 }
2605 return WinDefWindowProc(hwnd, msg, mp1, mp2);
2606}
2607
2608static VOID AdjustSizeOfClient(PSWP pswp, PRECTL prectl)
2609{
2610 SWP swp;
2611 RECTL rectl;
2612
2613 if (fFreeTree)
2614 return;
2615 if (pswp) {
2616 if (WinQueryWindowPos(hwndTree, &swp) &&
2617 !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
2618 pswp->x = swp.cx;
2619 pswp->cx -= swp.cx;
2620 }
2621 }
2622 if (prectl) {
2623 if (WinQueryWindowPos(hwndTree, &swp) &&
2624 !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
2625 WinQueryWindowRect(hwndTree, &rectl)) {
2626 prectl->xLeft = rectl.xRight;
2627 prectl->xRight -= rectl.xRight;
2628 }
2629 }
2630}
2631
2632VOID FillClient(HWND hwndClient, PSWP pswp, PRECTL prectl, BOOL avoidtree)
2633{
2634 ULONG adjust;
2635
2636 adjust = WinQuerySysValue(HWND_DESKTOP, SV_CYICON);
2637 if (pswp)
2638 WinQueryWindowPos(hwndClient, pswp);
2639 if (prectl)
2640 WinQueryWindowRect(hwndClient, prectl);
2641 if (avoidtree && !fFreeTree)
2642 AdjustSizeOfClient(pswp, prectl);
2643 if (prectl)
2644 prectl->yBottom += adjust;
2645 if (pswp) {
2646 if (!avoidtree || fFreeTree)
2647 pswp->x = 0;
2648 pswp->y = adjust;
2649 if (pswp->cy >= adjust)
2650 pswp->cy -= adjust;
2651 else
2652 pswp->cy = 0;
2653 }
2654}
2655
2656static VOID MoveChildrenAwayFromTree(HWND hwndClient)
2657{
2658 SWP swpC, swpT, swp;
2659 USHORT id;
2660 HWND hwndChild;
2661 HENUM henum;
2662
2663 if (fFreeTree)
2664 return;
2665 WinQueryWindowPos(hwndClient, &swpC);
2666 if (swpC.fl & (SWP_MINIMIZE | SWP_HIDE))
2667 return;
2668 WinQueryWindowPos(hwndTree, &swpT);
2669 henum = WinBeginEnumWindows(hwndClient);
2670 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2671 id = WinQueryWindowUShort(hwndChild, QWS_ID);
2672 if (!id || id == TREE_FRAME)
2673 continue;
2674 WinQueryWindowPos(hwndChild, &swp);
2675 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
2676 if (swp.x < swpT.cx) {
2677 swp.x = swpT.cx;
2678 if (swp.x + swp.cx > swpC.cx)
2679 swp.cx = swpC.cx - swp.x;
2680 if (swp.cx > 24)
2681 WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
2682 SWP_SIZE | SWP_MOVE | SWP_SHOW);
2683 }
2684 }
2685 }
2686 WinEndEnumWindows(henum);
2687}
2688
2689static VOID ArrangeIcons(HWND hwndClient)
2690{
2691 HENUM henum;
2692 HWND hwndChild;
2693 SWP swp;
2694
2695 henum = WinBeginEnumWindows(hwndClient);
2696 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2697 WinQueryWindowPos(hwndChild, &swp);
2698 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
2699 WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
2700 WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
2701 WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
2702 SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
2703 }
2704 }
2705 WinEndEnumWindows(henum);
2706}
2707
2708static VOID NextChild(HWND hwndClient, BOOL previous)
2709{
2710 HENUM henum;
2711 HWND hwndActive, hwndNext, hwndPrev = (HWND) 0;
2712 BOOL next = FALSE, once = FALSE;
2713
2714 previous = !previous;
2715
2716 hwndActive = WinQueryActiveWindow(hwndClient);
2717 if (!hwndActive)
2718 next = TRUE;
2719 henum = WinBeginEnumWindows(hwndClient);
2720 for (;;) {
2721 hwndNext = WinGetNextWindow(henum);
2722 if (hwndNext) {
2723 if (!WinQueryWindowUShort(hwndNext, QWS_ID))
2724 continue;
2725 if (next)
2726 break;
2727 if (hwndNext == hwndActive) {
2728 if (!previous && hwndPrev) {
2729 hwndNext = hwndPrev;
2730 break;
2731 }
2732 else if (previous)
2733 next = TRUE;
2734 }
2735 hwndPrev = hwndNext;
2736 }
2737 else {
2738 if ((!next && previous) || once)
2739 break;
2740 else if (!previous) {
2741 hwndNext = hwndPrev;
2742 break;
2743 }
2744 else
2745 once = next = TRUE;
2746 }
2747 }
2748 WinEndEnumWindows(henum);
2749
2750 if (hwndNext && hwndNext != hwndActive) {
2751 WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0,
2752 SWP_ZORDER | SWP_ACTIVATE);
2753 WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 0, 0,
2754 0, 0, SWP_ZORDER);
2755 }
2756}
2757
2758BOOL CloseChildren(HWND hwndClient)
2759{
2760 HENUM henum;
2761 HWND hwndChild;
2762 BOOL ret = FALSE;
2763
2764 fNoTileUpdate = TRUE;
2765 henum = WinBeginEnumWindows(hwndClient);
2766 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2767 if (hwndChild != hwndTree) {
2768 WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
2769 WM_SAVEAPPLICATION, MPVOID, MPVOID);
2770 if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
2771 WM_CLOSE, MPVOID, MPVOID)) {
2772 ret = TRUE;
2773 break;
2774 }
2775 }
2776 }
2777 WinEndEnumWindows(henum);
2778 fNoTileUpdate = FALSE;
2779 return ret;
2780}
2781
2782BOOL CloseDirCnrChildren(HWND hwndClient)
2783{
2784 /* returns TRUE if a directory container window was told to close */
2785
2786 HENUM henum;
2787 HWND hwndChild, hwndDir, hwndTemp;
2788 BOOL ret = FALSE;
2789
2790 fNoTileUpdate = TRUE;
2791 henum = WinBeginEnumWindows(hwndClient);
2792 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2793 if (hwndChild != hwndTree) {
2794 hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT);
2795 if (hwndTemp) {
2796 hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
2797 if (hwndDir) {
2798 WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
2799 WM_CLOSE, MPVOID, MPVOID);
2800 ret = TRUE;
2801 }
2802 }
2803 }
2804 }
2805 WinEndEnumWindows(henum);
2806 fNoTileUpdate = FALSE;
2807 return ret;
2808}
2809
2810/** Save directory container state
2811 * @param hwndClient Client window handle
2812 * @param pszStateName State name to save, NULL to save global state
2813 * @returns Number of directory container windows that were saved or -1 if error
2814 * @seealso RestoreDirCnrState
2815 */
2816
2817#define STATE_NAME_MAX_BYTES 256
2818
2819INT SaveDirCnrState(HWND hwndClient, PSZ pszStateName)
2820{
2821 HENUM henum;
2822 HWND hwndChild, hwndDir, hwndC;
2823 ULONG numsaves = 0, flWindowAttr;
2824 ULONG previous_numsaves, ulTemp = sizeof(ULONG);
2825 CHAR szPrefix[STATE_NAME_MAX_BYTES + 1];
2826 CHAR szKey[STATE_NAME_MAX_BYTES + 80];
2827 CHAR szDir[CCHMAXPATH];
2828 SWP swp;
2829 DIRCNRDATA *dcd;
2830 BOOL fIsShutDownState;
2831
2832 if (!pszStateName || !*pszStateName) {
2833 Runtime_Error(pszSrcFile, __LINE__, "no data");
2834 return -1;
2835 }
2836 if (strlen(pszStateName) > sizeof(szPrefix) - 2) {
2837 Runtime_Error(pszSrcFile, __LINE__, "SaveDirCnrState");
2838 return -1;
2839 }
2840
2841 fIsShutDownState = strcmp(pszStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0;
2842 sprintf(szPrefix, "%s.", pszStateName);
2843
2844 if (*lasttoolbar) {
2845 sprintf(szKey, "%sToolbar", szPrefix);
2846 PrfWriteProfileString(fmprof, FM3Str, szKey, lasttoolbar);
2847 }
2848
2849 if (!fIsShutDownState) {
2850 sprintf(szKey, "%sTargetDir", szPrefix);
2851 PrfWriteProfileString(fmprof, FM3Str, szKey, targetdir);
2852 }
2853
2854 henum = WinBeginEnumWindows(hwndClient);
2855 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2856 if (hwndChild != hwndTree) {
2857 hwndC = WinWindowFromID(hwndChild, FID_CLIENT);
2858 if (hwndC) {
2859 hwndDir = WinWindowFromID(hwndC, DIR_CNR);
2860 if (hwndDir) {
2861 WinQueryWindowPos(hwndChild, &swp);
2862 *szDir = 0;
2863 WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
2864 if (*szDir) {
2865 // If saving shutdown state skip no prescan drives
2866 if (fIsShutDownState &&
2867 driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
2868 continue;
2869 }
2870 sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
2871 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
2872 sizeof(SWP));
2873 dcd =
2874 WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
2875 if (dcd) {
2876 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
2877 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
2878 sizeof(INT));
2879 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
2880 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
2881 sizeof(MASK));
2882 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
2883 flWindowAttr = dcd->flWindowAttr;
2884 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
2885 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
2886 if (dcd->lastattr) {
2887 if (dcd->lastattr & CV_TEXT)
2888 flWindowAttr |= CV_TEXT;
2889 else if (dcd->lastattr & CV_DETAIL)
2890 flWindowAttr |= CV_DETAIL;
2891 else if (dcd->lastattr & CV_ICON)
2892 flWindowAttr |= CV_ICON;
2893 else
2894 flWindowAttr |= CV_NAME;
2895 }
2896 else
2897 flWindowAttr |= CV_NAME;
2898 }
2899 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
2900 sizeof(ULONG));
2901 sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
2902 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslongname,
2903 sizeof(BOOL));
2904 sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
2905 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssubject,
2906 sizeof(BOOL));
2907 sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
2908 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssize,
2909 sizeof(BOOL));
2910 sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
2911 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsea,
2912 sizeof(BOOL));
2913 sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
2914 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsattr,
2915 sizeof(BOOL));
2916 sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
2917 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsicon,
2918 sizeof(BOOL));
2919 sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
2920 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwdate,
2921 sizeof(BOOL));
2922 sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
2923 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwtime,
2924 sizeof(BOOL));
2925 sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
2926 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsladate,
2927 sizeof(BOOL));
2928 sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
2929 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslatime,
2930 sizeof(BOOL));
2931 sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
2932 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrdate,
2933 sizeof(BOOL));
2934 sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
2935 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrtime,
2936 sizeof(BOOL));
2937 sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
2938 SavePresParams(hwndDir, szKey);
2939 }
2940 sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
2941 PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
2942 }
2943 }
2944 }
2945 }
2946 } // while
2947 WinEndEnumWindows(henum);
2948
2949 sprintf(szKey, "%sNumDirsLastTime", szPrefix);
2950 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &previous_numsaves, &ulTemp))
2951 for (ulTemp = numsaves; ulTemp < previous_numsaves; ulTemp++) {
2952 sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, ulTemp);
2953 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(SWP));
2954 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, ulTemp);
2955 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(INT));
2956 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, ulTemp);
2957 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(MASK));
2958 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, ulTemp);
2959 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(ULONG));
2960 sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, ulTemp);
2961 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2962 sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, ulTemp);
2963 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2964 sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, ulTemp);
2965 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2966 sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, ulTemp);
2967 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2968 sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, ulTemp);
2969 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2970 sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, ulTemp);
2971 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2972 sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, ulTemp);
2973 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2974 sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, ulTemp);
2975 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2976 sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, ulTemp);
2977 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2978 sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, ulTemp);
2979 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2980 sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, ulTemp);
2981 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2982 sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, ulTemp);
2983 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, sizeof(BOOL));
2984 sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, ulTemp);
2985 PrfWriteProfileString(fmprof, FM3Str, szKey, NULL);
2986 sprintf(szKey, "%sDirCnr.%lu.", szPrefix, ulTemp);
2987 DeletePresParams(szKey);
2988 }
2989 sprintf(szKey, "%sNumDirsLastTime", szPrefix);
2990 if (numsaves) {
2991 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & numsaves, sizeof(ULONG));
2992 WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swp);
2993 sprintf(szKey, "%sMySizeLastTime", szPrefix);
2994 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, sizeof(SWP));
2995 if (WinQueryWindowPos(hwndTree, &swp)) {
2996 sprintf(szKey, "%sLastTreePos", szPrefix);
2997 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, sizeof(SWP));
2998 }
2999 }
3000 else if (fIsShutDownState) {
3001 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & numsaves, sizeof(ULONG));
3002 }
3003
3004 return numsaves;
3005}
3006
3007static VOID TransformSwp(PSWP pswp, double xtrans, double ytrans)
3008{
3009 SWP swp;
3010 HWND hwnd;
3011
3012 if ((LONG) pswp->x < 0L) {
3013 pswp->cx -= abs(pswp->x);
3014 pswp->x = 0;
3015 }
3016 if ((LONG) pswp->y < 0L) {
3017 pswp->cy -= abs(pswp->y);
3018 pswp->y = 0;
3019 }
3020 pswp->x = (LONG) (((double)pswp->x * 100.0) / xtrans);
3021 pswp->cx = (LONG) (((double)pswp->cx * 100.0) / xtrans);
3022 pswp->y = (LONG) (((double)pswp->y * 100.0) / ytrans);
3023 pswp->cy = (LONG) (((double)pswp->cy * 100.0) / ytrans);
3024 if (pswp->hwnd) {
3025 hwnd = WinQueryWindow(pswp->hwnd, QW_PARENT);
3026 if (hwnd) {
3027 if (WinQueryWindowPos(hwnd, &swp)) {
3028 if (pswp->x > swp.cx)
3029 pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
3030 if (pswp->y > swp.cy)
3031 pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
3032 if (pswp->x + pswp->cx > swp.cx)
3033 pswp->cx = swp.cx - pswp->x;
3034 if (pswp->y + pswp->cy > swp.cy)
3035 pswp->cy = swp.cy - pswp->y;
3036 }
3037 }
3038 }
3039}
3040
3041/** Restore directory container state
3042 * @param hwndClient Client window handle
3043 * @param pszStateName State name to restore, NULL to restore global state
3044 * @param noview request view state restore bypass
3045 * @returns TRUE if one or more directory containers were opened
3046 * @seealso SaveDirCnrState
3047 */
3048
3049static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview)
3050{
3051 CHAR szKey[STATE_NAME_MAX_BYTES + 80];
3052 CHAR szDir[CCHMAXPATH];
3053 CHAR szPrefix[STATE_NAME_MAX_BYTES + 2];
3054 HWND hwndDir, hwndC, hwndPPSave = NULLHANDLE;
3055 SWP swp, swpO, swpN;
3056 ULONG size, numsaves = 0;
3057 LONG x;
3058 double xtrans, ytrans;
3059 BOOL fRestored = FALSE;
3060 DIRCNRDATA localdcd, *dcd;
3061 BOOL fIsShutDownState;
3062 BOOL fDeleteState;
3063
3064 if (!pszStateName || !*pszStateName) {
3065 Runtime_Error(pszSrcFile, __LINE__, "no name");
3066 return fRestored;
3067 }
3068 if (strlen(pszStateName) > sizeof(szPrefix) - 2) {
3069 Runtime_Error(pszSrcFile, __LINE__, "name too long");
3070 return fRestored;
3071 }
3072
3073 sprintf(szPrefix, "%s.", pszStateName);
3074
3075 // If restoring shutdown state bypass no-prescan drives
3076 fIsShutDownState = strcmp(pszStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0;
3077 // Delete saved state if internally saved state
3078 fDeleteState = strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)) == 0;
3079
3080 size = (ULONG)0;
3081 sprintf(szKey, "%sToolbar", szPrefix);
3082 if (PrfQueryProfileSize(fmprof, FM3Str, szKey, &size) && size)
3083 {
3084 if (fToolsChanged)
3085 save_tools(NULL);
3086 PrfQueryProfileData(fmprof, FM3Str, szKey, lasttoolbar, &size);
3087 PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
3088 load_tools(NULL);
3089 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
3090 }
3091 size = (ULONG)0;
3092 sprintf(szKey, "%sTargetDir", szPrefix);
3093 if (PrfQueryProfileSize(fmprof, FM3Str, szKey, &size) && size)
3094 {
3095 PrfQueryProfileData(fmprof, FM3Str, szKey, targetdir, &size);
3096 PrfWriteProfileString(fmprof, FM3Str, "TargetDir", targetdir);
3097 SetTargetDir(NULL, TRUE);
3098 }
3099 size = sizeof(SWP);
3100 sprintf(szKey, "%sMySizeLastTime", szPrefix);
3101 if (!PrfQueryProfileData(fmprof,
3102 FM3Str,
3103 szKey,
3104 (PVOID) & swpO,
3105 &size) ||
3106 size != sizeof(SWP) || !swp.cx || !swp.cy)
3107 {
3108 WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpO);
3109 }
3110 // If restoring internally saved state, forget info
3111 if (fDeleteState)
3112 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3113 WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpN);
3114 if (swpN.fl & (SWP_MINIMIZE | SWP_HIDE))
3115 swpN = swpO;
3116 xtrans = ((double)swpO.cx * 100.0) / (double)swpN.cx;
3117 ytrans = ((double)swpO.cy * 100.0) / (double)swpN.cy;
3118 size = sizeof(SWP);
3119 sprintf(szKey, "%sLastTreePos", szPrefix);
3120 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, &size)) {
3121 if (fDeleteState)
3122 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3123 swp.hwnd = hwndTree;
3124 TransformSwp(&swp, xtrans, ytrans);
3125 if (!fFreeTree) {
3126 WinQueryWindowPos(hwndClient, &swpN);
3127 swp.x = 0;
3128 swp.y = (swpN.cy - swp.cy);
3129 }
3130 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) {
3131 swp.fl &= (~SWP_ACTIVATE);
3132 WinSetWindowPos(hwndTree,
3133 HWND_TOP,
3134 swp.x,
3135 swp.y,
3136 swp.cx,
3137 swp.cy,
3138 swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
3139 }
3140 else {
3141 WinSetWindowPos(hwndTree,
3142 HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
3143 WinSetWindowUShort(hwndTree, QWS_XRESTORE, (USHORT) swp.x);
3144 WinSetWindowUShort(hwndTree, QWS_CXRESTORE, (USHORT) swp.cx);
3145 WinSetWindowUShort(hwndTree, QWS_YRESTORE, (USHORT) swp.y);
3146 WinSetWindowUShort(hwndTree, QWS_CYRESTORE, (USHORT) swp.cy);
3147 }
3148 }
3149 size = sizeof(ULONG);
3150 sprintf(szKey, "%sNumDirsLastTime", szPrefix);
3151 if (PrfQueryProfileData(fmprof,
3152 FM3Str, szKey, (PVOID) & numsaves, &size)) {
3153 if (fDeleteState)
3154 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3155 for (x = numsaves - 1; x >= 0; x--) {
3156 sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, x);
3157 size = sizeof(SWP);
3158 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) {
3159 if (fDeleteState)
3160 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3161 sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
3162 size = sizeof(szDir);
3163 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
3164 // If restoring shutdown state and drive marked no prescan
3165 // bypass window restore
3166 if (fIsShutDownState &&
3167 driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
3168 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3169 continue;
3170 }
3171 if (fDeleteState)
3172 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3173 localdcd.ds.detailslongname = dsDirCnrDefault.detailslongname; // Set default
3174 size = sizeof(BOOL);
3175 sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
3176 if (PrfQueryProfileData(fmprof,
3177 FM3Str,
3178 szKey,
3179 (PVOID)&localdcd.ds.detailslongname,
3180 &size) &&
3181 size == sizeof(BOOL))
3182 {
3183 if (fDeleteState)
3184 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3185 }
3186 localdcd.ds.detailssubject = dsDirCnrDefault.detailssubject; // Set default
3187 size = sizeof(BOOL);
3188 sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
3189 if (PrfQueryProfileData(fmprof,
3190 FM3Str,
3191 szKey,
3192 (PVOID)&localdcd.ds.detailssubject,
3193 &size) &&
3194 size == sizeof(BOOL))
3195 {
3196 if (fDeleteState)
3197 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3198 }
3199 localdcd.ds.detailsea = dsDirCnrDefault.detailsea; // Set default
3200 size = sizeof(BOOL);
3201 sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
3202 if (PrfQueryProfileData(fmprof,
3203 FM3Str,
3204 szKey,
3205 (PVOID) & localdcd.ds.detailsea,
3206 &size) &&
3207 size == sizeof(BOOL))
3208 {
3209 if (fDeleteState)
3210 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3211 }
3212 localdcd.ds.detailssize = dsDirCnrDefault.detailssize; // Set default
3213 size = sizeof(BOOL);
3214 sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
3215 if (PrfQueryProfileData(fmprof,
3216 FM3Str,
3217 szKey,
3218 (PVOID) & localdcd.ds.detailssize,
3219 &size) &&
3220 size == sizeof(BOOL))
3221 {
3222 if (fDeleteState)
3223 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3224 }
3225 localdcd.ds.detailsicon = dsDirCnrDefault.detailsicon; // Set default
3226 size = sizeof(BOOL);
3227 sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
3228 if (PrfQueryProfileData(fmprof,
3229 FM3Str,
3230 szKey,
3231 (PVOID) & localdcd.ds.detailsicon,
3232 &size) &&
3233 size == sizeof(BOOL))
3234 {
3235 if (fDeleteState)
3236 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3237 }
3238 localdcd.ds.detailsattr = dsDirCnrDefault.detailsattr; // Set default
3239 size = sizeof(BOOL);
3240 sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
3241 if (PrfQueryProfileData(fmprof,
3242 FM3Str,
3243 szKey,
3244 (PVOID)&localdcd.ds.detailsattr,
3245 &size) &&
3246 size == sizeof(BOOL))
3247 {
3248 if (fDeleteState)
3249 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3250 }
3251 localdcd.ds.detailscrdate = dsDirCnrDefault.detailscrdate; // Set default
3252 size = sizeof(BOOL);
3253 sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
3254 if (PrfQueryProfileData(fmprof,
3255 FM3Str,
3256 szKey,
3257 (PVOID) & localdcd.ds.detailscrdate,
3258 &size) && size == sizeof(BOOL))
3259 {
3260 if (fDeleteState)
3261 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3262 }
3263 localdcd.ds.detailscrtime = dsDirCnrDefault.detailscrtime; // Set default
3264 size = sizeof(BOOL);
3265 sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
3266 if (PrfQueryProfileData(fmprof,
3267 FM3Str,
3268 szKey,
3269 (PVOID)&localdcd.ds.detailscrtime,
3270 &size) &&
3271 size == sizeof(BOOL))
3272 {
3273 if (fDeleteState)
3274 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3275 }
3276 localdcd.ds.detailslwdate = dsDirCnrDefault.detailslwdate; // Set default
3277 size = sizeof(BOOL);
3278 sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
3279 if (PrfQueryProfileData(fmprof,
3280 FM3Str,
3281 szKey,
3282 (PVOID) & localdcd.ds.detailslwdate,
3283 &size) &&
3284 size == sizeof(BOOL))
3285 {
3286 if (fDeleteState)
3287 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3288 }
3289 localdcd.ds.detailslwtime = dsDirCnrDefault.detailslwtime; // Set default
3290 size = sizeof(BOOL);
3291 sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
3292 if (PrfQueryProfileData(fmprof,
3293 FM3Str,
3294 szKey,
3295 (PVOID) & localdcd.ds.detailslwtime,
3296 &size) &&
3297 size == sizeof(BOOL))
3298 {
3299 if (fDeleteState)
3300 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3301 }
3302 localdcd.ds.detailsladate = dsDirCnrDefault.detailsladate; // Set default
3303 size = sizeof(BOOL);
3304 sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
3305 if (PrfQueryProfileData(fmprof,
3306 FM3Str,
3307 szKey,
3308 (PVOID) & localdcd.ds.detailsladate,
3309 &size) &&
3310 size == sizeof(BOOL))
3311 {
3312 if (fDeleteState)
3313 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3314 }
3315 localdcd.ds.detailslatime = dsDirCnrDefault.detailslatime; // Set default
3316 size = sizeof(BOOL);
3317 sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
3318 if (PrfQueryProfileData(fmprof,
3319 FM3Str,
3320 szKey,
3321 (PVOID) & localdcd.ds.detailslatime,
3322 &size) &&
3323 size == sizeof(BOOL))
3324 {
3325 if (fDeleteState)
3326 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3327 }
3328 hwndDir = (HWND) WinSendMsg(hwndClient,
3329 UM_SETDIR,
3330 MPFROMP(szDir), MPFROMLONG(1));
3331 if (hwndDir) {
3332 hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
3333 if (hwndC) {
3334 HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
3335 if (!hwndPPSave) {
3336 hwndPPSave = WinCreateWindow(hwndCnr, // Create a window (used to save default presparams)
3337 WC_CONTAINER,
3338 NULL,
3339 CCS_AUTOPOSITION | CCS_MINIICONS |
3340 CCS_MINIRECORDCORE | ulCnrType |
3341 WS_VISIBLE,
3342 0,
3343 0,
3344 0,
3345 0,
3346 hwndCnr,
3347 HWND_TOP, (ULONG) -1, NULL, NULL);
3348 CopyPresParams(hwndPPSave, hwndC);
3349 RestorePresParams(hwndPPSave, "DirCnr");
3350 }
3351 sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
3352 RestorePresParams(hwndCnr, szKey);
3353 dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
3354 if (dcd) {
3355 dcd->ds.detailslongname = localdcd.ds.detailslongname;
3356 dcd->ds.detailssubject = localdcd.ds.detailssubject ;
3357 dcd->ds.detailsattr = localdcd.ds.detailsattr ;
3358 dcd->ds.detailsea = localdcd.ds.detailsea ;
3359 dcd->ds.detailssize = localdcd.ds.detailssize ;
3360 dcd->ds.detailsicon = localdcd.ds.detailsicon ;
3361 dcd->ds.detailscrdate = localdcd.ds.detailscrdate ;
3362 dcd->ds.detailscrtime = localdcd.ds.detailscrtime ;
3363 dcd->ds.detailsladate = localdcd.ds.detailsladate ;
3364 dcd->ds.detailslatime = localdcd.ds.detailslatime ;
3365 dcd->ds.detailslwdate = localdcd.ds.detailslwdate ;
3366 dcd->ds.detailslwtime = localdcd.ds.detailslwtime ;
3367 size = sizeof(INT);
3368 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
3369 if (PrfQueryProfileData(fmprof,
3370 FM3Str,
3371 szKey,
3372 (PVOID) & dcd->sortFlags,
3373 &size) && size == sizeof(INT)) {
3374 if (!dcd->sortFlags)
3375 dcd->sortFlags = SORT_PATHNAME;
3376 }
3377 if (fDeleteState)
3378 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3379 size = sizeof(MASK);
3380 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
3381 if (PrfQueryProfileData(fmprof,
3382 FM3Str,
3383 szKey,
3384 (PVOID) & dcd->mask, &size) && size) {
3385 if (*dcd->mask.szMask)
3386 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
3387 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
3388 }
3389 *(dcd->mask.prompt) = 0;
3390 if (fDeleteState)
3391 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3392 size = sizeof(ULONG);
3393 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
3394 if (!noview) {
3395 if (PrfQueryProfileData(fmprof,
3396 FM3Str,
3397 szKey,
3398 (PVOID) & dcd->flWindowAttr,
3399 &size) && size == sizeof(ULONG)) {
3400
3401 CNRINFO cnri;
3402
3403 memset(&cnri, 0, sizeof(CNRINFO));
3404 cnri.cb = sizeof(CNRINFO);
3405 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
3406 CM_QUERYCNRINFO,
3407 MPFROMP(&cnri),
3408 MPFROMLONG(sizeof(CNRINFO)))) {
3409 cnri.flWindowAttr = dcd->flWindowAttr;
3410 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
3411 CM_SETCNRINFO,
3412 MPFROMP(&cnri),
3413 MPFROMLONG(CMA_FLWINDOWATTR));
3414 }
3415 }
3416 }
3417 if (fDeleteState)
3418 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3419 if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
3420 WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
3421 }
3422 }
3423 fRestored = TRUE;
3424 swp.hwnd = hwndDir;
3425 TransformSwp(&swp, xtrans, ytrans);
3426 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
3427 WinSetWindowPos(hwndDir,
3428 HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
3429 WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
3430 WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
3431 WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
3432 WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
3433 } else
3434 WinSetWindowPos(hwndDir,
3435 HWND_TOP,
3436 swp.x,
3437 swp.y,
3438 swp.cx,
3439 swp.cy,
3440 swp.fl | SWP_MOVE |
3441 SWP_SIZE | SWP_SHOW | SWP_ZORDER |
3442 SWP_ACTIVATE);
3443 }
3444 }
3445 }
3446 } // for
3447 if (hwndPPSave) {
3448 SavePresParams(hwndPPSave, "DirCnr");
3449 WinDestroyWindow(hwndPPSave);
3450 }
3451 }
3452 return fRestored;
3453}
3454
3455static ULONG CountChildren(HWND hwndClient, ULONG * ulNumMinChildren)
3456{
3457 HENUM henum;
3458 HWND hwndChild;
3459 SWP swp;
3460 register ULONG ulCnt = 0L;
3461 USHORT id;
3462
3463 if (ulNumMinChildren)
3464 *ulNumMinChildren = 0L;
3465 henum = WinBeginEnumWindows(hwndClient);
3466 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3467 id = WinQueryWindowUShort(hwndChild, QWS_ID);
3468 if (!id || (!fFreeTree && id == TREE_FRAME))
3469 continue;
3470 ulCnt++;
3471 if (ulNumMinChildren) {
3472 if (WinQueryWindowPos(hwndChild, &swp) && (swp.fl & SWP_MINIMIZE))
3473 (*ulNumMinChildren)++;
3474 }
3475 }
3476 WinEndEnumWindows(henum);
3477 return ulCnt;
3478}
3479
3480VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR,
3481 ULONG * ulNumMinChildrenR)
3482{
3483 register ULONG ulCnt;
3484 ULONG ulNumMinChildren;
3485 RECTL Rectl;
3486 register ULONG ulXDiff, ulYDiff, ulWindowsPerStack;
3487
3488 if (!ulCntR || !ulNumMinChildrenR)
3489 ulCnt = CountChildren(hwndClient, &ulNumMinChildren);
3490 else {
3491 ulCnt = *ulCntR;
3492 ulNumMinChildren = *ulNumMinChildrenR;
3493 if (ulCnt == (ULONG) - 1) {
3494 ulCnt = CountChildren(hwndClient, &ulNumMinChildren);
3495 /* return these values to the caller for later use */
3496 *ulCntR = ulCnt;
3497 *ulNumMinChildrenR = ulNumMinChildren;
3498 }
3499 }
3500 WinQueryWindowRect(hwndClient, &Rectl);
3501 AdjustSizeOfClient(NULL, &Rectl);
3502 if (!fFreeTree) {
3503
3504 SWP swp;
3505
3506 WinQueryWindowPos(hwndTree, &swp);
3507 if (ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
3508 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3509 }
3510 else if (ulNumMinChildren)
3511 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3512
3513 ulXDiff = WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER) +
3514 WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON) / 2;
3515 ulYDiff = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER) +
3516 WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON);
3517 ulWindowsPerStack = (Rectl.yTop - Rectl.yBottom) / (3 * ulYDiff);
3518 pswp->cx = Rectl.xRight - (ulWindowsPerStack * ulXDiff);
3519 pswp->cy = (Rectl.yTop - Rectl.yBottom) - (ulWindowsPerStack * ulYDiff);
3520 ulWindowsPerStack++;
3521 pswp->x = Rectl.xLeft + ((ulCnt % ulWindowsPerStack) * ulXDiff);
3522 pswp->y = (Rectl.yTop - pswp->cy - ((ulCnt % ulWindowsPerStack) * ulYDiff));
3523}
3524
3525static VOID CascadeChildren(HWND hwndClient)
3526{
3527 ULONG ulCnt = 0L, ulNumMinChildren;
3528 HWND hwndChild;
3529 HENUM henum;
3530 SWP swp;
3531 USHORT id;
3532 RECTL Rectl;
3533
3534 WinQueryWindowPos(hwndClient, &swp);
3535 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE))
3536 return;
3537
3538 CountChildren(hwndClient, &ulNumMinChildren);
3539 if (!fFreeTree) {
3540 WinQueryWindowRect(hwndClient, &Rectl);
3541 AdjustSizeOfClient(NULL, &Rectl);
3542 WinQueryWindowPos(hwndTree, &swp);
3543 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
3544 if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
3545 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
3546 if (swp.x != 0)
3547 swp.x = 0;
3548 if (swp.y < 0)
3549 swp.y = 0;
3550 if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
3551 swp.cx = Rectl.xRight - Rectl.xLeft;
3552 WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
3553 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
3554 }
3555 }
3556 henum = WinBeginEnumWindows(hwndClient);
3557 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3558 id = WinQueryWindowUShort(hwndChild, QWS_ID);
3559 if (!id || (!fFreeTree && id == TREE_FRAME))
3560 continue;
3561 WinQueryWindowPos(hwndChild, &swp);
3562 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) {
3563 GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren);
3564 WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
3565 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
3566 SWP_ZORDER | SWP_ACTIVATE);
3567 ulCnt++;
3568 }
3569 }
3570 WinEndEnumWindows(henum);
3571}
3572
3573VOID TileChildren(HWND hwndClient, BOOL absolute)
3574{
3575 register ULONG ulChildCnt, ulSquare, ulNumRows, ulNumCols, ulExtraCols,
3576 ulWidth, ulHeight;
3577 ULONG ulNumMinChildren;
3578 RECTL Rectl;
3579 HWND hwndChild;
3580
3581 if (fNoTileUpdate || hwndClient == HWND_DESKTOP)
3582 return;
3583 {
3584 SWP swp;
3585
3586 WinQueryWindowPos(hwndClient, &swp);
3587 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE))
3588 return;
3589 }
3590 ulChildCnt = CountChildren(hwndClient, &ulNumMinChildren);
3591 ulChildCnt -= ulNumMinChildren;
3592 if (!ulChildCnt)
3593 return;
3594
3595 fNoTileUpdate = TRUE;
3596
3597 for (ulSquare = 2; ulSquare * ulSquare <= ulChildCnt; ulSquare++) {
3598 ;
3599 }
3600 if (!fTileBackwards) {
3601 ulNumCols = ulSquare - 1;
3602 ulNumRows = ulChildCnt / ulNumCols;
3603 }
3604 else {
3605 ulNumRows = ulSquare - 1;
3606 ulNumCols = ulChildCnt / ulNumRows;
3607 }
3608 ulExtraCols = ulChildCnt % ulNumCols;
3609
3610 WinQueryWindowRect(hwndClient, &Rectl);
3611
3612 if (!fFreeTree) {
3613
3614 SWP swp;
3615
3616 WinQueryWindowPos(hwndTree, &swp);
3617 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
3618 if (swp.y < 0)
3619 swp.y = 0;
3620 if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
3621 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
3622 if (swp.x != 0)
3623 swp.x = 0;
3624 if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
3625 swp.cx = Rectl.xRight - Rectl.xLeft;
3626 WinSetWindowPos(hwndTree,
3627 HWND_TOP,
3628 swp.x,
3629 swp.y,
3630 swp.cx,
3631 swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
3632 WinQueryWindowPos(hwndTree, &swp);
3633 }
3634 if (ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
3635 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3636 }
3637 else if (ulNumMinChildren)
3638 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3639
3640 AdjustSizeOfClient(NULL, &Rectl);
3641
3642 if (Rectl.xRight > 0L && (Rectl.yBottom < Rectl.yTop)) {
3643
3644 HENUM henum;
3645
3646 henum = WinBeginEnumWindows(hwndClient);
3647 if ((hwndChild = WinGetNextWindow(henum)) != (HWND) 0) {
3648
3649 ULONG ulCurRow, ulCurCol;
3650 SWP swp;
3651 USHORT id;
3652
3653 ulHeight = (Rectl.yTop - Rectl.yBottom) / ulNumRows;
3654
3655 for (ulCurRow = 0; ulCurRow < ulNumRows; ulCurRow++) {
3656 if ((ulNumRows - ulCurRow) <= ulExtraCols)
3657 ulNumCols++;
3658 for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
3659 ulWidth = Rectl.xRight / ulNumCols;
3660
3661 while (hwndChild) {
3662 id = WinQueryWindowUShort(hwndChild, QWS_ID);
3663 if (id && (id != TREE_FRAME || fFreeTree)) {
3664 WinQueryWindowPos(hwndChild, &swp);
3665 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
3666 break;
3667 }
3668 hwndChild = WinGetNextWindow(henum);
3669 }
3670
3671 if (hwndChild) {
3672 if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
3673 WinGetMaxPosition(hwndChild, &swp);
3674 WinSetWindowPos(hwndChild,
3675 HWND_TOP,
3676 swp.x,
3677 swp.y,
3678 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
3679 WinSetWindowUShort(hwndChild,
3680 QWS_XRESTORE,
3681 (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
3682 WinSetWindowUShort(hwndChild,
3683 QWS_YRESTORE,
3684 (USHORT) (Rectl.yTop -
3685 (ulHeight * (ulCurRow + 1))));
3686 WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
3687 WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
3688 }
3689 else
3690 WinSetWindowPos(hwndChild,
3691 HWND_TOP,
3692 (ulWidth * ulCurCol) + Rectl.xLeft,
3693 Rectl.yTop - (ulHeight * (ulCurRow + 1)),
3694 ulWidth,
3695 ulHeight,
3696 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
3697 hwndChild = WinGetNextWindow(henum);
3698 }
3699 }
3700 if ((ulNumRows - ulCurRow) <= ulExtraCols) {
3701 ulNumCols--;
3702 ulExtraCols--;
3703 }
3704 }
3705 }
3706 WinEndEnumWindows(henum);
3707 }
3708
3709 fNoTileUpdate = FALSE;
3710}
3711
3712static VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy,
3713 SHORT newcx, SHORT newcy)
3714{
3715 /*
3716 * resize all children of the client to maintain their proportional
3717 * sizes and positions
3718 */
3719
3720 if (!newcx || !newcy || !oldcx || !oldcy)
3721 return;
3722 {
3723 HENUM henum;
3724 HWND hwndChild;
3725 register LONG x, y, cx, cy, ucx, ucy, ux, uy;
3726 SWP swp;
3727
3728 henum = WinBeginEnumWindows(hwndClient);
3729 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3730 if (!WinQueryWindowUShort(hwndChild, QWS_ID))
3731 continue;
3732 if (WinQueryWindowPos(hwndChild, &swp)) {
3733 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
3734 swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
3735 swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
3736 swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
3737 swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
3738 }
3739 else if (swp.fl & SWP_MAXIMIZE) {
3740 swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
3741 swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
3742 swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
3743 swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
3744 }
3745 cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
3746 cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
3747 x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
3748 y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
3749 if (x < 0)
3750 x = 0;
3751 if (y < 0)
3752 y = 0;
3753 ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
3754 uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
3755 ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
3756 ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
3757 if (ux + ucx > newcx)
3758 ucx = newcx - ux;
3759 if (uy + ucy > newcy)
3760 ucy = newcy - uy;
3761
3762 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
3763 WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
3764 SWP_MOVE | SWP_SIZE | SWP_SHOW);
3765 else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
3766 WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
3767 WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
3768 WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
3769 SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
3770 WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
3771 WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
3772 WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
3773 WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
3774 }
3775 else {
3776 WinGetMaxPosition(hwndChild, &swp);
3777 WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
3778 SWP_MOVE | SWP_SIZE | SWP_SHOW);
3779 WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
3780 WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
3781 WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
3782 WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
3783 }
3784 }
3785 }
3786 WinEndEnumWindows(henum);
3787 }
3788 if (!fFreeTree) {
3789
3790 RECTL Rectl;
3791 SWP swp;
3792
3793 WinQueryWindowRect(hwndClient, &Rectl);
3794 AdjustSizeOfClient(NULL, &Rectl);
3795 WinQueryWindowPos(hwndTree, &swp);
3796 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
3797
3798 if (!fNoTreeGap) {
3799 INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3800 if (swp.y < height)
3801 swp.y = height; // Force bottom to position
3802 }
3803 else
3804 swp.y = 0; // Force bottom to position
3805
3806 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
3807 if (swp.cy < 0)
3808 swp.cy = 0;
3809
3810 if (swp.x != 0)
3811 swp.x = 0; // Left align
3812
3813 // AdjustSizeOfClient can return bogus xRight values - fixme someday
3814 if (Rectl.xRight >= Rectl.xLeft) {
3815 if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
3816 swp.cx = Rectl.xRight - Rectl.xLeft;
3817 }
3818 WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
3819 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
3820 }
3821 }
3822}
3823
3824static VOID MinResChildren(HWND hwndClient, ULONG cmd)
3825{
3826 HENUM henum;
3827 HWND hwndChild;
3828
3829 {
3830 SWP swp;
3831
3832 WinQueryWindowPos(hwndClient, &swp);
3833 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE))
3834 return;
3835 }
3836 henum = WinBeginEnumWindows(hwndClient);
3837 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3838 if (!WinQueryWindowUShort(hwndChild, QWS_ID))
3839 continue;
3840 WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, cmd);
3841 }
3842}
3843
3844//=== ChildFrameButtonProc: subclass handler for WALKBUTTON and QUICKBUTTON windows ===
3845
3846static MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd,
3847 ULONG msg,
3848 MPARAM mp1, MPARAM mp2)
3849{
3850 USHORT id;
3851 static BOOL emphasized = FALSE;
3852
3853 switch (msg) {
3854 case WM_BUTTON1CLICK:
3855 case WM_CHORD:
3856 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
3857 break;
3858
3859 case WM_MOUSEMOVE:
3860 if (fOtherHelp) {
3861 if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
3862 && !WinQueryCapture(HWND_DESKTOP)) {
3863 id = WinQueryWindowUShort(hwnd, QWS_ID);
3864 switch (id) {
3865 case IDM_OPENWALK:
3866 MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
3867 break;
3868 case IDM_USERLIST:
3869 MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
3870 break;
3871 }
3872 }
3873 }
3874 break;
3875
3876 case WM_BUTTON3CLICK:
3877 case WM_BUTTON2CLICK:
3878 {
3879 USHORT cmd = 0;
3880
3881 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
3882 id = WinQueryWindowUShort(hwnd, QWS_ID);
3883 switch (id) {
3884 case IDM_OPENWALK:
3885 switch (msg) {
3886 case WM_BUTTON2CLICK:
3887 if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
3888 (KC_ALT | KC_SHIFT | KC_CTRL))
3889 cmd = IDM_GREP;
3890 else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
3891 CascadeChildren(hwndMain);
3892
3893#ifdef NEVER
3894 else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
3895 cmd = IDM_SYSINFO;
3896#endif
3897
3898 else if (shiftstate & KC_SHIFT)
3899 cmd = IDM_WINDOWDLG;
3900 else if (shiftstate & KC_CTRL)
3901 cmd = IDM_SEEALL;
3902 else if (shiftstate & KC_ALT)
3903 TileChildren(hwndMain, TRUE);
3904 else
3905 cmd = IDM_WALKDIR;
3906 break;
3907 case WM_BUTTON3CLICK:
3908 TileChildren(hwndMain, TRUE);
3909 break;
3910 }
3911 break;
3912 case IDM_USERLIST:
3913 switch (msg) {
3914 case WM_BUTTON2CLICK:
3915 if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
3916 (KC_ALT | KC_SHIFT | KC_CTRL))
3917 cmd = IDM_COLORPALETTE;
3918 else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
3919 cmd = IDM_HIDEMENU;
3920 else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
3921 cmd = IDM_NOTEBOOK;
3922 else if (shiftstate & KC_SHIFT)
3923 cmd = IDM_TOOLTITLES;
3924 else if (shiftstate & KC_CTRL)
3925 cmd = IDM_TEXTTOOLS;
3926 else if (shiftstate & KC_ALT)
3927 cmd = IDM_FONTPALETTE;
3928 else
3929 cmd = IDM_TOOLBAR;
3930 break;
3931 case WM_BUTTON3CLICK:
3932 cmd = IDM_DRIVEBAR;
3933 break;
3934 }
3935 break;
3936 } // switch id
3937
3938 if (cmd) {
3939 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
3940 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
3941 }
3942 }
3943 break;
3944
3945 case DM_DRAGOVER:
3946 id = WinQueryWindowUShort(hwnd, QWS_ID);
3947 if (id == IDM_OPENWALK) {
3948 if (!emphasized) {
3949 emphasized = TRUE;
3950 DrawTargetEmphasis(hwnd, emphasized);
3951 }
3952 if (AcceptOneDrop(hwnd, mp1, mp2))
3953 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
3954 }
3955 return MRFROM2SHORT(DOR_NEVERDROP, 0);
3956
3957 case DM_DRAGLEAVE:
3958 if (emphasized) {
3959 emphasized = FALSE;
3960 DrawTargetEmphasis(hwnd, emphasized);
3961 }
3962 break;
3963
3964 case DM_DROPHELP:
3965 DropHelp(mp1, mp2, hwnd, GetPString(IDS_OPENDROPHELP));
3966 return 0;
3967
3968 case DM_DROP:
3969 {
3970 char szFrom[CCHMAXPATH + 2];
3971
3972 if (emphasized) {
3973 emphasized = FALSE;
3974 DrawTargetEmphasis(hwnd, emphasized);
3975 }
3976 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
3977 if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
3978 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
3979 }
3980 }
3981 }
3982 return 0;
3983
3984 case WM_CLOSE:
3985 WinDestroyWindow(hwnd);
3986 return 0;
3987 }
3988 return PFNWPButton(hwnd, msg, mp1, mp2);
3989}
3990
3991static MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
3992 MPARAM mp2)
3993{
3994 PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
3995 static ULONG aheight = 0L;
3996
3997 switch (msg) {
3998 case WM_ADJUSTWINDOWPOS:
3999 {
4000 SWP *pswp;
4001
4002 pswp = (SWP *) mp1;
4003 if (fDataMin && !fAmClosing) {
4004 if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
4005
4006 SWP swp;
4007
4008 WinQueryWindowPos(hwnd, &swp);
4009 PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
4010 HideNote();
4011 }
4012 else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
4013 if (DataHwnd)
4014 PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
4015 }
4016 }
4017 if (!fAmClosing) {
4018 if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
4019 HideNote();
4020 }
4021 }
4022 break;
4023
4024 case UM_FOCUSME:
4025 CreateDataBar(HWND_DESKTOP, (ULONG) mp1);
4026 return 0;
4027
4028 case WM_BUTTON1UP:
4029 case WM_BUTTON2UP:
4030 case WM_BUTTON3UP:
4031 case WM_MOUSEMOVE:
4032 case WM_CHORD:
4033 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
4034 break;
4035
4036 case WM_CHAR:
4037 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
4038 break;
4039
4040 case WM_CONTROL:
4041 return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1,
4042 mp2);
4043
4044 case WM_COMMAND:
4045 return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
4046
4047 case WM_CALCFRAMERECT:
4048 {
4049 MRESULT mr;
4050 PRECTL prectl;
4051 LONG sheight = 20, bheight = 20;
4052
4053 mr = oldproc(hwnd, msg, mp1, mp2);
4054
4055 /*
4056 * Calculate the position of the client rectangle.
4057 * Otherwise, we'll see a lot of redraw when we move the
4058 * client during WM_FORMATFRAME.
4059 */
4060
4061 if (mr && mp2) {
4062 prectl = (PRECTL) mp1;
4063 if (prectl->yBottom != prectl->yTop) {
4064 {
4065 HPS hps;
4066 POINTL aptl[TXTBOX_COUNT];
4067
4068 hps = WinGetPS(hwndStatus);
4069 if (hps) {
4070 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
4071 bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
4072 WinReleasePS(hps);
4073 }
4074 }
4075 prectl->yBottom += (sheight + 4);
4076 prectl->yTop -= (sheight + 4);
4077 if (fMoreButtons) {
4078
4079 HPS hps;
4080 POINTL aptl[TXTBOX_COUNT];
4081
4082 hps = WinGetPS(hwndName);
4083 if (hps) {
4084 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
4085 bheight = aptl[TXTBOX_TOPLEFT].y + 6;
4086 WinReleasePS(hps);
4087 }
4088 prectl->yBottom += (bheight + 4);
4089 prectl->yTop -= (bheight + 4);
4090 }
4091 if (fToolbar) {
4092 if (!fTextTools)
4093 prectl->yTop -= ((fToolTitles) ? 50 : 40);
4094 else
4095 prectl->yTop -= 32;
4096 }
4097 if (fDrivebar) {
4098 ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
4099 ((prectl->xRight -
4100 (WinQuerySysValue(HWND_DESKTOP,
4101 SV_CYSIZEBORDER) * 2)) - 4));
4102 prectl->yTop -= (16 * (DriveLines * 18));
4103 }
4104 if (fUserComboBox) {
4105 if (!aheight) {
4106
4107 SWP swpTemp;
4108
4109 WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
4110 &swpTemp);
4111 aheight = swpTemp.cy;
4112 }
4113 prectl->yTop -= (aheight + 6L);
4114 }
4115 if (fAutoView) {
4116 AutoviewHeight = min(AutoviewHeight,
4117 (prectl->yTop - prectl->yBottom) - 116);
4118 AutoviewHeight = max(AutoviewHeight, 36);
4119 prectl->yBottom += (AutoviewHeight + 6);
4120 }
4121 }
4122 }
4123 return mr;
4124 }
4125
4126 case WM_FORMATFRAME:
4127 {
4128 SHORT sCount, soldCount;
4129 PSWP pswp, pswpClient, pswpNew;
4130 SWP swpClient;
4131 LONG theight = 48L, dheight = 20L, width, sheight = 20, bheight = 20;
4132
4133 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
4134 soldCount = sCount;
4135
4136 /*
4137 * Reformat the frame to "squeeze" the client
4138 * and make room for status window sibling beneath
4139 * and toolbar above (if toolbar's on) and userlists
4140 * (if userlists are on).
4141 */
4142
4143 pswp = (PSWP) mp1;
4144 {
4145 SHORT x;
4146
4147 for (x = 0; x < soldCount; x++) {
4148 if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
4149 pswpClient = pswp;
4150 break;
4151 }
4152 pswp++;
4153 }
4154 }
4155
4156 {
4157 HPS hps;
4158 POINTL aptl[TXTBOX_COUNT];
4159
4160 hps = WinGetPS(hwndStatus);
4161 if (hps) {
4162 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
4163 bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
4164 WinReleasePS(hps);
4165 }
4166 if (fMoreButtons) {
4167 hps = WinGetPS(hwndName);
4168 if (hps) {
4169 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
4170 bheight = aptl[TXTBOX_TOPLEFT].y + 6;
4171 WinReleasePS(hps);
4172 }
4173 }
4174 }
4175 pswpNew = (PSWP) mp1 + soldCount;
4176 *pswpNew = *pswpClient;
4177 swpClient = *pswpClient;
4178 pswpNew->hwnd = hwndStatus;
4179 pswpNew->hwndInsertBehind = HWND_BOTTOM;
4180 pswpNew->x = swpClient.x + 3;
4181 pswpNew->y = swpClient.y + 2;
4182 if (!fSplitStatus)
4183 width = swpClient.cx - (16 + (sheight * 2) + 4);
4184 else
4185 width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
4186 width = max(width, 10);
4187 if (fSplitStatus)
4188 pswpNew->cx = width - 6;
4189 else
4190 pswpNew->cx = width - 8;
4191 pswpNew->cy = sheight;
4192 pswpClient->y = pswpNew->y + pswpNew->cy + 3;
4193 pswpClient->cy = (swpClient.cy - pswpNew->cy) - 3;
4194 sCount++;
4195
4196 if (fSplitStatus) {
4197 pswpNew = (PSWP) mp1 + (soldCount + 1);
4198 *pswpNew = *pswpClient;
4199 pswpNew->hwnd = hwndStatus2;
4200 pswpNew->hwndInsertBehind = HWND_BOTTOM;
4201 pswpNew->x = width + 8;
4202 pswpNew->y = swpClient.y + 2;
4203 pswpNew->cx = width - 6;
4204 pswpNew->cy = sheight;
4205 sCount++;
4206 }
4207 else {
4208 WinShowWindow(hwndStatus2, FALSE);
4209 WinSetWindowText(hwndStatus2, NullStr);
4210 }
4211
4212 if (fToolbar) {
4213 if (fTextTools)
4214 theight = 32L;
4215 else if (!fToolTitles)
4216 theight = 40L;
4217 pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
4218 *pswpNew = *pswpClient;
4219 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
4220 pswpNew->hwndInsertBehind = HWND_BOTTOM;
4221 pswpNew->x = swpClient.x + 2;
4222 pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
4223 pswpNew->cx = swpClient.cx - 4;
4224 pswpNew->cy = theight - 4;
4225 pswpClient->cy -= theight;
4226 sCount++;
4227 }
4228 else
4229 WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
4230
4231 if (fDrivebar) {
4232 ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
4233 pswpNew = (PSWP) mp1 + (soldCount + 1 +
4234 (fSplitStatus != FALSE) +
4235 (fToolbar != FALSE));
4236 *pswpNew = *pswpClient;
4237 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
4238 pswpNew->hwndInsertBehind = HWND_BOTTOM;
4239 pswpNew->x = swpClient.x + 2;
4240 dheight += ((dheight - 2) * DriveLines);
4241 pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
4242 if (fToolbar)
4243 pswpNew->y -= theight;
4244 pswpNew->cx = swpClient.cx - 4;
4245 pswpNew->cy = dheight - 4;
4246 pswpClient->cy -= dheight;
4247 sCount++;
4248 }
4249 else
4250 WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
4251
4252 if (fAutoView) {
4253 pswpNew = (PSWP) mp1 + (soldCount + 1 +
4254 (fToolbar != FALSE) +
4255 (fDrivebar != FALSE) +
4256 (fSplitStatus != FALSE));
4257 *pswpNew = *pswpClient;
4258 pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
4259 pswpNew->x = pswpClient->x + 3;
4260 pswpNew->y = pswpClient->y + 3;
4261 if (fMoreButtons)
4262 pswpNew->y += (bheight + 4);
4263 pswpNew->cx = pswpClient->cx - 6;
4264 AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
4265 AutoviewHeight = max(AutoviewHeight, 36);
4266 pswpNew->cy = AutoviewHeight;
4267 pswpClient->y += (AutoviewHeight + 6);
4268 pswpClient->cy -= (AutoviewHeight + 6);
4269 sCount++;
4270 WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
4271 }
4272 else {
4273 WinShowWindow(hwndAutoview, FALSE);
4274 WinShowWindow(hwndAutoMLE, FALSE);
4275 }
4276
4277 pswpNew = (PSWP) mp1 + (soldCount + 1 +
4278 (fToolbar != FALSE) +
4279 (fDrivebar != FALSE) +
4280 (fSplitStatus != FALSE) + (fAutoView != FALSE));
4281 *pswpNew = *pswpClient;
4282 pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWALK);
4283 pswpNew->x = swpClient.cx - ((sheight * 2) + 4);
4284 pswpNew->y = swpClient.y;
4285 pswpNew->cx = sheight + 4;
4286 pswpNew->cy = sheight + 4;
4287 sCount++;
4288 pswpNew = (PSWP) mp1 + (soldCount + 2 +
4289 (fToolbar != FALSE) +
4290 (fDrivebar != FALSE) +
4291 (fSplitStatus != FALSE) + (fAutoView != FALSE));
4292 *pswpNew = *pswpClient;
4293 pswpNew->hwnd = WinWindowFromID(hwnd, IDM_USERLIST);
4294 pswpNew->x = swpClient.cx - (sheight + 2);
4295 pswpNew->y = swpClient.y;
4296 pswpNew->cx = sheight + 4;
4297 pswpNew->cy = sheight + 4;
4298 sCount++;
4299 pswpNew = (PSWP) mp1 + (soldCount + 3 +
4300 (fToolbar != FALSE) +
4301 (fDrivebar != FALSE) +
4302 (fSplitStatus != FALSE) + (fAutoView != FALSE));
4303 *pswpNew = *pswpClient;
4304 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED);
4305 pswpNew->x = swpClient.cx - ((sheight * 2) + 16);
4306 pswpNew->y = swpClient.y;
4307 pswpNew->cx = 12;
4308 pswpNew->cy = 12;
4309 sCount++;
4310 pswpNew = (PSWP) mp1 + (soldCount + 4 +
4311 (fToolbar != FALSE) +
4312 (fDrivebar != FALSE) +
4313 (fSplitStatus != FALSE) + (fAutoView != FALSE));
4314 *pswpNew = *pswpClient;
4315 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
4316 pswpNew->x = swpClient.cx - ((sheight * 2) + 16);
4317 pswpNew->y = swpClient.y + 12;
4318 pswpNew->cx = 12;
4319 pswpNew->cy = sheight - 8;
4320 sCount++;
4321 if (fUserComboBox) {
4322 if (!aheight) {
4323
4324 SWP swpTemp;
4325
4326 WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
4327 &swpTemp);
4328 aheight = swpTemp.cy;
4329 }
4330 pswpNew = (PSWP) mp1 + (soldCount + 5 +
4331 (fToolbar != FALSE) +
4332 (fSplitStatus != FALSE) +
4333 (fDrivebar != FALSE) + (fAutoView != FALSE));
4334 *pswpNew = *pswpClient;
4335 pswpNew->hwnd = hwndDrivelist;
4336 pswpNew->x = swpClient.x;
4337 pswpNew->cx = 48;
4338 pswpClient->cy -= (aheight + 6L);
4339 pswpNew->y = pswpClient->y;
4340 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4341 sCount++;
4342 pswpNew = (PSWP) mp1 + (soldCount + 6 +
4343 (fToolbar != FALSE) +
4344 (fDrivebar != FALSE) +
4345 (fSplitStatus != FALSE) +
4346 (fAutoView != FALSE));
4347 *pswpNew = *pswpClient;
4348 pswpNew->hwnd = hwndStatelist;
4349 pswpNew->x = swpClient.x + 48;
4350 pswpNew->cx = (swpClient.cx - 48) / 7;
4351 pswpNew->y = pswpClient->y;
4352 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4353 sCount++;
4354 pswpNew = (PSWP) mp1 + (soldCount + 7 +
4355 (fToolbar != FALSE) +
4356 (fDrivebar != FALSE) +
4357 (fSplitStatus != FALSE) +
4358 (fAutoView != FALSE));
4359 *pswpNew = *pswpClient;
4360 pswpNew->hwnd = hwndCmdlist;
4361 pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
4362 pswpNew->cx = (swpClient.cx - 48) / 5 +
4363 ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
4364 pswpNew->y = pswpClient->y;
4365 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4366 sCount++;
4367 pswpNew = (PSWP) mp1 + (soldCount + 8 +
4368 (fToolbar != FALSE) +
4369 (fDrivebar != FALSE) +
4370 (fSplitStatus != FALSE) +
4371 (fAutoView != FALSE));
4372 *pswpNew = *pswpClient;
4373 pswpNew->hwnd = hwndUserlist;
4374 pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
4375 pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
4376 ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
4377 pswpNew->y = pswpClient->y;
4378 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4379 sCount++;
4380 if (fToolbar) {
4381 pswpNew = (PSWP) mp1 + (soldCount + 9 +
4382 (fToolbar != FALSE) +
4383 (fDrivebar != FALSE) +
4384 (fSplitStatus != FALSE) +
4385 (fAutoView != FALSE));
4386 *pswpNew = *pswpClient;
4387 pswpNew->hwnd = hwndButtonlist;
4388 pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
4389 pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
4390 pswpNew->y = pswpClient->y;
4391 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4392 sCount++;
4393 }
4394 else
4395 WinShowWindow(hwndButtonlist, FALSE);
4396 }
4397 else {
4398 WinShowWindow(hwndUserlist, FALSE);
4399 WinShowWindow(hwndDrivelist, FALSE);
4400 WinShowWindow(hwndStatelist, FALSE);
4401 WinShowWindow(hwndButtonlist, FALSE);
4402 WinShowWindow(hwndCmdlist, FALSE);
4403 }
4404 {
4405 PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
4406 SHORT x;
4407
4408 pswpNew = (PSWP) mp1 + (soldCount + 5 +
4409 (fToolbar != FALSE) +
4410 (fDrivebar != FALSE) +
4411 (fSplitStatus != FALSE) +
4412 (fAutoView != FALSE) +
4413 ((fUserComboBox != FALSE) * 4) +
4414 (fUserComboBox != FALSE &&
4415 fToolbar != FALSE));
4416 pswp = (PSWP) mp1;
4417 for (x = 0; x < soldCount; x++) {
4418 if (!pswpTitlebar &&
4419 WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
4420 pswpTitlebar = pswp;
4421 else if (!pswpMinbutton &&
4422 WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
4423 pswpMinbutton = pswp;
4424 if (pswpTitlebar && pswpMinbutton)
4425 break;
4426 pswp++;
4427 }
4428 if (pswpMinbutton && pswpTitlebar) {
4429 *pswpNew = *pswpMinbutton;
4430 pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
4431 pswpNew->cy = pswpMinbutton->cy + 3;
4432 pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
4433 pswpTitlebar->cx -= (pswpNew->cx - 1);
4434 pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
4435 pswpNew->y = pswpMinbutton->y - 1;
4436 sCount++;
4437 }
4438 else
4439 WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
4440 }
4441
4442 if (fMoreButtons) {
4443
4444 LONG lastx;
4445
4446 pswpNew = (PSWP) mp1 + (soldCount + 6 +
4447 (fToolbar != FALSE) +
4448 (fDrivebar != FALSE) +
4449 (fSplitStatus != FALSE) +
4450 (fAutoView != FALSE) +
4451 ((fUserComboBox != FALSE) * 4) +
4452 (fUserComboBox != FALSE &&
4453 fToolbar != FALSE));
4454 *pswpNew = *pswpClient;
4455 pswpNew->hwnd = hwndName;
4456 pswpNew->x = swpClient.x + 3;
4457 pswpNew->y = swpClient.y + (sheight + 6);
4458 pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
4459 lastx = pswpNew->x + pswpNew->cx;
4460 pswpNew->cy = bheight;
4461 pswpClient->y += (bheight + 4);
4462 pswpClient->cy -= (bheight + 4);
4463 sCount++;
4464 pswpNew = (PSWP) mp1 + (soldCount + 7 +
4465 (fToolbar != FALSE) +
4466 (fDrivebar != FALSE) +
4467 (fSplitStatus != FALSE) +
4468 (fAutoView != FALSE) +
4469 ((fUserComboBox != FALSE) * 4) +
4470 (fUserComboBox != FALSE &&
4471 fToolbar != FALSE));
4472 *pswpNew = *pswpClient;
4473 pswpNew->hwnd = hwndDate;
4474 pswpNew->x = lastx + 3;
4475 pswpNew->y = swpClient.y + (sheight + 6);
4476 pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
4477 lastx = pswpNew->x + pswpNew->cx;
4478 pswpNew->cy = bheight;
4479 sCount++;
4480 pswpNew = (PSWP) mp1 + (soldCount + 8 +
4481 (fToolbar != FALSE) +
4482 (fDrivebar != FALSE) +
4483 (fSplitStatus != FALSE) +
4484 (fAutoView != FALSE) +
4485 ((fUserComboBox != FALSE) * 4) +
4486 (fUserComboBox != FALSE &&
4487 fToolbar != FALSE));
4488 *pswpNew = *pswpClient;
4489 pswpNew->hwnd = hwndAttr;
4490 pswpNew->x = lastx + 3;
4491 pswpNew->y = swpClient.y + (sheight + 6);
4492 pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
4493 pswpNew->cy = bheight;
4494 sCount++;
4495 }
4496 else {
4497 WinShowWindow(hwndAttr, FALSE);
4498 WinShowWindow(hwndName, FALSE);
4499 WinShowWindow(hwndDate, FALSE);
4500 }
4501 return MRFROMSHORT(sCount);
4502 }
4503
4504 case WM_QUERYFRAMECTLCOUNT:
4505 {
4506 SHORT sCount;
4507
4508 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
4509
4510 sCount += 6;
4511 if (fSplitStatus)
4512 sCount++;
4513 if (fToolbar)
4514 sCount++;
4515 if (fUserComboBox) {
4516 sCount += 4;
4517 if (fToolbar)
4518 sCount++;
4519 }
4520 if (fDrivebar)
4521 sCount++;
4522 if (fAutoView)
4523 sCount++;
4524 if (fMoreButtons)
4525 sCount += 3;
4526 return MRFROMSHORT(sCount);
4527 }
4528
4529 case WM_CLOSE:
4530 WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
4531 return 0;
4532 }
4533 return oldproc(hwnd, msg, mp1, mp2);
4534}
4535
4536MRESULT EXPENTRY MainWMCommand(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
4537{
4538 SetShiftState();
4539 switch (SHORT1FROMMP(mp1)) {
4540
4541 case IDM_CONTEXTMENU:
4542 {
4543 HWND hwnd = WinQueryFocus(HWND_DESKTOP);
4544 // DbgMsg(pszSrcFile, __LINE__, "IDM_CONTEXTMENU %x", hwnd);
4545 if (hwnd != NULLHANDLE) {
4546 HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
4547 USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
4548 switch (id) {
4549 case MAIN_SETUPLIST:
4550 case MAIN_USERLIST:
4551 case MAIN_CMDLIST:
4552 // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
4553 WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
4554 }
4555 }
4556 }
4557 break;
4558
4559 case IDM_SETTARGET:
4560 SetTargetDir(hwnd, FALSE);
4561 break;
4562
4563 case IDM_TOAUTOMLE:
4564 if (fComments && fAutoView)
4565 WinSetFocus(HWND_DESKTOP, hwndAutoMLE);
4566 break;
4567
4568 case IDM_HIDENOTEWND:
4569 HideNote();
4570 break;
4571 case IDM_SHOWNOTEWND:
4572 ShowNote();
4573 break;
4574
4575 case IDM_COMPARE:
4576 {
4577 WALK2 wa;
4578 PCNRITEM pci;
4579
4580 memset(&wa, 0, sizeof(wa));
4581 wa.size = sizeof(wa);
4582 pci =
4583 (PCNRITEM)
4584 WinSendMsg(WinWindowFromID
4585 (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
4586 CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
4587 MPFROMSHORT(CRA_CURSORED));
4588 if (pci && (INT) pci != -1) {
4589 strcpy(wa.szCurrentPath1, pci->pszFileName);
4590 MakeValidDir(wa.szCurrentPath1);
4591 }
4592 else
4593 strcpy(wa.szCurrentPath1, pFM2SaveDirectory);
4594 TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2);
4595 if (!*wa.szCurrentPath2)
4596 strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
4597 MakeValidDir(wa.szCurrentPath2);
4598 if (WinDlgBox(HWND_DESKTOP,
4599 hwnd,
4600 WalkTwoCmpDlgProc,
4601 FM3ModHandle,
4602 WALK2_FRAME,
4603 MPFROMP(&wa)) &&
4604 !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
4605 if (!*dircompare) {
4606
4607 COMPARE *cmp;
4608
4609 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
4610 if (cmp) {
4611 cmp->size = sizeof(COMPARE);
4612 strcpy(cmp->leftdir, wa.szCurrentPath1);
4613 strcpy(cmp->rightdir, wa.szCurrentPath2);
4614 cmp->hwndParent = hwnd;
4615 cmp->dcd.hwndParent = hwnd;
4616 WinDlgBox(HWND_DESKTOP,
4617 HWND_DESKTOP,
4618 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
4619 }
4620 }
4621 else {
4622
4623 CHAR szPath1[CCHMAXPATH];
4624 CHAR szPath2[CCHMAXPATH];
4625 runemf2(SEPARATE,
4626 HWND_DESKTOP, pszSrcFile, __LINE__,
4627 NULL, NULL,
4628 "%s %s %s",
4629 dircompare,
4630 BldQuotedFileName(szPath1, wa.szCurrentPath1),
4631 BldQuotedFileName(szPath2, wa.szCurrentPath2));
4632 }
4633 }
4634 }
4635 break;
4636
4637 case IDM_EXIT:
4638 case IDM_KILLME:
4639 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
4640 break;
4641
4642 case IDM_CLI:
4643 if (fSplitStatus &&
4644 hwndStatus2 &&
4645 !WinIsWindow(WinQueryAnchorBlock(hwnd),
4646 WinWindowFromID(hwndStatus2, COMMAND_LINE)))
4647 PostMsg(hwndStatus2, UM_CLICKED, MPVOID, MPVOID);
4648 break;
4649
4650 case IDM_ADDTOUSERLIST:
4651 case IDM_DELETEFROMUSERLIST:
4652 {
4653 CHAR temp[CCHMAXPATH], path[CCHMAXPATH];
4654
4655 *temp = 0;
4656 WinQueryWindowText(hwndUserlist, CCHMAXPATH, temp);
4657 bstrip(temp);
4658 if (*temp &&
4659 !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
4660 if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
4661 add_udir(TRUE, path);
4662 if (fUdirsChanged)
4663 save_udirs();
4664 WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
4665 }
4666 else {
4667 if (!remove_udir(path))
4668 Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
4669 else {
4670 if (fUdirsChanged)
4671 save_udirs();
4672 WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
4673 }
4674 }
4675 }
4676 }
4677 break;
4678
4679 case IDM_SAVEDIRCNRSTATE:
4680 case IDM_DELETEDIRCNRSTATE:
4681 {
4682 CHAR szStateName[STATE_NAME_MAX_BYTES + 1];
4683
4684 *szStateName = 0;
4685 WinQueryWindowText(hwndStatelist, STATE_NAME_MAX_BYTES, szStateName);
4686 bstrip(szStateName);
4687 // Complain if attempting to use reserved name
4688 if (stricmp(szStateName, GetPString(IDS_STATETEXT)) == 0 ||
4689 stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0)
4690 {
4691 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
4692 GetPString(IDS_WARNINGTEXT),
4693 "\"%s\" is a reserved state name", szStateName);
4694 }
4695 // Ignore request if blank
4696 else if (*szStateName) {
4697 BOOL fAbortOperation = FALSE;
4698 if (!fNoSaveState && fSaveState && stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
4699 {
4700 if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
4701 GetPString(IDS_WARNINGTEXT),
4702 GetPString(IDS_SHUTDOWNSTATE_WARNING), szStateName) == MBID_NO)
4703 fAbortOperation = TRUE;
4704 }
4705 if (!fAbortOperation) {
4706 if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
4707 // Save
4708 INT nSaved = SaveDirCnrState(hwnd, szStateName);
4709 if (nSaved >= 0) {
4710 INT ret = add_setup(szStateName);
4711 if (ret == 0) {
4712 WinSendMsg(hwndStatelist, LM_INSERTITEM,
4713 MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
4714 save_setups();
4715 }
4716 else if (ret != 1) {
4717 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
4718 GetPString(IDS_WARNINGTEXT),
4719 "\"%s\" state name add failed", szStateName); // 15 Apr 07 SHL failed
4720 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
4721 }
4722 }
4723 else {
4724 saymsg(MB_ENTER | MB_ICONASTERISK,
4725 hwnd,
4726 GetPString(IDS_WARNINGTEXT),
4727 "State data save failed");
4728 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
4729 }
4730 }
4731 else {
4732 // Delete
4733 ULONG numsaves = 0, size, x;
4734 CHAR s[STATE_NAME_MAX_BYTES + 80];
4735
4736 INT ret = remove_setup(szStateName);
4737 if (ret == 1)
4738 save_setups();
4739 sprintf(s, "%s.NumDirsLastTime", szStateName);
4740 size = sizeof(ULONG);
4741 if (!PrfQueryProfileData(fmprof,
4742 FM3Str,
4743 s,
4744 (PVOID)&numsaves,
4745 &size)) {
4746 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
4747 GetPString(IDS_WARNINGTEXT),
4748 GetPString(IDS_DOESNTEXISTTEXT), szStateName);
4749 }
4750 else if (!size)
4751 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
4752 else {
4753 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
4754 for (x = 0; x < numsaves; x++) {
4755 sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
4756 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4757 sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
4758 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4759 sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
4760 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4761 sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
4762 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4763 sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
4764 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4765 sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
4766 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4767 sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
4768 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4769 sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
4770 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4771 sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
4772 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4773 sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
4774 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4775 sprintf(s, "%s.DirCnr.%lu.DetailsIcon", szStateName, x);
4776 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4777 sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
4778 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4779 sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
4780 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4781 sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
4782 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4783 sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
4784 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4785 sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
4786 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4787 sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
4788 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4789 sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
4790 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4791 sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
4792 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4793 }
4794 sprintf(s, "%s.LastTreePos", szStateName);
4795 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4796 sprintf(s, "%s.MySizeLastTime", szStateName);
4797 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
4798 }
4799 PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
4800 }
4801 }
4802 }
4803 }
4804 break;
4805
4806 case IDM_IDEALSIZE:
4807 {
4808 SWP swp, swpD;
4809 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
4810 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
4811
4812 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
4813 if (swp.fl & SWP_MAXIMIZE) {
4814 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
4815 MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
4816 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
4817 }
4818 WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD);
4819 swpD.x += bsz;
4820 swpD.cx -= (bsz * 2);
4821 swpD.y += icz;
4822 swpD.cy -= (icz + bsz);
4823 if (swp.x == swpD.x && swp.y == swpD.y &&
4824 swp.cx == swpD.cx && swp.cy == swpD.cy &&
4825 // fixme to be #defined someday
4826 WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
4827 WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
4828 swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
4829 swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
4830 swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
4831 swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
4832 }
4833 else {
4834 WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
4835 WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
4836 WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
4837 WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
4838 }
4839 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP,
4840 swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
4841 }
4842 break;
4843
4844 case IDM_BLINK:
4845 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
4846 SWP_MINIMIZE);
4847 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
4848 SWP_RESTORE | SWP_ZORDER);
4849 break;
4850
4851 case DID_CANCEL:
4852 {
4853 HWND hwndTop = TopWindow(hwndMain, (HWND) 0);
4854
4855 if (hwndTop)
4856 WinSetFocus(HWND_DESKTOP, hwndTop);
4857 }
4858 break;
4859
4860 case IDM_NOTEBOOK:
4861 case IDM_DIRCNRSETTINGS:
4862 case IDM_DIRVIEWSETTINGS:
4863 case IDM_DIRSORTSETTINGS:
4864 case IDM_COLLECTORVIEWSETTINGS:
4865 case IDM_COLLECTORSORTSETTINGS:
4866 case IDM_ARCHIVERSETTINGS:
4867 case IDM_TREECNRVIEWSETTINGS:
4868 case IDM_TREECNRSORTSETTINGS:
4869 case IDM_VIEWERSETTINGS:
4870 case IDM_VIEWERSETTINGS2:
4871 case IDM_COMPARESETTINGS:
4872 case IDM_MONOLITHICSETTINGS:
4873 case IDM_GENERALSETTINGS:
4874 case IDM_SCANSETTINGS:
4875 case IDM_BUBBLESSETTINGS:
4876 case IDM_QUICKSETTINGS:
4877 WinDlgBox(HWND_DESKTOP,
4878 hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
4879 break;
4880
4881 case IDM_VIEWHELPS:
4882 case IDM_VIEWINFS:
4883 WinDlgBox(HWND_DESKTOP,
4884 HWND_DESKTOP,
4885 ViewInfProc,
4886 FM3ModHandle,
4887 VINF_FRAME,
4888 ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
4889 MPFROMP(NullStr) : MPVOID));
4890 break;
4891
4892 case IDM_OPENWALK:
4893 {
4894 char newpath[CCHMAXPATH];
4895
4896 *newpath = 0;
4897 TopWindowName(hwnd, (HWND) 0, newpath);
4898 if (WinDlgBox(HWND_DESKTOP,
4899 hwnd,
4900 WalkAllDlgProc,
4901 FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
4902 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
4903 }
4904 break;
4905
4906 case IDM_WINDOWDLG:
4907 WindowList(hwnd);
4908 break;
4909
4910 case IDM_HELPMOUSE:
4911 case IDM_HELPCONTEXT:
4912 case IDM_HELPHINTS:
4913 case IDM_HELPPIX:
4914 case IDM_HELPTUTOR:
4915 case IDM_HELPUSERLIST:
4916 case IDM_HELP:
4917 case IDM_HELPCONTENTS:
4918 case IDM_HELPKEYS:
4919 case IDM_HELPGENERAL:
4920 if (hwndHelp) {
4921 if (SHORT1FROMMP(mp2) == CMDSRC_MENU) {
4922
4923 RECTL rcl;
4924 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
4925
4926 WinQueryWindowRect(HWND_DESKTOP, &rcl);
4927 rcl.yBottom += icz;
4928 rcl.yTop -= icz;
4929 rcl.xLeft += icz;
4930 rcl.xRight -= icz;
4931 WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
4932 }
4933 else {
4934
4935 RECTL rcl;
4936
4937 WinQueryWindowRect(HWND_DESKTOP, &rcl);
4938 rcl.yBottom += 8;
4939 rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
4940 rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
4941 rcl.xRight -= 8;
4942 WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
4943 }
4944 switch (SHORT1FROMMP(mp1)) {
4945 case IDM_HELPCONTEXT:
4946 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4947 MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
4948 break;
4949
4950 case IDM_HELPMOUSE:
4951 if (hwndHelp)
4952 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4953 MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
4954 break;
4955
4956 case IDM_HELPPIX:
4957 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4958 MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
4959 break;
4960
4961 case IDM_HELPTUTOR:
4962 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4963 MPFROM2SHORT(HELP_TUTORIAL, 0),
4964 MPFROMSHORT(HM_RESOURCEID));
4965 break;
4966
4967 case IDM_HELPHINTS:
4968 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4969 MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
4970 break;
4971
4972 case IDM_HELPGENERAL:
4973 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4974 MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
4975 break;
4976 case IDM_HELPKEYS:
4977 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4978 MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
4979 break;
4980
4981 case IDM_HELP:
4982 case IDM_HELPCONTENTS:
4983 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
4984 break;
4985
4986 case IDM_HELPUSERLIST:
4987 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4988 MPFROM2SHORT(HELP_USERLISTS, 0),
4989 MPFROMSHORT(HM_RESOURCEID));
4990 break;
4991 }
4992 }
4993 break;
4994
4995 case IDM_EDITANYARCHIVER:
4996 EditArchiverDefinition(hwnd);
4997 break;
4998
4999 case IDM_ABOUT:
5000 WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle,
5001 ABT_FRAME, MPVOID);
5002 break;
5003
5004 case IDM_FONTPALETTE:
5005 OpenObject("<WP_FNTPAL>", Default, hwnd);
5006 break;
5007
5008 case IDM_HICOLORPALETTE:
5009 case IDM_COLORPALETTE:
5010 {
5011 CHAR *palette = "<WP_CLRPAL>";
5012 ULONG version[2];
5013
5014 if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
5015 (PVOID) & version, (ULONG) sizeof(version))) {
5016 if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
5017 if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
5018 palette = "<WP_HIRESCLRPAL>";
5019 else
5020 palette = "<WP_LORESCLRPAL>";
5021 }
5022 }
5023 OpenObject(palette, Default, hwnd);
5024 }
5025 break;
5026
5027 case IDM_SYSTEMSETUP:
5028 OpenObject("<WP_CONFIG>", Default, hwnd);
5029 break;
5030
5031 case IDM_SCHEMEPALETTE:
5032 {
5033 HOBJECT hWPSObject;
5034
5035 hWPSObject = WinQueryObject("<WP_SCHPAL>");
5036 if (hWPSObject != NULLHANDLE)
5037 WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
5038 "Spring:PM_Spring,Summer:PM_Summer,"
5039 "System:PM_System,Windows:PM_Windows;"
5040 "OPEN=DEFAULT");
5041 }
5042 break;
5043
5044 case IDM_SYSTEMCLOCK:
5045 OpenObject("<WP_CLOCK>", Default, hwnd);
5046 break;
5047
5048#ifdef NEVER
5049 case IDM_SYSINFO:
5050 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle,
5051 SYS_FRAME, NULL);
5052 break;
5053#endif
5054
5055 case IDM_INSTANT:
5056 {
5057 CHAR path[CCHMAXPATH];
5058 PCNRITEM pci = (PCNRITEM) 0;
5059
5060 if (hwndTree)
5061 pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
5062 MPFROMLONG(CMA_FIRST),
5063 MPFROMSHORT(CRA_CURSORED));
5064 if (pci && (INT) pci != -1) {
5065 strcpy(path, pci->pszFileName);
5066 MakeValidDir(path);
5067 }
5068 else
5069 strcpy(path, pFM2SaveDirectory);
5070 WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle,
5071 BAT_FRAME, MPFROMP(path));
5072 }
5073 break;
5074
5075 case IDM_WINFULLSCREEN:
5076 case IDM_DOSCOMMANDLINE:
5077 case IDM_COMMANDLINE:
5078 {
5079 CHAR *env = GetCmdSpec(FALSE), path[CCHMAXPATH];
5080 INT type = SEPARATE | WINDOWED;
5081
5082 *path = 0;
5083 TopWindowName(hwnd, (HWND) 0, path);
5084 if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE)
5085 env = GetCmdSpec(TRUE);
5086 else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) {
5087 env = "WINOS2.COM";
5088 type = SEPARATE | FULLSCREEN;
5089 }
5090 runemf2(type, hwnd, pszSrcFile, __LINE__,
5091 path, NULL, "%s", env);
5092 }
5093 break;
5094
5095 case IDM_KILLPROC:
5096 WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle,
5097 KILL_FRAME, NULL);
5098 break;
5099
5100 case IDM_AUTOVIEWCOMMENTS:
5101 case IDM_AUTOVIEWFILE:
5102 if (SHORT1FROMMP(mp1) == IDM_AUTOVIEWFILE)
5103 fComments = FALSE;
5104 else
5105 fComments = TRUE;
5106 PrfWriteProfileData(fmprof, FM3Str, "Comments", &fComments, sizeof(BOOL));
5107 WinSetWindowText((fComments) ? hwndAutoview : hwndAutoMLE, NullStr);
5108 goto AutoChange;
5109
5110 case IDM_AUTOVIEW:
5111 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
5112 &fAutoView, TRUE, "AutoView");
5113 AutoChange:
5114 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
5115 MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5116 if (fAutoView) {
5117
5118 CHAR s[CCHMAXPATH];
5119 HWND hwndDir;
5120 PCNRITEM pci;
5121
5122 hwndDir = TopWindowName(hwnd, (HWND) 0, s);
5123 if (hwndDir) {
5124 hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
5125 if (hwndDir) {
5126 hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
5127 if (hwndDir) {
5128 pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
5129 MPFROMLONG(CMA_FIRST),
5130 MPFROMSHORT(CRA_CURSORED));
5131 if (pci && (INT) pci != -1 &&
5132 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
5133 WinSendMsg(hwnd,
5134 UM_LOADFILE,
5135 MPFROMP(pci->pszFileName),
5136 (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
5137 MPVOID : MPFROMLONG(1));
5138 }
5139 }
5140 }
5141 }
5142 break;
5143
5144 case IDM_TEXTTOOLS:
5145 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
5146 &fTextTools, TRUE, "TextTools");
5147 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5148 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
5149 MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5150 break;
5151
5152 case IDM_TOOLTITLES:
5153 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
5154 &fToolTitles, TRUE, "ToolTitles");
5155 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5156 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
5157 MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5158 break;
5159
5160 case IDM_HIDEMENU:
5161 {
5162 HWND hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
5163 MenuInvisible = MenuInvisible ? FALSE : TRUE;
5164 if (MenuInvisible) {
5165 WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
5166 WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5167 FID_SYSMENU), IDM_HIDEMENU,
5168 GetPString(IDS_UNHIDEMENUTEXT));
5169 }
5170 else {
5171 WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
5172 WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5173 FID_SYSMENU), IDM_HIDEMENU,
5174 GetPString(IDS_HIDEMENUTEXT));
5175 }
5176 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
5177 MPFROMLONG(FCF_MENU), MPVOID);
5178 PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible",
5179 &MenuInvisible, sizeof(BOOL));
5180 }
5181 break;
5182
5183 case IDM_SEEALL:
5184 case IDM_GREP:
5185 case IDM_COLLECTOR:
5186 {
5187 HWND hwndC;
5188 SWP swp;
5189 BOOL already = FALSE;
5190
5191 if (Collector)
5192 already = TRUE;
5193 if (!already && !fAutoTile && !fExternalCollector)
5194 GetNextWindowPos(hwnd, &swp, NULL, NULL);
5195 hwndC = StartCollector(fExternalCollector ? HWND_DESKTOP : hwnd, 4);
5196 if (hwndC) {
5197 if (!already && !fAutoTile && !fExternalCollector)
5198 WinSetWindowPos(hwndC, HWND_TOP,
5199 swp.x, swp.y, swp.cx, swp.cy,
5200 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
5201 else if (fAutoTile && !already)
5202 TileChildren(hwnd, TRUE);
5203 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
5204 SWP_ACTIVATE);
5205 if (SHORT1FROMMP(mp1) == IDM_GREP)
5206 PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
5207 MPFROM2SHORT(IDM_GREP, 0), MPVOID);
5208 if (SHORT1FROMMP(mp1) == IDM_SEEALL)
5209 PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
5210 MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
5211 }
5212 }
5213 break;
5214
5215 case IDM_TOOLLEFT:
5216 case IDM_TOOLRIGHT:
5217 {
5218 TOOL *tool;
5219
5220 if (!toolhead || !toolhead->next) {
5221 firsttool = (toolhead) ? toolhead->id : 0;
5222 break;
5223 }
5224 tool = find_tool(firsttool);
5225 if (!tool)
5226 tool = toolhead;
5227 if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) {
5228 tool = prev_tool(tool, TRUE);
5229 firsttool = tool->id;
5230 }
5231 else {
5232 tool = next_tool(tool, TRUE);
5233 firsttool = tool->id;
5234 }
5235 ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5236 MAIN_TOOLS));
5237 }
5238 break;
5239
5240 case IDM_CREATETOOL:
5241 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5242 break;
5243
5244 case IDM_TOOLBAR:
5245 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5246 IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
5247 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5248 WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5249 MAIN_TOOLS), fToolbar);
5250 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
5251 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5252 if (fDrivebar)
5253 WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5254 MAIN_DRIVES), NULL, TRUE);
5255 break;
5256
5257 case IDM_DRIVEBAR:
5258 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5259 IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
5260 WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5261 MAIN_DRIVES), fDrivebar);
5262 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
5263 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5264 PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
5265 break;
5266
5267 case IDM_USERLIST:
5268 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5269 SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
5270 WinShowWindow(hwndUserlist, fUserComboBox);
5271 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
5272 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5273 PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
5274 PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
5275 PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID);
5276 PostMsg(hwnd, UM_FILLBUTTONLIST, MPVOID, MPVOID);
5277 break;
5278
5279 case IDM_MOREBUTTONS:
5280 WinSetWindowText(hwndName, NullStr);
5281 WinSetWindowText(hwndDate, NullStr);
5282 WinSetWindowText(hwndAttr, NullStr);
5283 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5284 SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
5285 if (fMoreButtons) {
5286
5287 HWND hwndTemp;
5288
5289 hwndTemp = TopWindow(hwnd, (HWND) 0);
5290
5291 if (hwndTemp) {
5292 WinSetFocus(HWND_DESKTOP, hwnd);
5293 WinSetFocus(HWND_DESKTOP, hwndTemp);
5294 }
5295 }
5296 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
5297 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5298 break;
5299
5300 case IDM_TOGGLEDRAGDIALOG:
5301 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5302 IDM_TOGGLEDRAGDIALOG,
5303 &fDragndropDlg,
5304 TRUE,
5305 "Drag&DropDlg");
5306 break;
5307
5308 case IDM_SYNCUPDATES:
5309 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5310 IDM_SYNCUPDATES,
5311 &fSyncUpdates,
5312 TRUE,
5313 "SyncUpdates");
5314 break;
5315
5316 case IDM_FREETREE:
5317 if (fFreeTree) {
5318 SWP swp, swpT;
5319
5320 WinQueryWindowPos(hwndTree, &swpT);
5321 WinQueryWindowPos(hwnd, &swp);
5322 WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0,
5323 SWP_MOVE);
5324 }
5325 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
5326 &fFreeTree, TRUE, "FreeTree");
5327 if (fAutoTile)
5328 TileChildren(hwnd, TRUE);
5329 break;
5330
5331 case IDM_AUTOTILE:
5332 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5333 SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
5334 if (fAutoTile)
5335 TileChildren(hwnd, TRUE);
5336 break;
5337
5338 case IDM_TILEBACKWARDS:
5339 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5340 SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
5341 if (fAutoTile)
5342 TileChildren(hwnd, TRUE);
5343 break;
5344
5345 case IDM_NEXTWINDOW:
5346 case IDM_PREVWINDOW:
5347 NextChild(hwnd, (SHORT1FROMMP(mp1) == IDM_PREVWINDOW));
5348 break;
5349
5350 case IDM_CASCADE:
5351 CascadeChildren(hwnd);
5352 break;
5353
5354 case IDM_TILE:
5355 TileChildren(hwnd, TRUE);
5356 break;
5357
5358 case IDM_RESTORE:
5359 MinResChildren(hwnd, SWP_RESTORE);
5360 break;
5361
5362 case IDM_MINIMIZE:
5363 MinResChildren(hwnd, SWP_MINIMIZE);
5364 break;
5365
5366 case IDM_ARRANGEICONS:
5367 ArrangeIcons(hwnd);
5368 break;
5369
5370 case IDM_INIVIEWER:
5371 StartIniEditor(hwnd, NULL, 4);
5372 break;
5373
5374 case IDM_EDITASSOC:
5375 EditAssociations(hwnd);
5376 break;
5377
5378 case IDM_EDITCOMMANDS:
5379 EditCommands(hwnd);
5380 PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID);
5381 break;
5382
5383 default:
5384 if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER),
5385 SHORT1FROMMP(mp1))) {
5386 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
5387 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
5388
5389 INT x;
5390 HWND hwndCnr;
5391
5392 if (!cmdloaded)
5393 load_commands();
5394 hwndCnr = TopWindow(hwnd, (HWND) 0);
5395 hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
5396 UM_CONTAINERHWND, MPVOID, MPVOID);
5397 if (!hwndCnr) {
5398 Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
5399 break;
5400 }
5401 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
5402 if (x >= 0) {
5403 x++;
5404 RunCommand(hwndCnr, x);
5405 if (fUnHilite) {
5406
5407 PCNRITEM pci;
5408 DIRCNRDATA *dcd = NULL;
5409
5410 // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
5411 if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
5412 dcd = INSTDATA(hwndCnr);
5413 pci = (PCNRITEM) WinSendMsg(hwndCnr,
5414 CM_QUERYRECORDEMPHASIS,
5415 MPFROMLONG(CMA_FIRST),
5416 MPFROMSHORT(CRA_CURSORED));
5417 if (pci && (INT) pci != -1 &&
5418 (pci->rc.flRecordAttr & CRA_SELECTED))
5419 {
5420 UnHilite(hwnd,
5421 TRUE,
5422 dcd ? &dcd->lastselection : NULL,
5423 dcd ? dcd ->ulItemsToUnHilite : 0);
5424 }
5425 }
5426 }
5427 }
5428 else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
5429 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) {
5430 if (!qtloaded)
5431 load_quicktools();
5432 if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) {
5433 if (fToolsChanged)
5434 save_tools(NULL);
5435 if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]))
5436 load_tools(NULL);
5437 else {
5438 strcpy(lasttoolbar,
5439 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]);
5440 PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
5441 }
5442 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5443 }
5444 }
5445 else {
5446
5447 HWND hwndActive;
5448
5449 hwndActive = TopWindow(hwnd, (HWND) 0);
5450 if (hwndActive)
5451 PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
5452 WM_COMMAND, mp1, mp2);
5453 }
5454 }
5455 break; // default
5456 } // switch mp1
5457 return 0;
5458}
5459
5460static MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1,
5461 MPARAM mp2)
5462{
5463 TID tid;
5464 SWP swp;
5465 PFNWP oldproc;
5466 HWND hwndTmp;
5467 HWND hwndFrame;
5468 HWND hwndSysMenu, hwndSysSubMenu, hwndMenu;
5469 USHORT idSysMenu;
5470 MENUITEM mi, mit;
5471 ULONG size;
5472 BOOL temp = FALSE;
5473
5474 switch (msg) {
5475 case WM_CREATE:
5476 WinQueryWindowProcess(hwnd, &mypid, &tid);
5477 hwndMain = hwnd;
5478 WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
5479 WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
5480 WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
5481 WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
5482 if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
5483 Runtime_Error(pszSrcFile, __LINE__,
5484 GetPString(IDS_COULDNTSTARTTHREADTEXT));
5485 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
5486 return 0;
5487 }
5488 else
5489 DosSleep(32);//05 Aug 07 GKY 64
5490
5491 hwndFrame = WinQueryWindow(hwnd, QW_PARENT);
5492
5493 /*
5494 * create frame children (not client children, frame children)
5495 */
5496 DosSleep(1);
5497 WinQueryWindowPos(hwndFrame, &swp);
5498 oldproc = WinSubclassWindow(hwndFrame, MainFrameWndProc);
5499 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
5500 CommonCreateMainChildren(hwnd, &swp);
5501
5502 if (!WinCreateWindow(hwndFrame,
5503 WC_BUTTON,
5504 "I",
5505 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
5506 ((swp.cx -
5507 WinQuerySysValue(HWND_DESKTOP,
5508 SV_CXMINMAXBUTTON)) -
5509 WinQuerySysValue(HWND_DESKTOP,
5510 SV_CXMINMAXBUTTON) / 2) -
5511 WinQuerySysValue(HWND_DESKTOP,
5512 SV_CXSIZEBORDER),
5513 (swp.cy - WinQuerySysValue(HWND_DESKTOP,
5514 SV_CYMINMAXBUTTON)) -
5515 WinQuerySysValue(HWND_DESKTOP,
5516 SV_CYSIZEBORDER),
5517 WinQuerySysValue(HWND_DESKTOP,
5518 SV_CXMINMAXBUTTON) / 2,
5519 WinQuerySysValue(HWND_DESKTOP,
5520 SV_CYMINMAXBUTTON),
5521 hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
5522 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
5523 }
5524 else {
5525 WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_IDEALSIZE),
5526 IdealButtonProc);
5527 SetPresParams(WinWindowFromID(hwndFrame,
5528 IDM_IDEALSIZE),
5529 NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
5530 }
5531
5532 hwndTmp = WinCreateWindow(hwndFrame,
5533 WC_BUTTON,
5534 "#1019",
5535 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
5536 BS_BITMAP,
5537 swp.cx - 46,
5538 swp.y + 2,
5539 24,
5540 22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
5541 if (!hwndTmp)
5542 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
5543
5544 hwndTmp = WinCreateWindow(hwndFrame,
5545 WC_BUTTON,
5546 "#3062",
5547 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
5548 BS_BITMAP,
5549 swp.cx - 22,
5550 swp.y + 2,
5551 24,
5552 22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
5553 if (!hwndTmp)
5554 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
5555
5556 hwndUserlist = WinCreateWindow(hwndFrame,
5557 WC_COMBOBOX,
5558 (PSZ) NULL,
5559 WS_VISIBLE | CBS_DROPDOWN |
5560 LS_HORZSCROLL,
5561 (swp.x +
5562 WinQuerySysValue(HWND_DESKTOP,
5563 SV_CXSIZEBORDER) + 48L),
5564 (swp.cy -
5565 WinQuerySysValue(HWND_DESKTOP,
5566 SV_CYSIZEBORDER)) - 60,
5567 ((swp.cx -
5568 (WinQuerySysValue(HWND_DESKTOP,
5569 SV_CXSIZEBORDER) *
5570 2)) - 64L), 60L, hwndFrame, HWND_TOP,
5571 MAIN_USERLIST, NULL, NULL);
5572 if (!hwndUserlist)
5573 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
5574 hwndCmdlist = WinCreateWindow(hwndFrame,
5575 WC_COMBOBOX,
5576 (PSZ) NULL,
5577 WS_VISIBLE | CBS_DROPDOWN |
5578 LS_HORZSCROLL,
5579 (swp.x +
5580 WinQuerySysValue(HWND_DESKTOP,
5581 SV_CXSIZEBORDER) + 48L),
5582 (swp.cy -
5583 WinQuerySysValue(HWND_DESKTOP,
5584 SV_CYSIZEBORDER)) - 60,
5585 ((swp.cx -
5586 (WinQuerySysValue(HWND_DESKTOP,
5587 SV_CXSIZEBORDER) * 2)) -
5588 64L), 60L, hwndFrame, HWND_TOP,
5589 MAIN_CMDLIST, NULL, NULL);
5590 if (!hwndCmdlist)
5591 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
5592 WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
5593 hwndStatelist = WinCreateWindow(hwndFrame,
5594 WC_COMBOBOX,
5595 (PSZ) NULL,
5596 WS_VISIBLE | CBS_DROPDOWN |
5597 LS_HORZSCROLL,
5598 (swp.x +
5599 WinQuerySysValue(HWND_DESKTOP,
5600 SV_CXSIZEBORDER) + 48L),
5601 (swp.cy -
5602 WinQuerySysValue(HWND_DESKTOP,
5603 SV_CYSIZEBORDER)) - 60,
5604 ((swp.cx -
5605 (WinQuerySysValue(HWND_DESKTOP,
5606 SV_CXSIZEBORDER) *
5607 2)) - 64L), 60L, hwndFrame, HWND_TOP,
5608 MAIN_SETUPLIST, NULL, NULL);
5609 if (!hwndStatelist)
5610 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
5611
5612 hwndDrivelist = WinCreateWindow(hwndFrame,
5613 WC_COMBOBOX,
5614 (PSZ) NULL,
5615 WS_VISIBLE | CBS_DROPDOWN,
5616 (swp.x +
5617 WinQuerySysValue(HWND_DESKTOP,
5618 SV_CXSIZEBORDER)),
5619 (swp.cy -
5620 WinQuerySysValue(HWND_DESKTOP,
5621 SV_CYSIZEBORDER)) - 60,
5622 48L,
5623 60L,
5624 hwndFrame,
5625 HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
5626 if (!hwndDrivelist)
5627 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
5628 SetPresParams(hwndDrivelist,
5629 NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
5630 hwndButtonlist = WinCreateWindow(hwndFrame,
5631 WC_COMBOBOX,
5632 (PSZ) NULL,
5633 WS_VISIBLE | CBS_DROPDOWN |
5634 LS_HORZSCROLL,
5635 (swp.cx -
5636 WinQuerySysValue(HWND_DESKTOP,
5637 SV_CXSIZEBORDER)) -
5638 164L,
5639 (swp.cy -
5640 WinQuerySysValue(HWND_DESKTOP,
5641 SV_CYSIZEBORDER)) - 60,
5642 164L, 60L, hwndFrame, HWND_TOP,
5643 MAIN_BUTTONLIST, NULL, NULL);
5644 if (!hwndButtonlist)
5645 Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
5646 WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT),
5647 EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
5648 WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT),
5649 EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
5650 WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT),
5651 EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
5652 WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT),
5653 EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
5654 WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT),
5655 EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
5656
5657 oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT),
5658 DropDownListProc);
5659 WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT),
5660 QWL_USER, (PVOID) oldproc);
5661 oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT),
5662 DropDownListProc);
5663 WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT),
5664 QWL_USER, (PVOID) oldproc);
5665 oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT),
5666 DropDownListProc);
5667 WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT),
5668 QWL_USER, (PVOID) oldproc);
5669 oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT),
5670 DropDownListProc);
5671 WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT),
5672 QWL_USER, (PVOID) oldproc);
5673 oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT),
5674 DropDownListProc);
5675 WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT),
5676 QWL_USER, (PVOID) oldproc);
5677 oldproc = WinSubclassWindow(hwndUserlist, DropDownListProc);
5678 WinSetWindowPtr(hwndUserlist, QWL_USER, (PVOID) oldproc);
5679 oldproc = WinSubclassWindow(hwndCmdlist, DropDownListProc);
5680 WinSetWindowPtr(hwndCmdlist, QWL_USER, (PVOID) oldproc);
5681 oldproc = WinSubclassWindow(hwndStatelist, DropDownListProc);
5682 WinSetWindowPtr(hwndStatelist, QWL_USER, (PVOID) oldproc);
5683 oldproc = WinSubclassWindow(hwndDrivelist, DropDownListProc);
5684 WinSetWindowPtr(hwndDrivelist, QWL_USER, (PVOID) oldproc);
5685 oldproc = WinSubclassWindow(hwndButtonlist, DropDownListProc);
5686 WinSetWindowPtr(hwndButtonlist, QWL_USER, (PVOID) oldproc);
5687 oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_USERLIST),
5688 ChildFrameButtonProc);
5689 WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_USERLIST),
5690 QWL_USER, (PVOID) oldproc);
5691 oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_OPENWALK),
5692 ChildFrameButtonProc);
5693 WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_OPENWALK),
5694 QWL_USER, (PVOID) oldproc);
5695 hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
5696 WinSendMsg(hwnd, UM_ADDTOMENU, MPVOID, MPVOID);
5697 SetToggleChecks(hwndMenu);
5698 CfgMenuInit(hwndMenu, FALSE); // 14 Feb 08 SHL
5699 SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE);
5700 SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
5701 SetConditionalCascade(hwndMenu, IDM_AUTOVIEWSUBMENU, IDM_AUTOVIEW);
5702 SetConditionalCascade(hwndMenu, IDM_TILEMENU, IDM_TILE);
5703 WinSetWindowULong(hwnd, QWL_USER, hwndMenu);
5704 memset(&mi, 0, sizeof(mi));
5705 memset(&mit, 0, sizeof(mit));
5706 hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
5707 idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu,
5708 MM_ITEMIDFROMPOSITION,
5709 MPVOID, MPVOID));
5710 WinSendMsg(hwndSysMenu,
5711 MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
5712 hwndSysSubMenu = mit.hwndSubMenu;
5713 mi.iPosition = MIT_END;
5714 mi.afStyle = MIS_SEPARATOR;
5715 mi.id = (USHORT) - 1;
5716 WinSendMsg(hwndSysSubMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(NULL));
5717 mi.afStyle = MIS_TEXT;
5718 mi.id = IDM_IDEALSIZE;
5719 WinSendMsg(hwndSysSubMenu,
5720 MM_INSERTITEM,
5721 MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
5722 mi.afStyle = MIS_TEXT;
5723 mi.id = IDM_HIDEMENU;
5724 WinSendMsg(hwndSysSubMenu,
5725 MM_INSERTITEM,
5726 MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
5727 SetSysMenu(hwndSysMenu);
5728
5729 size = sizeof(BOOL);
5730 if (PrfQueryProfileData(fmprof,
5731 FM3Str,
5732 "MenuInvisible", &temp, &size) && size && temp)
5733 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HIDEMENU, 0), MPVOID);
5734 size = sizeof(BOOL);
5735 if (PrfQueryProfileData(fmprof,
5736 FM3Str, "FreeTree", &temp, &size) && size && temp)
5737 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_FREETREE, 0), MPVOID);
5738 size = sizeof(BOOL);
5739 if (PrfQueryProfileData(fmprof,
5740 FM3Str,
5741 "AutoTile", &temp, &size) && size && !temp)
5742 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_AUTOTILE, 0), MPVOID);
5743 size = sizeof(BOOL);
5744 if (PrfQueryProfileData(fmprof,
5745 FM3Str, "Toolbar", &temp, &size) && size && !temp)
5746 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
5747
5748 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "FM/2");
5749 FixSwitchList(hwndFrame, NULL);
5750 break; // WM_CREATE
5751
5752 case UM_SETUP:
5753 /*
5754 * start up some initial children
5755 */
5756 WinShowWindow(WinQueryWindow(hwnd, QW_PARENT), TRUE);
5757 PostMsg(MainObjectHwnd, UM_SETUP2, mp1, mp2);
5758 return 0;
5759
5760 case UM_SETUP2:
5761 {
5762 SWP swp;
5763 ULONG size = sizeof(SWP);
5764
5765 WinQueryWindowPos(hwnd, &swp);
5766 hwndTree = StartTreeCnr(hwnd, 4);
5767 if (!hwndTree)
5768 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
5769 else {
5770 if (!fSaveState ||
5771 !PrfQueryProfileData(fmprof,
5772 FM3Str,
5773 "LastTreePos",
5774 &swp, &size) || size != sizeof(SWP)) {
5775
5776 INT ratio, height = 0;
5777
5778 if (!fNoTreeGap)
5779 height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
5780 size = sizeof(ratio);
5781 if (!PrfQueryProfileData(fmprof,
5782 FM3Str,
5783 "TreeWindowRatio",
5784 (PVOID) & ratio,
5785 &size) || size < sizeof(ratio))
5786 ratio = 400;
5787 WinSetWindowPos(hwndTree,
5788 HWND_TOP,
5789 0,
5790 height,
5791 (swp.cx * 100) / ratio,
5792 swp.cy - height,
5793 SWP_SHOW | SWP_SIZE | SWP_MOVE |
5794 SWP_ACTIVATE | SWP_ZORDER);
5795 }
5796 else
5797 WinSetWindowPos(hwndTree,
5798 HWND_TOP,
5799 swp.x,
5800 swp.y,
5801 swp.cx,
5802 swp.cy,
5803 swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
5804 SWP_ZORDER | SWP_ACTIVATE);
5805 }
5806// ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5807// MAIN_TOOLS));
5808 }
5809 PostMsg(MainObjectHwnd, UM_SETUP3, mp1, mp2);
5810 return 0;
5811
5812 case UM_SETUP3:
5813 /* start remaining child windows */
5814 if (!fNoSaveState && fSaveState) {
5815 PSZ pszStatename = GetPString(IDS_SHUTDOWNSTATE);
5816 PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszStatename), MPVOID);
5817 if (!add_setup(pszStatename))
5818 save_setups();
5819 } else {
5820 load_tools(NULL);
5821 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5822 }
5823 PostMsg(MainObjectHwnd, UM_SETUP4, mp1, mp2);
5824 return 0;
5825
5826 case UM_SETUP4:
5827 {
5828 INT argc = (INT) mp1, x;
5829 CHAR **argv = (CHAR **) mp2;
5830
5831 for (x = 1; x < argc; x++) {
5832 if (*argv[x] == '/' || *argv[x] == ';')
5833 continue;
5834 if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE))
5835 OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
5836 }
5837 }
5838 PostMsg(MainObjectHwnd, UM_SETUP5, MPVOID, MPVOID);
5839 return 0;
5840
5841 case UM_SETUP5:
5842// if (fAutoTile)
5843// TileChildren(hwnd, TRUE);
5844 PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
5845 PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
5846 PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID);
5847 PostMsg(hwnd, UM_FILLBUTTONLIST, MPVOID, MPVOID);
5848 {
5849 HWND hwndActive;
5850
5851 hwndActive = TopWindow(hwnd, hwndTree);
5852 if (hwndActive)
5853 WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
5854 }
5855 if (fStartMinimized || fReminimize)
5856 PostMsg(hwndTree, UM_MINIMIZE, MPVOID, MPVOID);
5857 else if (fStartMaximized)
5858 PostMsg(hwndTree, UM_MAXIMIZE, MPVOID, MPVOID);
5859 fRunning = TRUE;
5860 if (fWantFirstTimeInit) {
5861 fWantFirstTimeInit = FALSE;
5862 PostMsg(hwnd, WM_COMMAND, MPFROMLONG(IDM_QUICKSETTINGS), MPVOID);
5863 }
5864 return 0;
5865 }
5866
5867 return WinDefWindowProc(hwnd, msg, mp1, mp2);
5868}
5869
5870MRESULT EXPENTRY MainWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
5871{
5872 switch (msg) {
5873 case WM_CREATE:
5874# ifdef FORTIFY
5875 Fortify_EnterScope();
5876# endif
5877 case UM_SETUP:
5878 case UM_SETUP2:
5879 case UM_SETUP3:
5880 case UM_SETUP4:
5881 case UM_SETUP5:
5882 return MainWMOnce(hwnd, msg, mp1, mp2);
5883
5884 case WM_CONTROLPOINTER:
5885 if (!fNoFinger &&
5886 (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
5887 SHORT1FROMMP(mp1) == IDM_USERLIST))
5888 return MRFROMLONG(hptrFinger);
5889 break;
5890
5891 case UM_LOADFILE:
5892 case UM_THREADUSE:
5893 case UM_BUILDDRIVEBAR:
5894 return CommonMainWndProc(hwnd, msg, mp1, mp2);
5895
5896 case WM_BUTTON1UP:
5897 case WM_BUTTON2UP:
5898 case WM_BUTTON3UP:
5899 case WM_MOUSEMOVE:
5900 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
5901 break;
5902
5903 case WM_CHAR:
5904 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
5905 break;
5906
5907 case WM_MENUEND:
5908 if ((HWND) mp2 == MainPopupMenu) {
5909 WinDestroyWindow(MainPopupMenu);
5910 MainPopupMenu = (HWND) 0;
5911 }
5912 break;
5913
5914 case UM_CONTEXTMENU:
5915 case WM_CONTEXTMENU:
5916 if (CheckMenu(hwndMainMenu, &MainPopupMenu, MAIN_POPUP)) {
5917 SetToggleChecks(MainPopupMenu);
5918 PopupMenu(hwnd, hwnd, MainPopupMenu);
5919 }
5920 if (msg == UM_CONTEXTMENU)
5921 return 0;
5922 return MRFROMSHORT(TRUE);
5923
5924 case UM_SETUSERLISTNAME:
5925 if (mp1) {
5926 if (fUserComboBox)
5927 WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
5928 (CHAR *)mp1);
5929 if (add_udir(FALSE, (CHAR *)mp1)) {
5930 if (fUserComboBox && fAutoAddDirs) {
5931 WinSendMsg(hwndUserlist, LM_INSERTITEM,
5932 MPFROM2SHORT(LIT_SORTASCENDING, 0),
5933 MPFROMP((CHAR *)mp1));
5934 }
5935 }
5936 }
5937 return 0;
5938
5939 case UM_ARRANGEICONS:
5940 ArrangeIcons(hwnd);
5941 return 0;
5942
5943 case WM_CHORD:
5944 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
5945 break;
5946
5947 case WM_SETFOCUS:
5948 if (mp2)
5949 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
5950 break;
5951
5952 case UM_FOCUSME:
5953 WinSetFocus(hwndTree, TRUE);
5954 return 0;
5955
5956 case UM_RESCAN:
5957 TileChildren(hwnd, TRUE);
5958 return 0;
5959
5960 case WM_SAVEAPPLICATION:
5961 {
5962 SWP swp;
5963
5964 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
5965 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
5966 WinStoreWindowPos(FM2Str,
5967 "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
5968 if (!fNoSaveState && fSaveState)
5969 SaveDirCnrState(hwnd, GetPString(IDS_SHUTDOWNSTATE));
5970 }
5971 }
5972 break;
5973
5974 case MM_PORTHOLEINIT:
5975 switch (SHORT1FROMMP(mp1)) {
5976 case 0:
5977 case 1:
5978 {
5979 HWND hwndCurrent;
5980 ULONG wmsg;
5981
5982 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
5983 hwndCurrent = TopWindow(hwnd, (HWND) 0);
5984 PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
5985 FID_CLIENT), wmsg,
5986 MPVOID, MPVOID), mp1, mp2);
5987 }
5988 break;
5989 }
5990 break;
5991
5992 case WM_INITMENU:
5993 switch (SHORT1FROMMP(mp1)) {
5994 case IDM_CONFIGMENU:
5995 SetToggleChecks((HWND) WinQueryWindowULong(hwnd, QWL_USER));
5996 break;
5997
5998 case IDM_WINDOWSMENU:
5999 /*
6000 * add child windows of client
6001 * and switchlist entries to end of pulldown menu
6002 */
6003 {
6004 HWND hwndMenu, hwndSubMenu;
6005 MENUITEM mi;
6006
6007 hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
6008 memset(&mi, 0, sizeof(mi));
6009 mi.iPosition = MIT_END;
6010 mi.afStyle = MIS_TEXT;
6011 if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
6012 MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
6013 break;
6014 hwndSubMenu = mi.hwndSubMenu;
6015 SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
6016 }
6017 break;
6018
6019 default:
6020 {
6021 HWND hwndCurrent;
6022
6023 hwndCurrent = TopWindow(hwnd, (HWND) 0);
6024 if (hwndCurrent)
6025 WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
6026 }
6027 break;
6028 }
6029 break;
6030
6031 case UM_ADDTOMENU:
6032 AddToMenu((CHAR *)mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
6033 FID_MENU));
6034 return 0;
6035
6036 case UM_FILLCMDLIST:
6037 WinSendMsg(hwndCmdlist, LM_DELETEALL, MPVOID, MPVOID);
6038 if (!cmdloaded)
6039 load_commands();
6040 if (cmdhead) {
6041
6042 LINKCMDS *info;
6043
6044 info = cmdhead;
6045 while (info) {
6046 WinSendMsg(hwndCmdlist, LM_INSERTITEM,
6047 MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
6048 info = info->next;
6049 }
6050 }
6051 return 0;
6052
6053 case UM_FILLSETUPLIST:
6054 fill_setups_list();
6055 return 0;
6056
6057 case UM_FILLBUTTONLIST:
6058 WinSendMsg(hwndButtonlist, LM_DELETEALL, MPVOID, MPVOID);
6059 if (fUserComboBox) {
6060
6061 BOOL foundit = FALSE, thisone;
6062 ULONG ulSearchCount;
6063 SHORT sSelect;
6064 FILEFINDBUF3 findbuf;
6065 HDIR hDir;
6066 CHAR *p;
6067
6068 DosError(FERR_DISABLEHARDERR);
6069 hDir = HDIR_CREATE;
6070 ulSearchCount = 1;
6071 if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED,
6072 &findbuf, sizeof(FILEFINDBUF3),
6073 &ulSearchCount, FIL_STANDARD)) {
6074 do {
6075 priority_bumped();
6076 if (!foundit) {
6077 thisone = FALSE;
6078 p = strrchr(lasttoolbar, '\\');
6079 if (!p)
6080 p = lasttoolbar;
6081 else
6082 p++;
6083 if (!stricmp(findbuf.achName, p))
6084 thisone = TRUE;
6085 }
6086 p = strrchr(findbuf.achName, '.');
6087 if (p)
6088 *p = 0;
6089 sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
6090 MPFROM2SHORT(LIT_SORTASCENDING, 0),
6091 MPFROMP(findbuf.achName));
6092 if (!foundit && thisone && sSelect >= 0) {
6093 WinSendMsg(hwndButtonlist, LM_SELECTITEM,
6094 MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
6095 foundit = TRUE;
6096 }
6097 }
6098 while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
6099 &ulSearchCount));
6100 DosFindClose(hDir);
6101 priority_bumped();
6102 }
6103 WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBARTEXT));
6104 }
6105 return 0;
6106
6107 case UM_FILLUSERLIST:
6108 WinSendMsg(hwndUserlist, LM_DELETEALL, MPVOID, MPVOID);
6109 if (fUserComboBox) {
6110 ULONG ulDriveNum;
6111 ULONG ulDriveMap;
6112 ULONG ulSearchCount;
6113 FILEFINDBUF3 findbuf;
6114 HDIR hDir;
6115 APIRET rc;
6116 LINKDIRS *info;
6117 LINKDIRS *temp;
6118
6119 if (!loadedudirs)
6120 load_udirs();
6121 DosError(FERR_DISABLEHARDERR);
6122 DosQCurDisk(&ulDriveNum, &ulDriveMap);
6123 info = udirhead;
6124 while (info) {
6125 if (IsFullName(info->path) &&
6126 !(driveflags[toupper(*info->path) - 'A'] &
6127 (DRIVE_IGNORE | DRIVE_INVALID))) {
6128 DosError(FERR_DISABLEHARDERR);
6129 hDir = HDIR_CREATE;
6130 ulSearchCount = 1;
6131 if (!IsRoot(info->path))
6132 rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
6133 MUST_HAVE_DIRECTORY | FILE_READONLY |
6134 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
6135 &findbuf, sizeof(FILEFINDBUF3),
6136 &ulSearchCount, FIL_STANDARD);
6137 else {
6138 rc = 0;
6139 findbuf.attrFile = FILE_DIRECTORY;
6140 }
6141 priority_bumped();
6142 if (!rc) {
6143 if (!IsRoot(info->path))
6144 DosFindClose(hDir);
6145 if (findbuf.attrFile & FILE_DIRECTORY)
6146 WinSendMsg(hwndUserlist, LM_INSERTITEM,
6147 MPFROM2SHORT(LIT_SORTASCENDING, 0),
6148 MPFROMP(info->path));
6149 else {
6150 temp = info->next;
6151 remove_udir(info->path);
6152 info = temp;
6153 continue;
6154 }
6155 }
6156 else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
6157 temp = info->next;
6158 remove_udir(info->path);
6159 info = temp;
6160 continue;
6161 }
6162 }
6163 info = info->next;
6164 }
6165 info = ldirhead;
6166 while (info) {
6167 if (IsFullName(info->path) &&
6168 !(driveflags[toupper(*info->path) - 'A'] &
6169 (DRIVE_IGNORE | DRIVE_INVALID))) {
6170 DosError(FERR_DISABLEHARDERR);
6171 hDir = HDIR_CREATE;
6172 ulSearchCount = 1;
6173 if (!IsRoot(info->path))
6174 rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
6175 MUST_HAVE_DIRECTORY | FILE_READONLY |
6176 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
6177 &findbuf, sizeof(FILEFINDBUF3),
6178 &ulSearchCount, FIL_STANDARD);
6179 else {
6180 rc = 0;
6181 findbuf.attrFile = FILE_DIRECTORY;
6182 }
6183 priority_bumped();
6184 if (!rc) {
6185 if (!IsRoot(info->path))
6186 DosFindClose(hDir);
6187 if (findbuf.attrFile & FILE_DIRECTORY)
6188 WinSendMsg(hwndUserlist, LM_INSERTITEM,
6189 MPFROM2SHORT(LIT_SORTASCENDING, 0),
6190 MPFROMP(info->path));
6191 else {
6192 temp = info->next;
6193 remove_udir(info->path);
6194 info = temp;
6195 continue;
6196 }
6197 }
6198 else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
6199 temp = info->next;
6200 remove_udir(info->path);
6201 info = temp;
6202 continue;
6203 }
6204 }
6205 info = info->next;
6206 }
6207 WinSendMsg(hwndUserlist, LM_INSERTITEM,
6208 MPFROM2SHORT(0, 0),
6209 MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
6210 WinSetWindowText(hwndUserlist, GetPString(IDS_COMMONDIRTEXT));
6211 }
6212 return 0;
6213
6214 case UM_SIZE:
6215 if (fAutoTile)
6216 TileChildren(hwnd, FALSE);
6217 else
6218 MoveChildrenAwayFromTree(hwnd);
6219 return 0;
6220
6221 case WM_SIZE:
6222 ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1),
6223 SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
6224 break;
6225
6226 case WM_ERASEBACKGROUND:
6227 WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
6228 return 0;
6229
6230 case WM_PAINT:
6231 {
6232 HPS hps;
6233 RECTL rcl;
6234
6235 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
6236 if (hps) {
6237 WinQueryWindowRect(hwnd, &rcl);
6238 WinFillRect(hps, &rcl, CLR_PALEGRAY);
6239 WinEndPaint(hps);
6240 }
6241 }
6242 break;
6243
6244 case UM_CONTROL:
6245 switch (SHORT1FROMMP(mp1)) {
6246 case MAIN_CMDLIST:
6247 case MAIN_SETUPLIST:
6248 case MAIN_DRIVELIST:
6249 case MAIN_USERLIST:
6250 case MAIN_BUTTONLIST:
6251 switch (SHORT2FROMMP(mp1)) {
6252 case CBN_ENTER:
6253 {
6254 HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
6255 SHORT1FROMMP(mp1));
6256 CHAR path[CCHMAXPATH];
6257 ULONG ul;
6258
6259 switch (SHORT1FROMMP(mp1)) {
6260 case MAIN_USERLIST:
6261 ul = CCHMAXPATH;
6262 break;
6263 case MAIN_SETUPLIST:
6264 ul = STATE_NAME_MAX_BYTES;
6265 break;
6266 default:
6267 ul = 13; // fixme to not be hardcoded
6268 }
6269
6270 SetShiftState();
6271 WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
6272 bstrip(path);
6273 if (*path) {
6274 if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
6275 if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
6276 if (!LastDir ||
6277 !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
6278 UM_CONTAINERDIR, MPFROMP(path), MPVOID))
6279 strcpy(path, pFM2SaveDirectory);
6280 if (!PMMkDir(hwnd, path, TRUE)) {
6281 WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
6282 break;
6283 }
6284 }
6285 if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
6286
6287 HWND hwndDir;
6288
6289 if ((fUserListSwitches &&
6290 !(shiftstate & KC_SHIFT)) ||
6291 (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
6292 hwndDir = FindDirCnr(hwnd);
6293 if (hwndDir) {
6294 WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
6295 break;
6296 }
6297 }
6298 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
6299 }
6300 }
6301 else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
6302 ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
6303 FID_CLIENT),
6304 TREE_CNR), path, FALSE, TRUE);
6305 WinSetFocus(HWND_DESKTOP, hwndTree);
6306 }
6307 else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
6308 strcat(path, ".TLS");
6309 load_tools(path);
6310 PrfWriteProfileString(fmprof,
6311 FM3Str, "LastToolbar", lasttoolbar);
6312 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
6313 WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBARTEXT));
6314 }
6315 else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
6316 CHAR szKey[80];
6317 ULONG size, numsaves = 0;
6318
6319 SetShiftState();
6320 size = sizeof(ULONG);
6321 sprintf(szKey, "%s.NumDirsLastTime", path); // path is state name
6322 if (!PrfQueryProfileData(fmprof,
6323 FM3Str,
6324 szKey,
6325 (PVOID)&numsaves,
6326 &size))
6327 {
6328 if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
6329 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
6330 GetPString(IDS_WARNINGTEXT),
6331 GetPString(IDS_DOESNTEXISTTEXT), path);
6332 }
6333 else {
6334 Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
6335 IDS_PRFQUERYPROFILEDATA);
6336 }
6337 }
6338 else {
6339 char *pszStateName;
6340 if ((shiftstate & KC_SHIFT) == 0)
6341 PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
6342 pszStateName = xstrdup(path, pszSrcFile, __LINE__);
6343 if (!pszStateName) {
6344 // Fall back if out of memory - already complained
6345 if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
6346 // Autotile requested or forced
6347 PostMsg(MainObjectHwnd,
6348 UM_RESTORE,
6349 MPVOID,
6350 MPFROMLONG(1)); // Autotile
6351 }
6352 }
6353 else if (!PostMsg(MainObjectHwnd,
6354 UM_RESTORE,
6355 MPFROMP(pszStateName),
6356 MPVOID)) {
6357 free(pszStateName);
6358 }
6359 }
6360 }
6361 else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
6362
6363 SHORT sSelect;
6364
6365 sSelect = (SHORT) WinSendMsg(hwndCmdlist,
6366 LM_QUERYSELECTION,
6367 MPFROMSHORT(LIT_FIRST), MPVOID);
6368 if (sSelect >= 0)
6369 WinPostMsg(hwnd,
6370 WM_COMMAND,
6371 MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
6372 MPVOID);
6373 WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
6374 }
6375 }
6376 }
6377 break;
6378
6379 default:
6380 break;
6381 }
6382 break;
6383
6384 default:
6385 break;
6386 }
6387 return 0;
6388
6389 case WM_HELP:
6390 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
6391 break;
6392
6393 case UM_COMMAND:
6394 case WM_COMMAND:
6395
6396 return MainWMCommand(hwnd, msg, mp1, mp2);
6397
6398 case WM_CLOSE:
6399 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
6400 WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
6401 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
6402 fAmClosing = TRUE;
6403 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
6404 WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
6405 if (CloseChildren(hwnd)) {
6406 fAmClosing = FALSE;
6407 if (fAutoTile)
6408 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
6409 return 0;
6410 }
6411 if (hwndTree) {
6412 if (!PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID))
6413 WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
6414 }
6415 DosSleep(1);
6416 return 0; // Hold off WM_QUIT
6417
6418 case UM_CLOSE:
6419 HideNote();
6420 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
6421 return 0;
6422
6423 case UM_RESTORE:
6424 {
6425 // Try to restore saved shutdown state
6426 char *pszDefaultStateName = xstrdup(GetPString(IDS_SHUTDOWNSTATE),
6427 pszSrcFile, __LINE__);
6428 if (pszDefaultStateName) {
6429 if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
6430 // 05 Feb 08 SHL fixme to complain?
6431 free(pszDefaultStateName);
6432 }
6433 }
6434 return 0;
6435
6436 case UM_SETDIR:
6437 /* mp1 == name of directory to open */
6438 if (mp1)
6439 return MRFROMLONG(OpenDirCnr((HWND) 0,
6440 hwndMain,
6441 hwndTree, (BOOL) mp2, (char *)mp1));
6442 return 0;
6443
6444 case WM_DESTROY:
6445 hwndMain = (HWND) 0;
6446 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
6447 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
6448# ifdef FORTIFY
6449 free_commands();
6450 free_associations();
6451 free_udirs();
6452 free_ldir();
6453 free_archivers();
6454 free_tools();
6455 free_setups();
6456 Fortify_LeaveScope();
6457# endif
6458 break;
6459 }
6460 return WinDefWindowProc(hwnd, msg, mp1, mp2);
6461}
6462
6463VOID DeletePresParams(CHAR * pchKeyroot)
6464// This code assumes that pchKeyroot points to a buffer large enough to
6465// hold the full INI key: The state name.dircnr-number.PPName. The
6466// PPNames are listed below.
6467{
6468 PSZ apszPPNames[] =
6469 {
6470 "Backgroundcolor",
6471 "Foregroundcolor",
6472 "Hilitebackgroundcolor",
6473 "Hiliteforegroundcolor",
6474 "Bordercolor",
6475 "Fontnamesize"
6476 };
6477
6478 ULONG ulSize, ulArraySize = sizeof(apszPPNames) / sizeof(PSZ), x;
6479 CHAR * eos = pchKeyroot + strlen(pchKeyroot);
6480
6481 for (x = 0; x < ulArraySize; x++)
6482 {
6483 strcpy(eos, apszPPNames[x]);
6484 if (PrfQueryProfileSize(fmprof, appname, pchKeyroot, &ulSize) && ulSize)
6485 {
6486 PrfWriteProfileData(fmprof, appname, pchKeyroot, NULL, ulSize);
6487 }
6488 }
6489}
6490
6491#pragma alloc_text(MISC8,SetToggleChecks,FindDirCnrByName,TopWindow)
6492#pragma alloc_text(MISC8,TopWindowName,CountDirCnrs)
6493#pragma alloc_text(MAINWND,AdjustSizeOfClient,FillClient,ChildButtonProc)
6494#pragma alloc_text(MAINWND,ToolBackProc,StatusProc)
6495#pragma alloc_text(MAINWND,MoveChildrenAwayFromTree,ArrangeIcons,NextChild)
6496#pragma alloc_text(MAINWND,ChildFrameButtonProc)
6497#pragma alloc_text(MAINWND2,CloseChildren,CountChildren,GetNextWindowPos)
6498#pragma alloc_text(MAINWND2,CascadeChildren,TileChildren,ResizeChildren)
6499#pragma alloc_text(MAINWND2,MinResChildren,MainFrameWndProc,MainWndProc)
6500#pragma alloc_text(MAINWND2,DropDownListProc)
6501#pragma alloc_text(MAINWND3,RestoreDirCnrState,SaveDirCnrState)
6502#pragma alloc_text(MAINWND3,CloseDirCnrChildren,TransformSwp)
6503#pragma alloc_text(MAINWND3,ResizeTools,BuildTools,CommandLineProc)
6504#pragma alloc_text(MAINWND4,DriveProc,DriveBackProc,BuildDriveBarButtons,ResizeDrives)
6505#pragma alloc_text(MAINWND4,LEDProc,IdealButtonProc)
6506#pragma alloc_text(MAINWND5,MainWMOnce)
6507#pragma alloc_text(MAINWND6,MainWMCommand)
6508#pragma alloc_text(BUBBLE,MakeBubble,BubbleProc,BubbleHelp)
6509#pragma alloc_text(MAINOBJ,MainObjectWndProc,MakeMainObjWin)
6510
Note: See TracBrowser for help on using the repository browser.