source: trunk/dll/mainwnd.c@ 1570

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

This code adds the semaphores to prevent a rescan from starting before the current one is finished; it fixes the double directory listing in the tree container and streamlines scanning. It update mapsym.pl to the latest version. Some code cleanup is included

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