source: trunk/dll/mainwnd.c@ 1181

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

Ticket 187: Draft 2: Move remaining function declarations

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