source: trunk/dll/mainwnd.c@ 1675

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

Enhance traget directory drop to give the option of changing the directory or carrying out an operation to the current target; Added an error message for target=None; Added parameter to SetTargetDir. Ticket 373

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