source: trunk/dll/mainwnd.c@ 1667

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

Make the Target Directory (DriveBar) a drop target (ticket 373)

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