source: trunk/dll/mainwnd.c@ 1128

Last change on this file since 1128 was 1128, checked in by John Small, 17 years ago

Ticket 259: 1) Support save/restore of target dir with states (except FM2Shutdown)

2) Added separate toolbar setting for FM/2 Lite
3) Improved earlier changes for this ticket

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