source: trunk/dll/mainwnd.c@ 1158

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

Ticket 187: Draft 1: Functions only

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