source: trunk/dll/mainwnd.c@ 1671

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

Add ability to change and save PresParam to compare dialog (Ticket 443) Fix loading of a list file in the right compare container (Ticket 489) Allow for selection of include subdirectories or a list file on initial startup of compare dirs (Ticket 145)

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