source: trunk/dll/mainwnd.c@ 1673

Last change on this file since 1673 was 1673, checked in by Gregg Young, 13 years ago

Update to Doxygen comment style Ticket 55. Also some minor code cleanup.

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