source: trunk/dll/mainwnd.c@ 1546

Last change on this file since 1546 was 1546, checked in by Gregg Young, 15 years ago

Add menu item to allow opening of directory container from the collector based on the path of the selected item. (Ticket 362) Add open file button to EAs dialog to allow opening of a new file's eas (Ticket 439). Initial work on populating the help table (It provides F1 help a few more places) (Ticket 95). Some minor code cleanup and help file updates.

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