source: trunk/dll/mainwnd.c@ 1065

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

Ticket 230: Simplified code and eliminated some local variables by incorporating
all the details view settings (both the global variables and those in the
DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.

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