source: trunk/dll/mainwnd.c@ 1550

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

This actually fixes the double names in the tree container. It also streamlines the initial scan code by eliminating multiple redundant scans.

  • 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 1550 2010-11-03 02:50:42Z 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 if (fInitialDriveScan)
1865 DosWaitEventSem(hevInitialCnrScanComplete, SEM_INDEFINITE_WAIT);
1866 switch(SHORT1FROMMP(mp1)) {
1867 case IDM_RESCAN:
1868 {
1869 BOOL toggleTree = FALSE;
1870
1871 if (!hwndTree) {
1872 WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID);
1873 toggleTree = TRUE;
1874 }
1875 WinSendMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
1876 if (toggleTree)
1877 WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID);
1878 }
1879 break;
1880 case IDM_REFRESHREMOVABLES:
1881 {
1882 BOOL toggleTree = FALSE;
1883
1884 if (!hwndTree) {
1885 WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID);
1886 toggleTree = TRUE;
1887 }
1888 WinSendMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_REFRESHREMOVABLES, 0), MPVOID);
1889 if (toggleTree)
1890 WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID);
1891 }
1892 break;
1893 default:
1894 {
1895 CHAR dv[4];
1896
1897 *dv = SHORT1FROMMP(mp1) - IDM_DRIVEA + 'A';
1898 strcpy(dv + 1, ":\\");
1899 if (isalpha(*dv)) {
1900
1901 HWND hwndActive;
1902
1903 dv[1] = ':';
1904 dv[2] = '\\';
1905 dv[3] = 0;
1906 hwndActive = TopWindow(hwnd, (HWND) 0);
1907 if (hwndActive)
1908 WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
1909 UM_DRIVECMD, MPFROMP(dv), MPVOID);
1910 }
1911 }
1912 }
1913 return 0;
1914
1915 case WM_PAINT:
1916 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
1917 break;
1918
1919 case WM_CLOSE:
1920 WinDestroyWindow(hwnd);
1921 return 0;
1922 }
1923 return PFNWPStatic(hwnd, msg, mp1, mp2);
1924}
1925
1926MRESULT EXPENTRY DriveProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1927{
1928 USHORT id;
1929 CHAR szDrv[CCHMAXPATH];
1930
1931 static BOOL emphasized = FALSE;
1932 static HWND hwndMenu = NULLHANDLE;
1933 static USHORT helpid = 0;
1934
1935 switch (msg) {
1936 case WM_MOUSEMOVE:
1937 if (fDrivebarHelp && (!hwndBubble ||
1938 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
1939 !WinQueryCapture(HWND_DESKTOP)) {
1940 id = WinQueryWindowUShort(hwnd, QWS_ID);
1941 if (helpid != id) {
1942 helpid = id;
1943 PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
1944 }
1945 else
1946 helpid = 0;
1947 }
1948 break;
1949
1950 case WM_PAINT:
1951 {
1952 HPS hps;
1953 POINTL aptl[4] = {0, 0, DRIVE_BUTTON_WIDTH - 1, DRIVE_BUTTON_HEIGHT - 1,
1954 0, 0, DRIVE_BUTTON_WIDTH - 1, DRIVE_BUTTON_HEIGHT - 1};
1955 //The last 2 numbers should be the width and height of the bitmap
1956 HBITMAP hbm;
1957 PBITMAPINFOHEADER pbmpData;
1958 POINTL ptlStart;
1959 ULONG x, iconid;
1960 FATTRS fat;
1961 SIZEF sizfCharBox;
1962
1963 id = WinQueryWindowUShort(hwnd, QWS_ID);
1964 if (id == IDM_REFRESHREMOVABLES || id == IDM_RESCAN)
1965 break;
1966 *szDrv = 0;
1967 x = id - IDM_DRIVEA;
1968 *szDrv = (CHAR) x + 'A';
1969 strcpy(szDrv + 1, ":");
1970 if (x > 1) {
1971 if (driveflags[x] & DRIVE_CDROM)
1972 iconid = CDROM_ICON;
1973 else
1974 iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
1975 REMOVABLE_ICON :
1976 (driveflags[x] & DRIVE_VIRTUAL) ?
1977 VIRTUAL_ICON :
1978 (driveflags[x] & DRIVE_REMOTE) ?
1979 REMOTE_ICON :
1980 (driveflags[x] & DRIVE_RAMDISK) ?
1981 RAMDISK_ICON :
1982 (driveflags[x] & DRIVE_ZIPSTREAM) ?
1983 ZIPSTREAM_ICON :
1984 (driveflags[x] & DRIVE_LOCALHD) ?
1985 DRIVE_ICON : DONNO_ICON;
1986 }
1987 else
1988 iconid = FLOPPY_ICON;
1989 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
1990 if (hps) {
1991 hbm = GpiLoadBitmap(hps, 0, iconid, 0, 0);
1992 if (hbm) {
1993 pbmpData = xmallocz(sizeof(PBITMAPINFOHEADER) * 3, pszSrcFile, __LINE__);
1994 if (pbmpData) {
1995 GpiQueryBitmapParameters(hbm, pbmpData);
1996 aptl[1].x = pbmpData->cx;
1997 aptl[1].y = pbmpData->cy;
1998 aptl[3].x = pbmpData->cx;
1999 aptl[3].y = pbmpData->cy;
2000 GpiWCBitBlt(hps, hbm, 4L, aptl, ROP_SRCCOPY, BBO_PAL_COLORS);
2001 free(pbmpData);
2002 }
2003 }
2004 memset(&fat, 0, sizeof(fat));
2005 fat.usRecordLength = sizeof(FATTRS);
2006 fat.fsSelection = FATTR_SEL_BOLD ;
2007 fat.usCodePage = 850;
2008 fat.fsFontUse = FATTR_FONTUSE_NOMIX;
2009 strcpy(fat.szFacename , FNT_HELVETICA);
2010 x = GpiCreateLogFont(hps, NULL, DRIVEBAR_FONT_LCID, &fat);
2011 if (x != GPI_ERROR) {
2012 GpiSetCharSet(hps, DRIVEBAR_FONT_LCID);
2013 sizfCharBox.cx = MAKEFIXED(10,0); //Font size
2014 sizfCharBox.cy = MAKEFIXED(14,0);
2015 GpiSetCharBox( hps, &sizfCharBox );
2016 GpiSetColor(hps, iconid == RAMDISK_ICON ? CLR_YELLOW : CLR_DARKBLUE);
2017 ptlStart.x = 1L; //Char box position
2018 ptlStart.y = 8L;
2019 GpiCharStringAt(hps, &ptlStart, strlen(szDrv), szDrv);
2020 GpiDeleteSetId(hps, DRIVEBAR_FONT_LCID);
2021 }
2022 WinEndPaint(hps);
2023 }
2024 }
2025 break;
2026
2027 case UM_SETUP6:
2028 if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) {
2029 if ((char *)mp1 &&
2030 (!hwndBubble ||
2031 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
2032 !WinQueryCapture(HWND_DESKTOP)) {
2033
2034 RECTL rcl;
2035 POINTL ptl;
2036
2037 WinQueryPointerPos(HWND_DESKTOP, &ptl);
2038 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
2039 WinQueryWindowRect(hwnd, &rcl);
2040 if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl)) {
2041 BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
2042 }
2043 }
2044 }
2045 return 0;
2046
2047 case WM_MENUEND:
2048 if (hwndMenu == (HWND) mp2) {
2049 WinDestroyWindow(hwndMenu);
2050 hwndMenu = (HWND) 0;
2051 }
2052 break;
2053
2054 case WM_CONTEXTMENU:
2055 if (hwndMenu)
2056 WinDestroyWindow(hwndMenu);
2057 hwndMenu = (HWND) 0;
2058 id = WinQueryWindowUShort(hwnd, QWS_ID);
2059 *szDrv = id - IDM_DRIVEA + 'A';
2060 strcpy(szDrv + 1, ":");
2061 if (isalpha(*szDrv)) {
2062 hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES);
2063 if (hwndMenu) {
2064 BOOL rdy, local;
2065 CHAR chDrv = *szDrv;
2066 UINT iDrv = chDrv - 'A';
2067
2068 strcat(szDrv, PCSZ_BACKSLASH);
2069 MakeValidDir(szDrv);
2070 // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
2071 local = ~driveflags[iDrv] & DRIVE_REMOTE && ~driveflags[iDrv] & DRIVE_VIRTUAL &&
2072 ~driveflags[iDrv] & DRIVE_RAMDISK;
2073 rdy = toupper(*szDrv) == toupper(chDrv);
2074 iDrv = toupper(*szDrv) - 'A';
2075 if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
2076 WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
2077
2078 if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE)
2079 WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
2080
2081 if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE || !local) {
2082 WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
2083 WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
2084 WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
2085 }
2086 if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
2087 WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
2088 WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
2089 WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
2090 }
2091 if (!rdy) {
2092 WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
2093 WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
2094 WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
2095 WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
2096
2097 if (!rdy || !local)
2098 WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
2099 }
2100 /* fixme to be gone?
2101 if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
2102 WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
2103 }
2104 */
2105 PopupMenu(hwnd, hwnd, hwndMenu);
2106 }
2107 }
2108 return MRFROMSHORT(TRUE);
2109
2110 case WM_BUTTON2CLICK:
2111 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
2112 if (!(shiftstate & KC_CTRL))
2113 break;
2114
2115 case WM_CHORD:
2116 case WM_BUTTON3CLICK:
2117 id = WinQueryWindowUShort(hwnd, QWS_ID);
2118 *szDrv = id - IDM_DRIVEA + 'A';
2119 strcpy(szDrv + 1, ":");
2120 if (isalpha(*szDrv)) {
2121 strcat(szDrv, PCSZ_BACKSLASH);
2122 if (!FindDirCnrByName(szDrv, TRUE))
2123 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
2124 }
2125 break;
2126
2127 case WM_COMMAND:
2128 PostMsg(hwnd, UM_COMMAND, mp1, mp2);
2129 return 0;
2130
2131 case UM_COMMAND:
2132 id = WinQueryWindowUShort(hwnd, QWS_ID);
2133 *szDrv = id - IDM_DRIVEA + 'A';
2134 strcpy(szDrv + 1, ":");
2135 if (isalpha(*szDrv)) {
2136 strcat(szDrv, PCSZ_BACKSLASH);
2137 CommonDriveCmd(hwnd, szDrv, SHORT1FROMMP(mp1));
2138 }
2139 return 0;
2140
2141 case DM_DRAGOVER:
2142 id = WinQueryWindowUShort(hwnd, QWS_ID);
2143 *szDrv = id - IDM_DRIVEA + 'A';
2144 strcpy(szDrv + 1, ":");
2145 if (isalpha(*szDrv) &&
2146 !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
2147 if (!emphasized) {
2148 emphasized = TRUE;
2149 DrawTargetEmphasis(hwnd, emphasized);
2150 }
2151 if (AcceptOneDrop(hwnd, mp1, mp2))
2152 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
2153 return MRFROM2SHORT(DOR_NEVERDROP, 0);
2154 }
2155 break;
2156
2157 case DM_DRAGLEAVE:
2158 id = WinQueryWindowUShort(hwnd, QWS_ID);
2159 *szDrv = id - IDM_DRIVEA + 'A';
2160 strcpy(szDrv + 1, ":");
2161 if (isalpha(*szDrv) &&
2162 !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
2163 if (emphasized) {
2164 emphasized = FALSE;
2165 DrawTargetEmphasis(hwnd, emphasized);
2166 }
2167 }
2168 break;
2169
2170 case DM_DROPHELP:
2171 id = WinQueryWindowUShort(hwnd, QWS_ID);
2172 *szDrv = id - IDM_DRIVEA + 'A';
2173 strcpy(szDrv + 1, ":");
2174 if (isalpha(*szDrv) &&
2175 !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
2176 DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP));
2177 return 0;
2178 }
2179 break;
2180
2181 case DM_DROP:
2182 id = WinQueryWindowUShort(hwnd, QWS_ID);
2183 *szDrv = id - IDM_DRIVEA + 'A';
2184 strcpy(szDrv + 1, ":");
2185 if (isalpha(*szDrv) &&
2186 !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
2187
2188 CNRDRAGINFO cnd;
2189 LISTINFO *li;
2190 ULONG action = UM_ACTION;
2191
2192 if (emphasized) {
2193 emphasized = FALSE;
2194 DrawTargetEmphasis(hwnd, emphasized);
2195 }
2196 memset(&cnd, 0, sizeof(cnd));
2197 cnd.pDragInfo = (PDRAGINFO) mp1;
2198 cnd.pRecord = NULL;
2199 li = DoFileDrop(hwnd,
2200 NULL,
2201 TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
2202 CheckPmDrgLimit(cnd.pDragInfo);
2203 if (li) {
2204 strcpy(li->targetpath, szDrv);
2205 strcat(li->targetpath, PCSZ_BACKSLASH);
2206 if (li->list && li->list[0] && IsRoot(li->list[0]))
2207 li->type = DO_LINK;
2208 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2209
2210 CHECKLIST cl;
2211
2212 memset(&cl, 0, sizeof(cl));
2213 cl.size = sizeof(cl);
2214 cl.flags = li->type;
2215 cl.list = li->list;
2216 cl.cmd = li->type;
2217 cl.prompt = li->targetpath;
2218 li->type = WinDlgBox(HWND_DESKTOP,
2219 hwndMain,
2220 DropListProc,
2221 FM3ModHandle, DND_FRAME, MPFROMP(&cl));
2222 if (li->type == DID_ERROR)
2223 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2224 GetPString(IDS_DRAGDROPDIALOGTEXT));
2225 if (!li->type) {
2226 FreeListInfo(li);
2227 return 0;
2228 }
2229 li->list = cl.list;
2230 if (!li->list || !li->list[0]) {
2231 FreeListInfo(li);
2232 return 0;
2233 }
2234 }
2235 else {
2236 if (!WinDlgBox(HWND_DESKTOP,
2237 hwndMain,
2238 WalkDlgProc,
2239 FM3ModHandle,
2240 WALK_FRAME,
2241 MPFROMP(li->targetpath)) || !*li->targetpath) {
2242 FreeListInfo(li);
2243 return 0;
2244 }
2245 }
2246 switch (li->type) {
2247 case DND_LAUNCH:
2248 strcat(li->targetpath, " %a");
2249 ExecOnList(hwndMain,
2250 li->targetpath, PROMPT | WINDOWED, NULL, NULL, li->list, NULL,
2251 pszSrcFile, __LINE__);
2252 FreeList(li->list);
2253 li->list = NULL;
2254 break;
2255 case DO_LINK:
2256 if (fLinkSetsIcon) {
2257 li->type = IDM_SETICON;
2258 action = UM_MASSACTION;
2259 }
2260 else
2261 li->type = IDM_COMPARE;
2262 break;
2263 case DND_EXTRACT:
2264 if (*li->targetpath && !IsFile(li->targetpath))
2265 li->type = IDM_EXTRACT;
2266 break;
2267 case DND_MOVE:
2268 li->type = IDM_MOVE;
2269 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2270 action = UM_MASSACTION;
2271 li->type = IDM_ARCHIVEM;
2272 }
2273 break;
2274 case DND_WILDMOVE:
2275 li->type = IDM_WILDMOVE;
2276 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2277 action = UM_MASSACTION;
2278 li->type = IDM_ARCHIVEM;
2279 }
2280 break;
2281 case DND_OBJECT:
2282 li->type = IDM_OBJECT;
2283 action = UM_MASSACTION;
2284 break;
2285 case DND_SHADOW:
2286 li->type = IDM_SHADOW;
2287 action = UM_MASSACTION;
2288 break;
2289 case DND_COMPARE:
2290 li->type = IDM_COMPARE;
2291 break;
2292 case DND_SETICON:
2293 action = UM_MASSACTION;
2294 li->type = IDM_SETICON;
2295 break;
2296 case DND_COPY:
2297 li->type = IDM_COPY;
2298 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2299 action = UM_MASSACTION;
2300 li->type = IDM_ARCHIVE;
2301 }
2302 break;
2303 case DND_WILDCOPY:
2304 li->type = IDM_WILDCOPY;
2305 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2306 action = UM_MASSACTION;
2307 li->type = IDM_ARCHIVE;
2308 }
2309 break;
2310 default:
2311 if (*li->arcname && li->info) {
2312 action = UM_MASSACTION;
2313 li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
2314 IDM_FAKEEXTRACT;
2315 }
2316 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2317 action = UM_MASSACTION;
2318 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2319 }
2320 else
2321 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2322 break;
2323 }
2324 if (!li->list || !li->list[0])
2325 FreeListInfo(li);
2326 else
2327 WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
2328 }
2329 return 0;
2330 }
2331 break;
2332
2333 case WM_DESTROY:
2334 if (hwndMenu)
2335 WinDestroyWindow(hwndMenu);
2336 hwndMenu = (HWND) 0;
2337 break;
2338 }
2339 return PFNWPButton(hwnd, msg, mp1, mp2);
2340}
2341
2342VOID BuildDriveBarButtons(HWND hwndT)
2343{
2344 register ULONG x;
2345 ULONG ulDriveNum, ulDriveMap;
2346 HENUM henum;
2347 HWND hwndB;
2348
2349 henum = WinBeginEnumWindows(hwndT);
2350
2351 while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE)
2352 WinDestroyWindow(hwndB);
2353
2354 WinEndEnumWindows(henum);
2355 if (fDrivebar) {
2356 DosError(FERR_DISABLEHARDERR);
2357 DosQCurDisk(&ulDriveNum, &ulDriveMap);
2358 for (x = 0; x < 26; x++) {
2359 if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
2360 hwndB = WinCreateWindow(hwndT,
2361 (CHAR *) WC_DRIVEBUTTONS,
2362 0,
2363 BS_NOPOINTERFOCUS | BS_USERBUTTON,
2364 0,
2365 0,
2366 DRIVE_BUTTON_WIDTH,
2367 DRIVE_BUTTON_HEIGHT,
2368 hwndT, HWND_TOP, x + IDM_DRIVEA, NULL, NULL);
2369 if (!hwndB)
2370 Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
2371 PCSZ_WINCREATEWINDOW);
2372 else {
2373 WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
2374 }
2375 }
2376 } // for
2377 hwndB = WinCreateWindow(hwndT,
2378 (CHAR *) WC_DRIVEBUTTONS,
2379 "#7001",
2380 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
2381 0,
2382 0,
2383 DRIVE_BUTTON_WIDTH,
2384 DRIVE_BUTTON_HEIGHT,
2385 hwndT, HWND_TOP, IDM_REFRESHREMOVABLES, NULL, NULL);
2386 if (!hwndB)
2387 Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
2388 PCSZ_WINCREATEWINDOW);
2389 hwndB = WinCreateWindow(hwndT,
2390 (CHAR *) WC_DRIVEBUTTONS,
2391 "#7000",
2392 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
2393 0,
2394 0,
2395 DRIVE_BUTTON_WIDTH,
2396 DRIVE_BUTTON_HEIGHT,
2397 hwndT, HWND_TOP, IDM_RESCAN, NULL, NULL);
2398 if (!hwndB)
2399 Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
2400 PCSZ_WINCREATEWINDOW);
2401 } // if drivebar
2402 PostMsg(WinQueryWindow(hwndT, QW_PARENT),
2403 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
2404}
2405
2406VOID ResizeDrives(HWND hwndT, long xwidth)
2407{
2408 register ULONG ctrlxpos = 1, ctrlypos = 0, ctrlxsize;
2409 HENUM henum;
2410 HWND hwndB;
2411 RECTL rcl;
2412
2413 DriveLines = 0;
2414 if (!fDrivebar)
2415 return;
2416 if (!xwidth) {
2417 WinQueryWindowRect(hwndT, &rcl);
2418 xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP,
2419 SV_CYSIZEBORDER) * 2) + 1);
2420 }
2421 henum = WinBeginEnumWindows(hwndT);
2422 while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) {
2423 ctrlxsize = DRIVE_BUTTON_WIDTH;
2424 WinSetWindowPos(hwndB,
2425 HWND_TOP,
2426 ctrlxpos, ctrlypos, ctrlxsize, DRIVE_BUTTON_HEIGHT, SWP_MOVE | SWP_SHOW);
2427 ctrlxpos += (ctrlxsize + 2);
2428 if (ctrlxpos + (DRIVE_BUTTON_WIDTH + 2 + ((fShowTarget && DriveLines == 0) ?
2429 256 : 0)) > xwidth) {
2430 ctrlxpos = 1;
2431 ctrlypos += DRIVE_BUTTON_HEIGHT;
2432 DriveLines++;
2433 }
2434 }
2435 if (ctrlxpos == 2 && DriveLines)
2436 DriveLines--;
2437}
2438
2439MRESULT EXPENTRY StatusProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2440{
2441 static HWND hwndE = (HWND) 0, hwndB = (HWND) 0;
2442 static CHAR lastcmd[1024] = "";
2443
2444 switch (msg) {
2445 case WM_CREATE:
2446 {
2447 MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2);
2448 //fixme to allow user to change presparams 1-10-09 GKY
2449 SetPresParams(hwnd,
2450 &RGBGREY,
2451 &RGBBLACK, &RGBGREY, FNT_8HELVETICABOLD);
2452 return mr;
2453 }
2454
2455 case WM_PRESPARAMCHANGED:
2456 if (fRunning) {
2457
2458 ULONG AttrFound, AttrValue[64], cbRetLen;
2459
2460 cbRetLen = WinQueryPresParam(hwnd,
2461 (ULONG) mp1,
2462 0,
2463 &AttrFound,
2464 (ULONG) sizeof(AttrValue), &AttrValue, 0);
2465 if (cbRetLen) {
2466 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
2467 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
2468 }
2469 }
2470 break;
2471
2472 case WM_CONTEXTMENU:
2473 PostMsg(hwndMain, UM_CONTEXTMENU, MPVOID, MPVOID);
2474 return MRFROMSHORT(TRUE);
2475
2476 case WM_BEGINDRAG:
2477 if (hwndTree) {
2478
2479 SWP swp;
2480 ULONG fl = SWP_ACTIVATE | SWP_SHOW | SWP_ZORDER;
2481
2482 WinQueryWindowPos(hwndTree, &swp);
2483 if (!(swp.fl & SWP_MAXIMIZE))
2484 fl |= SWP_RESTORE;
2485 WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl);
2486 }
2487 break;
2488
2489 case UM_SETUP:
2490 if (mp1)
2491 strcpy(lastcmd, (CHAR *)mp1);
2492 return 0;
2493
2494 case UM_RESCAN:
2495 if (hwndE && WinIsWindow(WinQueryAnchorBlock(hwnd), hwndE))
2496 WinDestroyWindow(hwndE);
2497 if (hwndB && WinIsWindow(WinQueryAnchorBlock(hwnd), hwndB))
2498 WinDestroyWindow(hwndB);
2499 hwndE = hwndB = (HWND) 0;
2500 return 0;
2501
2502 case WM_COMMAND:
2503 switch (SHORT1FROMMP(mp1)) {
2504 case COMMAND_BUTTON:
2505 PostMsg(hwndE, msg, mp1, mp2);
2506 break;
2507 }
2508 return 0;
2509
2510 case WM_MOUSEMOVE:
2511 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
2512 {
2513 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
2514 PCSZ s = NULL;
2515
2516 if (fOtherHelp) {
2517 if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
2518 && !WinQueryCapture(HWND_DESKTOP)) {
2519 switch (id) {
2520 case IDM_ATTRS:
2521 if (WinQueryWindowTextLength(hwnd))
2522 s = GetPString(IDS_ATTRSBUTTONHELP);
2523 break;
2524 case IDM_INFO:
2525 if (WinQueryWindowTextLength(hwnd))
2526 s = GetPString(IDS_INFOBUTTONHELP);
2527 break;
2528 case IDM_RENAME:
2529 if (WinQueryWindowTextLength(hwnd))
2530 s = GetPString(IDS_NAMEBUTTONHELP);
2531 break;
2532 case MAIN_STATUS2:
2533 if (!hwndE)
2534 s = GetPString(IDS_STATUS2HELP);
2535 break;
2536 default:
2537 break;
2538 }
2539 if (s)
2540 MakeBubble(hwnd, FALSE, s);
2541 else if (hwndBubble)
2542 WinDestroyWindow(hwndBubble);
2543 }
2544 }
2545 switch (id) {
2546 case IDM_ATTRS:
2547 case IDM_INFO:
2548 case IDM_RENAME:
2549 case MAIN_STATUS2:
2550 return CommonTextProc(hwnd, msg, mp1, mp2);
2551 default:
2552 break;
2553 }
2554 }
2555 break;
2556
2557 case WM_BUTTON2DOWN:
2558 case WM_BUTTON2UP:
2559 case UM_FOCUSME:
2560 return CommonTextButton(hwnd, msg, mp1, mp2);
2561
2562 case WM_BUTTON1DOWN:
2563 case WM_BUTTON1UP:
2564 case WM_BUTTON3DOWN:
2565 case WM_BUTTON3UP:
2566 {
2567 USHORT id;
2568
2569 id = WinQueryWindowUShort(hwnd, QWS_ID);
2570 switch (id) {
2571 case IDM_ATTRS:
2572 case IDM_INFO:
2573 case IDM_RENAME:
2574 case MAIN_STATUS2:
2575 return CommonTextButton(hwnd, msg, mp1, mp2);
2576 default:
2577 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
2578 break;
2579 }
2580 }
2581 break;
2582
2583 case WM_SETFOCUS:
2584 if (mp2) {
2585
2586 USHORT id;
2587
2588 id = WinQueryWindowUShort(hwnd, QWS_ID);
2589 if (id == MAIN_STATUS2 && hwndE)
2590 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2591 else
2592 return CommonTextButton(hwnd, msg, mp1, mp2);
2593 }
2594 break;
2595
2596 case WM_BUTTON1CLICK:
2597 {
2598 USHORT id;
2599
2600 id = WinQueryWindowUShort(hwnd, QWS_ID);
2601 if (id == MAIN_STATUS) {
2602 if (SHORT2FROMMP(mp2) & KC_CTRL)
2603 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2604 FID_CLIENT),
2605 WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
2606 else if (hwndTree)
2607 PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
2608 }
2609 }
2610 break;
2611
2612 case UM_CLICKED:
2613 case UM_CLICKED3:
2614 {
2615 USHORT id;
2616
2617 id = WinQueryWindowUShort(hwnd, QWS_ID);
2618 if (id == MAIN_STATUS2 && !hwndE) {
2619
2620 SWP swp;
2621 CHAR directory[CCHMAXPATH];
2622 PFNWP oldproce;
2623
2624 *directory = 0;
2625 TopWindowName(hwndMain, (HWND) 0, directory);
2626 WinQueryWindowPos(hwnd, &swp);
2627 hwndB = WinCreateWindow(hwnd,
2628 (CHAR *) WC_BUTTON,
2629 "+",
2630 WS_VISIBLE | BS_PUSHBUTTON |
2631 BS_NOPOINTERFOCUS,
2632 swp.cx - swp.cy,
2633 0,
2634 swp.cy,
2635 swp.cy,
2636 hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
2637 if (!hwndB)
2638 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2639 PCSZ_WINCREATEWINDOW);
2640 hwndE = WinCreateWindow(hwnd,
2641 (CHAR *) WC_ENTRYFIELD,
2642 NULL,
2643 WS_VISIBLE | ES_AUTOSCROLL,
2644 0,
2645 0,
2646 swp.cx - swp.cy,
2647 swp.cy,
2648 hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
2649 if (!hwndE)
2650 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2651 PCSZ_WINCREATEWINDOW);
2652 if (!hwndE || !hwndB) {
2653 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2654 return 0;
2655 }
2656 WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
2657 WinSetWindowText(hwndStatus, directory);
2658 if (*lastcmd)
2659 WinSetWindowText(hwndE, lastcmd);
2660 else
2661 WinSetWindowText(hwndE, (CHAR *) GetPString(IDS_HELPCMDTEXT));
2662 oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
2663 if (oldproce)
2664 WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
2665 PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
2666 PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
2667 return 0;
2668 }
2669 if (msg == UM_CLICKED3 || (SHORT2FROMMP(mp2) & KC_CTRL)) {
2670 switch (id) {
2671 case IDM_ATTRS:
2672 id = IDM_SORTSIZE;
2673 break;
2674 case IDM_INFO:
2675 id = IDM_SORTLWDATE;
2676 break;
2677 case IDM_RENAME:
2678 id = IDM_SORTFILENAME;
2679 break;
2680 }
2681 }
2682 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
2683 WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
2684 }
2685 return 0;
2686
2687 case WM_PAINT:
2688 {
2689 USHORT id;
2690
2691 id = WinQueryWindowUShort(hwnd, QWS_ID);
2692 switch (id) {
2693 case IDM_ATTRS:
2694 case IDM_INFO:
2695 case IDM_RENAME:
2696 case MAIN_STATUS2:
2697 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
2698 break;
2699 default:
2700 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
2701 break;
2702 }
2703 if (id == IDM_RENAME) {
2704
2705 HPS hps;
2706
2707 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
2708 if (hps) {
2709 PaintSTextWindow(hwnd, hps);
2710 WinEndPaint(hps);
2711 }
2712 return 0;
2713 }
2714 }
2715 break;
2716
2717 }
2718 return PFNWPStatic(hwnd, msg, mp1, mp2);
2719}
2720
2721MRESULT EXPENTRY ToolBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2722{
2723 switch (msg) {
2724 case WM_CREATE:
2725 hwndToolback = hwnd;
2726 break;
2727
2728 case WM_MOUSEMOVE:
2729 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
2730 break;
2731
2732 case WM_CONTROLPOINTER:
2733 if (!fNoFinger && SHORT1FROMMP(mp1) < 25000)
2734 return MRFROMLONG(hptrFinger);
2735 break;
2736
2737 case WM_CHAR:
2738 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
2739 break;
2740
2741 case WM_COMMAND:
2742 case UM_COMMAND:
2743 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2744 FID_CLIENT), msg, mp1, mp2);
2745
2746 case WM_PAINT:
2747 {
2748 HPS hps;
2749 RECTL rcl;
2750 ULONG lColor = 0L;
2751
2752 hps = WinBeginPaint(hwnd, (HPS)0, NULL);
2753 if (hps) {
2754 GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
2755 if (!WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
2756 sizeof(lColor), &lColor, 0))
2757 lColor = 0x00CCCCCCL; //Palegray
2758 WinQueryWindowRect(hwnd, &rcl);
2759 WinFillRect(hps, &rcl, lColor);
2760 WinEndPaint(hps);
2761 }
2762
2763 }
2764 break;
2765
2766 case WM_PRESPARAMCHANGED:
2767 PresParamChanged(hwnd, PCSZ_TOOLBAR, mp1, mp2);
2768 WinInvalidateRect(hwnd, NULL, TRUE);
2769 break;
2770
2771 case UM_SETUP:
2772 {
2773 USHORT id;
2774 TOOL *tool;
2775
2776 RestorePresParams(hwnd, PCSZ_TOOLBAR);
2777 id = SHORT1FROMMP(mp1);
2778 tool = find_tool(id);
2779 if (tool) {
2780 del_tool(tool);
2781 WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
2782 if (fToolTitles)
2783 WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
2784 ResizeTools(hwnd);
2785 save_tools(NULL);
2786 }
2787 }
2788 return 0;
2789
2790 case UM_SETUP2: /* Used to load a new a toolbar */
2791 BuildTools(hwnd, TRUE);
2792 return 0;
2793
2794 case WM_CHORD:
2795 {
2796 USHORT id;
2797
2798 id = (USHORT) WinDlgBox(HWND_DESKTOP,
2799 hwnd,
2800 AddToolProc,
2801 FM3ModHandle, ADDBTN_FRAME, MPVOID);
2802 if (id && id != (USHORT) - 1)
2803 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2804 FID_CLIENT),
2805 WM_COMMAND,
2806 MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
2807 }
2808 break;
2809
2810 case WM_CONTEXTMENU:
2811 if (WinDlgBox(HWND_DESKTOP,
2812 hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
2813 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
2814 return MRFROMSHORT(TRUE);
2815
2816 case WM_CLOSE:
2817 WinDestroyWindow(hwnd);
2818 return 0;
2819
2820 case WM_DESTROY:
2821 break;
2822 }
2823 return WinDefWindowProc(hwnd, msg, mp1, mp2);
2824}
2825
2826static VOID AdjustSizeOfClient(PSWP pswp, PRECTL prectl)
2827{
2828 SWP swp;
2829 RECTL rectl;
2830
2831 if (fFreeTree)
2832 return;
2833 if (pswp) {
2834 if (WinQueryWindowPos(hwndTree, &swp) &&
2835 !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
2836 pswp->x = swp.cx;
2837 pswp->cx -= swp.cx;
2838 }
2839 }
2840 if (prectl) {
2841 if (WinQueryWindowPos(hwndTree, &swp) &&
2842 !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
2843 WinQueryWindowRect(hwndTree, &rectl)) {
2844 prectl->xLeft = rectl.xRight;
2845 prectl->xRight -= rectl.xRight;
2846 }
2847 }
2848}
2849
2850VOID FillClient(HWND hwndClient, PSWP pswp, PRECTL prectl, BOOL avoidtree)
2851{
2852 ULONG adjust;
2853
2854 adjust = WinQuerySysValue(HWND_DESKTOP, SV_CYICON);
2855 if (pswp)
2856 WinQueryWindowPos(hwndClient, pswp);
2857 if (prectl)
2858 WinQueryWindowRect(hwndClient, prectl);
2859 if (avoidtree && !fFreeTree)
2860 AdjustSizeOfClient(pswp, prectl);
2861 if (prectl)
2862 prectl->yBottom += adjust;
2863 if (pswp) {
2864 if (!avoidtree || fFreeTree)
2865 pswp->x = 0;
2866 pswp->y = adjust;
2867 if (pswp->cy >= adjust)
2868 pswp->cy -= adjust;
2869 else
2870 pswp->cy = 0;
2871 }
2872}
2873
2874static VOID MoveChildrenAwayFromTree(HWND hwndClient)
2875{
2876 SWP swpC, swpT, swp;
2877 USHORT id;
2878 HWND hwndChild;
2879 HENUM henum;
2880
2881 if (fFreeTree)
2882 return;
2883 WinQueryWindowPos(hwndClient, &swpC);
2884 if (swpC.fl & (SWP_MINIMIZE | SWP_HIDE))
2885 return;
2886 WinQueryWindowPos(hwndTree, &swpT);
2887 henum = WinBeginEnumWindows(hwndClient);
2888 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2889 id = WinQueryWindowUShort(hwndChild, QWS_ID);
2890 if (!id || id == TREE_FRAME)
2891 continue;
2892 WinQueryWindowPos(hwndChild, &swp);
2893 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
2894 if (swp.x < swpT.cx) {
2895 swp.x = swpT.cx;
2896 if (swp.x + swp.cx > swpC.cx)
2897 swp.cx = swpC.cx - swp.x;
2898 if (swp.cx > 24)
2899 WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
2900 SWP_SIZE | SWP_MOVE | SWP_SHOW);
2901 }
2902 }
2903 }
2904 WinEndEnumWindows(henum);
2905}
2906
2907static VOID ArrangeIcons(HWND hwndClient)
2908{
2909 HENUM henum;
2910 HWND hwndChild;
2911 SWP swp;
2912
2913 henum = WinBeginEnumWindows(hwndClient);
2914 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2915 WinQueryWindowPos(hwndChild, &swp);
2916 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
2917 WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
2918 WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
2919 WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
2920 SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
2921 }
2922 }
2923 WinEndEnumWindows(henum);
2924}
2925
2926static VOID NextChild(HWND hwndClient, BOOL previous)
2927{
2928 HENUM henum;
2929 HWND hwndActive, hwndNext, hwndPrev = (HWND) 0;
2930 BOOL next = FALSE, once = FALSE;
2931
2932 previous = !previous;
2933
2934 hwndActive = WinQueryActiveWindow(hwndClient);
2935 if (!hwndActive)
2936 next = TRUE;
2937 henum = WinBeginEnumWindows(hwndClient);
2938 for (;;) {
2939 hwndNext = WinGetNextWindow(henum);
2940 if (hwndNext) {
2941 if (!WinQueryWindowUShort(hwndNext, QWS_ID))
2942 continue;
2943 if (next)
2944 break;
2945 if (hwndNext == hwndActive) {
2946 if (!previous && hwndPrev) {
2947 hwndNext = hwndPrev;
2948 break;
2949 }
2950 else if (previous)
2951 next = TRUE;
2952 }
2953 hwndPrev = hwndNext;
2954 }
2955 else {
2956 if ((!next && previous) || once)
2957 break;
2958 else if (!previous) {
2959 hwndNext = hwndPrev;
2960 break;
2961 }
2962 else
2963 once = next = TRUE;
2964 }
2965 }
2966 WinEndEnumWindows(henum);
2967
2968 if (hwndNext && hwndNext != hwndActive) {
2969 WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0,
2970 SWP_ZORDER | SWP_ACTIVATE);
2971 WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 0, 0,
2972 0, 0, SWP_ZORDER);
2973 }
2974}
2975
2976BOOL CloseChildren(HWND hwndClient)
2977{
2978 HENUM henum;
2979 HWND hwndChild;
2980 BOOL ret = FALSE;
2981
2982 fNoTileUpdate = TRUE;
2983 henum = WinBeginEnumWindows(hwndClient);
2984 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2985 if (hwndChild != hwndTree) {
2986 WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
2987 WM_SAVEAPPLICATION, MPVOID, MPVOID);
2988 if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
2989 WM_CLOSE, MPVOID, MPVOID)) {
2990 ret = TRUE;
2991 break;
2992 }
2993 }
2994 }
2995 WinEndEnumWindows(henum);
2996 fNoTileUpdate = FALSE;
2997 return ret;
2998}
2999
3000BOOL CloseDirCnrChildren(HWND hwndClient)
3001{
3002 /* returns TRUE if a directory container window was told to close */
3003
3004 HENUM henum;
3005 HWND hwndChild, hwndDir, hwndTemp;
3006 BOOL ret = FALSE;
3007
3008 fNoTileUpdate = TRUE;
3009 henum = WinBeginEnumWindows(hwndClient);
3010 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3011 if (hwndChild != hwndTree) {
3012 hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT);
3013 if (hwndTemp) {
3014 hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
3015 if (hwndDir) {
3016 WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
3017 WM_CLOSE, MPVOID, MPVOID);
3018 ret = TRUE;
3019 }
3020 }
3021 }
3022 }
3023 WinEndEnumWindows(henum);
3024 fNoTileUpdate = FALSE;
3025 return ret;
3026}
3027
3028/** Save directory container state
3029 * @param hwndClient Client window handle
3030 * @param pszStateName State name to save, NULL to save global state
3031 * @returns Number of directory container windows that were saved or -1 if error
3032 * @seealso RestoreDirCnrState
3033 */
3034
3035INT SaveDirCnrState(HWND hwndClient, PCSZ pszStateName)
3036{
3037 HENUM henum;
3038 HWND hwndChild, hwndDir, hwndC;
3039 ULONG numsaves = 0, flWindowAttr;
3040 ULONG previous_numsaves, ulTemp = sizeof(ULONG);
3041 CHAR szPrefix[STATE_NAME_MAX_BYTES + 1];
3042 CHAR szKey[STATE_NAME_MAX_BYTES + 80], szKeyBase[STATE_NAME_MAX_BYTES + 80], *eos;
3043 CHAR szDir[CCHMAXPATH];
3044 SWP swp;
3045 DIRCNRDATA *dcd;
3046 BOOL fIsShutDownState;
3047
3048 if (!pszStateName || !*pszStateName) {
3049 Runtime_Error(pszSrcFile, __LINE__, NULL);
3050 return -1;
3051 }
3052 if (strlen(pszStateName) > sizeof(szPrefix) - 2) {
3053 Runtime_Error(pszSrcFile, __LINE__, "SaveDirCnrState");
3054 return -1;
3055 }
3056
3057 fIsShutDownState = strcmp(pszStateName, PCSZ_SHUTDOWNSTATE) == 0;
3058 sprintf(szPrefix, "%s.", pszStateName);
3059
3060 if (*lasttoolbar) {
3061 sprintf(szKey, "%sToolbar", szPrefix);
3062 PrfWriteProfileString(fmprof, FM3Str, szKey, lasttoolbar);
3063 }
3064
3065 if (!fIsShutDownState) {
3066 sprintf(szKey, "%sTargetDir", szPrefix);
3067 PrfWriteProfileString(fmprof, FM3Str, szKey, targetdir);
3068 sprintf(szKey, "%sVersion", szPrefix);
3069 PrfWriteProfileString(fmprof, FM3Str, szKey, "3.16");
3070 }
3071
3072 henum = WinBeginEnumWindows(hwndClient);
3073 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3074 if (hwndChild != hwndTree) {
3075 hwndC = WinWindowFromID(hwndChild, FID_CLIENT);
3076 if (hwndC) {
3077 hwndDir = WinWindowFromID(hwndC, DIR_CNR);
3078 if (hwndDir) {
3079 WinQueryWindowPos(hwndChild, &swp);
3080 *szDir = 0;
3081 WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
3082 if (*szDir) {
3083 // If saving shutdown state skip no prescan drives
3084 if (fIsShutDownState &&
3085 driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
3086 continue;
3087 }
3088 sprintf(szKeyBase, "%sDirCnr.%lu", szPrefix, numsaves);
3089 strcpy(szKey, szKeyBase);
3090 strcat(szKey, ".");
3091 eos = &szKey[strlen(szKey)];
3092 strcpy(eos, "Pos");
3093 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
3094 sizeof(SWP));
3095 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
3096 if (dcd) {
3097 strcpy(eos, "Sort");
3098 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
3099 sizeof(INT));
3100 strcpy(eos, "Filter");
3101 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
3102 sizeof(MASK));
3103 strcpy(eos, "View");
3104 flWindowAttr = dcd->flWindowAttr;
3105 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
3106 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
3107 if (dcd->lastattr) {
3108 if (dcd->lastattr & CV_TEXT)
3109 flWindowAttr |= CV_TEXT;
3110 else if (dcd->lastattr & CV_DETAIL)
3111 flWindowAttr |= CV_DETAIL;
3112 else if (dcd->lastattr & CV_ICON)
3113 flWindowAttr |= CV_ICON;
3114 else
3115 flWindowAttr |= CV_NAME;
3116 }
3117 else
3118 flWindowAttr |= CV_NAME;
3119 }
3120 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &flWindowAttr,
3121 sizeof(ULONG));
3122 WriteDetailsSwitches(szKeyBase, &dcd->ds, TRUE);
3123 SavePresParams(hwndDir, szKeyBase);
3124 }
3125 strcpy(eos, "Dir");
3126 PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
3127 numsaves++;
3128 }
3129 }
3130 }
3131 }
3132 } // while
3133 WinEndEnumWindows(henum);
3134
3135 sprintf(szKey, "%sNumDirsLastTime", szPrefix);
3136 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &previous_numsaves, &ulTemp)) {
3137 ULONG size = 0;
3138
3139 sprintf(szKey, "%sVersion", szPrefix);
3140 PrfQueryProfileSize(fmprof, FM3Str, szKey, &size);
3141 if (!size && fSaveState) {
3142 for (ulTemp = 0; ulTemp < previous_numsaves; ulTemp++)
3143 RemoveOldCnrSwitches(szPrefix, ulTemp);
3144 sprintf(szKey, "%sVersion", szPrefix);
3145 PrfWriteProfileString(fmprof, FM3Str, szKey, "3.16");
3146 }
3147 for (ulTemp = numsaves; ulTemp < previous_numsaves; ulTemp++) {
3148 sprintf(szKeyBase, "%sDirCnr.%lu", szPrefix, ulTemp);
3149 RemoveCnrSwitches(szKeyBase, NULL);
3150 }
3151 }
3152 sprintf(szKey, "%sNumDirsLastTime", szPrefix);
3153 if (numsaves) {
3154 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, sizeof(ULONG));
3155 WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swp);
3156 sprintf(szKey, "%sMySizeLastTime", szPrefix);
3157 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, sizeof(SWP));
3158 if (WinQueryWindowPos(hwndTree, &swp)) {
3159 sprintf(szKey, "%sLastTreePos", szPrefix);
3160 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, sizeof(SWP));
3161 }
3162 }
3163 else if (fIsShutDownState) {
3164 PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, sizeof(ULONG));
3165 }
3166 return numsaves;
3167}
3168
3169static VOID TransformSwp(PSWP pswp, double xtrans, double ytrans)
3170{
3171 SWP swp;
3172 HWND hwnd;
3173
3174 if ((LONG) pswp->x < 0L) {
3175 pswp->cx -= abs(pswp->x);
3176 pswp->x = 0;
3177 }
3178 if ((LONG) pswp->y < 0L) {
3179 pswp->cy -= abs(pswp->y);
3180 pswp->y = 0;
3181 }
3182 pswp->x = (LONG) (((double)pswp->x * 100.0) / xtrans);
3183 pswp->cx = (LONG) (((double)pswp->cx * 100.0) / xtrans);
3184 pswp->y = (LONG) (((double)pswp->y * 100.0) / ytrans);
3185 pswp->cy = (LONG) (((double)pswp->cy * 100.0) / ytrans);
3186 if (pswp->hwnd) {
3187 hwnd = WinQueryWindow(pswp->hwnd, QW_PARENT);
3188 if (hwnd) {
3189 if (WinQueryWindowPos(hwnd, &swp)) {
3190 if (pswp->x > swp.cx)
3191 pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
3192 if (pswp->y > swp.cy)
3193 pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
3194 if (pswp->x + pswp->cx > swp.cx)
3195 pswp->cx = swp.cx - pswp->x;
3196 if (pswp->y + pswp->cy > swp.cy)
3197 pswp->cy = swp.cy - pswp->y;
3198 }
3199 }
3200 }
3201}
3202
3203/** Restore directory container state
3204 * @param hwndClient Client window handle
3205 * @param pszStateName State name to restore, NULL to restore global state
3206 * @param noview request view state restore bypass
3207 * @returns TRUE if one or more directory containers were opened
3208 * @seealso SaveDirCnrState
3209 */
3210
3211static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview)
3212{
3213 CHAR szKey[STATE_NAME_MAX_BYTES + 80], szKeyBase[STATE_NAME_MAX_BYTES + 80];
3214 CHAR szDir[CCHMAXPATH];
3215 CHAR szPrefix[STATE_NAME_MAX_BYTES + 2];
3216 HWND hwndDir, hwndC, hwndPPSave = NULLHANDLE;
3217 SWP swp, swpO, swpN;
3218 ULONG size, numsaves = 0;
3219 LONG x;
3220 double xtrans, ytrans;
3221 BOOL fRestored = FALSE;
3222 DIRCNRDATA localdcd, *dcd;
3223 BOOL fIsShutDownState;
3224 BOOL fDeleteState;
3225
3226 if (!pszStateName || !*pszStateName) {
3227 Runtime_Error(pszSrcFile, __LINE__, "no name");
3228 return fRestored;
3229 }
3230 if (strlen(pszStateName) > sizeof(szPrefix) - 2) {
3231 Runtime_Error(pszSrcFile, __LINE__, "name too long");
3232 return fRestored;
3233 }
3234
3235 sprintf(szPrefix, "%s.", pszStateName);
3236
3237 // If restoring shutdown state bypass no-prescan drives
3238 fIsShutDownState = strcmp(pszStateName, PCSZ_SHUTDOWNSTATE) == 0;
3239 // Delete saved state if internally saved state
3240 fDeleteState = strcmp(pszStateName, PCSZ_FM2TEMPTEXT) == 0;
3241 sprintf(szKey, "%sToolbar", szPrefix);
3242 {
3243 if (fToolsChanged)
3244 save_tools(NULL);
3245 PrfQueryProfileString(fmprof, FM3Str, szKey, NULL, lasttoolbar, sizeof(lasttoolbar));
3246 PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
3247 load_tools(NULL);
3248 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
3249 }
3250 sprintf(szKey, "%sTargetDir", szPrefix);
3251 {
3252 PrfQueryProfileString(fmprof, FM3Str, szKey, NULL, targetdir, sizeof(targetdir));
3253 PrfWriteProfileString(fmprof, FM3Str, "TargetDir", targetdir);
3254 SetTargetDir(NULLHANDLE, TRUE);
3255 }
3256 size = sizeof(SWP);
3257 sprintf(szKey, "%sMySizeLastTime", szPrefix);
3258 if (!PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swpO, &size) ||
3259 size != sizeof(SWP) || !swp.cx || !swp.cy)
3260 {
3261 WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpO);
3262 }
3263 // If restoring internally saved state, forget info
3264 if (fDeleteState)
3265 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3266 WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpN);
3267 if (swpN.fl & (SWP_MINIMIZE | SWP_HIDE))
3268 swpN = swpO;
3269 xtrans = ((double)swpO.cx * 100.0) / (double)swpN.cx;
3270 ytrans = ((double)swpO.cy * 100.0) / (double)swpN.cy;
3271 size = sizeof(SWP);
3272 sprintf(szKey, "%sLastTreePos", szPrefix);
3273 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) {
3274 if (fDeleteState)
3275 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3276 swp.hwnd = hwndTree;
3277 TransformSwp(&swp, xtrans, ytrans);
3278 if (!fFreeTree) {
3279 WinQueryWindowPos(hwndClient, &swpN);
3280 swp.x = 0;
3281 swp.y = (swpN.cy - swp.cy);
3282 }
3283 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) {
3284 swp.fl &= (~SWP_ACTIVATE);
3285 WinSetWindowPos(hwndTree,
3286 HWND_TOP,
3287 swp.x,
3288 swp.y,
3289 swp.cx,
3290 swp.cy,
3291 swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
3292 }
3293 else {
3294 WinSetWindowPos(hwndTree,
3295 HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
3296 WinSetWindowUShort(hwndTree, QWS_XRESTORE, (USHORT) swp.x);
3297 WinSetWindowUShort(hwndTree, QWS_CXRESTORE, (USHORT) swp.cx);
3298 WinSetWindowUShort(hwndTree, QWS_YRESTORE, (USHORT) swp.y);
3299 WinSetWindowUShort(hwndTree, QWS_CYRESTORE, (USHORT) swp.cy);
3300 }
3301 }
3302 sprintf(szKey, "%sNumDirsLastTime", szPrefix);
3303 size = sizeof(ULONG);
3304 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, &size)) {
3305 if (fDeleteState)
3306 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
3307 for (x = numsaves - 1; x >= 0; x--) {
3308 CHAR *eos = szKey;
3309
3310 sprintf(szKeyBase, "%sDirCnr.%lu", szPrefix, x);
3311 strcpy(szKey, szKeyBase);
3312 strcat(szKey, ".");
3313 eos = &szKey[strlen(szKey)];
3314 strcpy(eos, "Pos");
3315 size = sizeof(SWP);
3316 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) {
3317 strcpy(eos, "Dir"); ;
3318 size = sizeof(szDir);
3319 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
3320 // If restoring shutdown state and drive marked no prescan
3321 // bypass window restore
3322 if (fIsShutDownState &&
3323 driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
3324 RemoveCnrSwitches(szKeyBase, NULL);
3325 RemoveOldCnrSwitches(szPrefix, x);
3326 continue;
3327 }
3328 if (x == 0 && fSwitchTree)
3329 pszFocusDir = xstrdup(szDir, pszSrcFile, __LINE__);
3330 LoadDetailsSwitches(szKeyBase, &localdcd.ds, TRUE);
3331 hwndDir = (HWND) WinSendMsg(hwndClient,
3332 UM_SETDIR,
3333 MPFROMP(szDir), MPFROMLONG(1));
3334 if (hwndDir) {
3335 hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
3336 if (hwndC) {
3337 HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
3338 if (!hwndPPSave) {
3339 hwndPPSave = WinCreateWindow(hwndCnr, // Create a window (used to save default presparams)
3340 (CHAR *) WC_CONTAINER,
3341 NULL,
3342 CCS_AUTOPOSITION | CCS_MINIICONS |
3343 CCS_MINIRECORDCORE | ulCnrType,
3344 0,
3345 0,
3346 0,
3347 0,
3348 hwndCnr,
3349 HWND_TOP, (ULONG) -1, NULL, NULL);
3350 CopyPresParams(hwndPPSave, hwndC);
3351 RestorePresParams(hwndPPSave, PCSZ_DIRCNR);
3352 }
3353 RestorePresParams(hwndCnr, szKeyBase);
3354 dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
3355 if (dcd) {
3356 dcd->ds.detailslongname = localdcd.ds.detailslongname;
3357 dcd->ds.detailssubject = localdcd.ds.detailssubject ;
3358 dcd->ds.detailsattr = localdcd.ds.detailsattr ;
3359 dcd->ds.detailsea = localdcd.ds.detailsea ;
3360 dcd->ds.detailssize = localdcd.ds.detailssize ;
3361 dcd->ds.detailsicon = localdcd.ds.detailsicon ;
3362 dcd->ds.detailscrdate = localdcd.ds.detailscrdate ;
3363 dcd->ds.detailscrtime = localdcd.ds.detailscrtime ;
3364 dcd->ds.detailsladate = localdcd.ds.detailsladate ;
3365 dcd->ds.detailslatime = localdcd.ds.detailslatime ;
3366 dcd->ds.detailslwdate = localdcd.ds.detailslwdate ;
3367 dcd->ds.detailslwtime = localdcd.ds.detailslwtime ;
3368 strcpy(eos, "Sort");
3369 size = sizeof(INT);
3370 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &dcd->sortFlags,
3371 &size)) {
3372 if (!dcd->sortFlags)
3373 dcd->sortFlags = SORT_PATHNAME;
3374 }
3375 size = sizeof(MASK);
3376 strcpy(eos, "Filter");
3377 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &dcd->mask, &size)) {
3378 if (*dcd->mask.szMask)
3379 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
3380 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
3381 }
3382 *(dcd->mask.prompt) = 0;
3383 strcpy(eos, "View");
3384 if (!noview) {
3385 size = sizeof(ULONG);
3386 if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &dcd->flWindowAttr,
3387 &size)) {
3388
3389 CNRINFO cnri;
3390
3391 memset(&cnri, 0, sizeof(CNRINFO));
3392 cnri.cb = sizeof(CNRINFO);
3393 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
3394 CM_QUERYCNRINFO,
3395 MPFROMP(&cnri),
3396 MPFROMLONG(sizeof(CNRINFO)))) {
3397 cnri.flWindowAttr = dcd->flWindowAttr;
3398 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
3399 CM_SETCNRINFO,
3400 MPFROMP(&cnri),
3401 MPFROMLONG(CMA_FLWINDOWATTR));
3402 }
3403 }
3404 }
3405 if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
3406 WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
3407 }
3408 }
3409 fRestored = TRUE;
3410 swp.hwnd = hwndDir;
3411 TransformSwp(&swp, xtrans, ytrans);
3412 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
3413 WinSetWindowPos(hwndDir,
3414 HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
3415 WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
3416 WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
3417 WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
3418 WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
3419 } else
3420 WinSetWindowPos(hwndDir,
3421 HWND_TOP,
3422 swp.x,
3423 swp.y,
3424 swp.cx,
3425 swp.cy,
3426 swp.fl | SWP_MOVE |
3427 SWP_SIZE | SWP_SHOW | SWP_ZORDER |
3428 SWP_ACTIVATE);
3429 }
3430 if (fDeleteState)
3431 RemoveCnrSwitches(szKeyBase, pszStateName);
3432 }
3433 }
3434 } // for
3435 if (hwndPPSave) {
3436 SavePresParams(hwndPPSave, PCSZ_DIRCNR);
3437 WinDestroyWindow(hwndPPSave);
3438 }
3439 }
3440 return fRestored;
3441}
3442
3443static ULONG CountChildren(HWND hwndClient, ULONG * ulNumMinChildren)
3444{
3445 HENUM henum;
3446 HWND hwndChild;
3447 SWP swp;
3448 register ULONG ulCnt = 0L;
3449 USHORT id;
3450
3451 if (ulNumMinChildren)
3452 *ulNumMinChildren = 0L;
3453 henum = WinBeginEnumWindows(hwndClient);
3454 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3455 id = WinQueryWindowUShort(hwndChild, QWS_ID);
3456 if (!id || (!fFreeTree && id == TREE_FRAME))
3457 continue;
3458 ulCnt++;
3459 if (ulNumMinChildren) {
3460 if (WinQueryWindowPos(hwndChild, &swp) && (swp.fl & SWP_MINIMIZE))
3461 (*ulNumMinChildren)++;
3462 }
3463 }
3464 WinEndEnumWindows(henum);
3465 return ulCnt;
3466}
3467
3468VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR,
3469 ULONG * ulNumMinChildrenR)
3470{
3471 register ULONG ulCnt;
3472 ULONG ulNumMinChildren;
3473 RECTL Rectl;
3474 register ULONG ulXDiff, ulYDiff, ulWindowsPerStack;
3475
3476 if (!ulCntR || !ulNumMinChildrenR)
3477 ulCnt = CountChildren(hwndClient, &ulNumMinChildren);
3478 else {
3479 ulCnt = *ulCntR;
3480 ulNumMinChildren = *ulNumMinChildrenR;
3481 if (ulCnt == (ULONG) - 1) {
3482 ulCnt = CountChildren(hwndClient, &ulNumMinChildren);
3483 /* return these values to the caller for later use */
3484 *ulCntR = ulCnt;
3485 *ulNumMinChildrenR = ulNumMinChildren;
3486 }
3487 }
3488 WinQueryWindowRect(hwndClient, &Rectl);
3489 AdjustSizeOfClient(NULL, &Rectl);
3490 if (!fFreeTree) {
3491
3492 SWP swp;
3493
3494 WinQueryWindowPos(hwndTree, &swp);
3495 if (ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
3496 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3497 }
3498 else if (ulNumMinChildren)
3499 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3500
3501 ulXDiff = WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER) +
3502 WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON) / 2;
3503 ulYDiff = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER) +
3504 WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON);
3505 ulWindowsPerStack = (Rectl.yTop - Rectl.yBottom) / (3 * ulYDiff);
3506 pswp->cx = Rectl.xRight - (ulWindowsPerStack * ulXDiff);
3507 pswp->cy = (Rectl.yTop - Rectl.yBottom) - (ulWindowsPerStack * ulYDiff);
3508 ulWindowsPerStack++;
3509 pswp->x = Rectl.xLeft + ((ulCnt % ulWindowsPerStack) * ulXDiff);
3510 pswp->y = (Rectl.yTop - pswp->cy - ((ulCnt % ulWindowsPerStack) * ulYDiff));
3511}
3512
3513static VOID CascadeChildren(HWND hwndClient)
3514{
3515 ULONG ulCnt = 0L, ulNumMinChildren;
3516 HWND hwndChild;
3517 HENUM henum;
3518 SWP swp;
3519 USHORT id;
3520 RECTL Rectl;
3521
3522 WinQueryWindowPos(hwndClient, &swp);
3523 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE))
3524 return;
3525
3526 CountChildren(hwndClient, &ulNumMinChildren);
3527 if (!fFreeTree) {
3528 WinQueryWindowRect(hwndClient, &Rectl);
3529 AdjustSizeOfClient(NULL, &Rectl);
3530 WinQueryWindowPos(hwndTree, &swp);
3531 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
3532 if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
3533 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
3534 if (swp.x != 0)
3535 swp.x = 0;
3536 if (swp.y < 0)
3537 swp.y = 0;
3538 if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
3539 swp.cx = Rectl.xRight - Rectl.xLeft;
3540 WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
3541 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
3542 }
3543 }
3544 henum = WinBeginEnumWindows(hwndClient);
3545 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3546 id = WinQueryWindowUShort(hwndChild, QWS_ID);
3547 if (!id || (!fFreeTree && id == TREE_FRAME))
3548 continue;
3549 WinQueryWindowPos(hwndChild, &swp);
3550 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) {
3551 GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren);
3552 WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
3553 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
3554 SWP_ZORDER | SWP_ACTIVATE);
3555 ulCnt++;
3556 }
3557 }
3558 WinEndEnumWindows(henum);
3559}
3560
3561VOID TileChildren(HWND hwndClient, BOOL absolute)
3562{
3563 register ULONG ulChildCnt, ulSquare, ulNumRows, ulNumCols, ulExtraCols,
3564 ulWidth, ulHeight;
3565 ULONG ulNumMinChildren;
3566 RECTL Rectl;
3567 HWND hwndChild;
3568
3569 if (fNoTileUpdate || hwndClient == HWND_DESKTOP)
3570 return;
3571 {
3572 SWP swp;
3573
3574 WinQueryWindowPos(hwndClient, &swp);
3575 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE))
3576 return;
3577 }
3578 ulChildCnt = CountChildren(hwndClient, &ulNumMinChildren);
3579 ulChildCnt -= ulNumMinChildren;
3580 if (!ulChildCnt)
3581 return;
3582
3583 fNoTileUpdate = TRUE;
3584
3585 for (ulSquare = 2; ulSquare * ulSquare <= ulChildCnt; ulSquare++) {
3586 ;
3587 }
3588 if (!fTileBackwards) {
3589 ulNumCols = ulSquare - 1;
3590 ulNumRows = ulChildCnt / ulNumCols;
3591 }
3592 else {
3593 ulNumRows = ulSquare - 1;
3594 ulNumCols = ulChildCnt / ulNumRows;
3595 }
3596 ulExtraCols = ulChildCnt % ulNumCols;
3597
3598 WinQueryWindowRect(hwndClient, &Rectl);
3599
3600 if (!fFreeTree) {
3601
3602 SWP swp;
3603
3604 WinQueryWindowPos(hwndTree, &swp);
3605 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
3606 if (swp.y < 0)
3607 swp.y = 0;
3608 if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
3609 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
3610 if (swp.x != 0)
3611 swp.x = 0;
3612 if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
3613 swp.cx = Rectl.xRight - Rectl.xLeft;
3614 WinSetWindowPos(hwndTree,
3615 HWND_TOP,
3616 swp.x,
3617 swp.y,
3618 swp.cx,
3619 swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
3620 WinQueryWindowPos(hwndTree, &swp);
3621 }
3622 if (ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
3623 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3624 }
3625 else if (ulNumMinChildren)
3626 Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3627
3628 AdjustSizeOfClient(NULL, &Rectl);
3629
3630 if (Rectl.xRight > 0L && (Rectl.yBottom < Rectl.yTop)) {
3631
3632 HENUM henum;
3633
3634 henum = WinBeginEnumWindows(hwndClient);
3635 if ((hwndChild = WinGetNextWindow(henum)) != (HWND) 0) {
3636
3637 ULONG ulCurRow, ulCurCol;
3638 SWP swp;
3639 USHORT id;
3640
3641 ulHeight = (Rectl.yTop - Rectl.yBottom) / ulNumRows;
3642
3643 for (ulCurRow = 0; ulCurRow < ulNumRows; ulCurRow++) {
3644 if ((ulNumRows - ulCurRow) <= ulExtraCols)
3645 ulNumCols++;
3646 for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
3647 ulWidth = Rectl.xRight / ulNumCols;
3648
3649 while (hwndChild) {
3650 id = WinQueryWindowUShort(hwndChild, QWS_ID);
3651 if (id && (id != TREE_FRAME || fFreeTree)) {
3652 WinQueryWindowPos(hwndChild, &swp);
3653 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
3654 break;
3655 }
3656 hwndChild = WinGetNextWindow(henum);
3657 }
3658
3659 if (hwndChild) {
3660 if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
3661 WinGetMaxPosition(hwndChild, &swp);
3662 WinSetWindowPos(hwndChild,
3663 HWND_TOP,
3664 swp.x,
3665 swp.y,
3666 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
3667 WinSetWindowUShort(hwndChild,
3668 QWS_XRESTORE,
3669 (USHORT) ((USHORT) ulWidth * (USHORT) ulCurCol)
3670 + (USHORT) Rectl.xLeft);
3671 WinSetWindowUShort(hwndChild,
3672 QWS_YRESTORE,
3673 (USHORT) (Rectl.yTop -
3674 (ulHeight * (ulCurRow + 1))));
3675 WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
3676 WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
3677 }
3678 else
3679 WinSetWindowPos(hwndChild,
3680 HWND_TOP,
3681 (ulWidth * ulCurCol) + Rectl.xLeft,
3682 Rectl.yTop - (ulHeight * (ulCurRow + 1)),
3683 ulWidth,
3684 ulHeight,
3685 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
3686 hwndChild = WinGetNextWindow(henum);
3687 }
3688 }
3689 if ((ulNumRows - ulCurRow) <= ulExtraCols) {
3690 ulNumCols--;
3691 ulExtraCols--;
3692 }
3693 }
3694 }
3695 WinEndEnumWindows(henum);
3696 }
3697
3698 fNoTileUpdate = FALSE;
3699}
3700
3701static VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy,
3702 SHORT newcx, SHORT newcy)
3703{
3704 /*
3705 * resize all children of the client to maintain their proportional
3706 * sizes and positions
3707 */
3708
3709 if (!newcx || !newcy || !oldcx || !oldcy)
3710 return;
3711 {
3712 HENUM henum;
3713 HWND hwndChild;
3714 register LONG x, y, cx, cy, ucx, ucy, ux, uy;
3715 SWP swp;
3716
3717 henum = WinBeginEnumWindows(hwndClient);
3718 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3719 if (!WinQueryWindowUShort(hwndChild, QWS_ID))
3720 continue;
3721 if (WinQueryWindowPos(hwndChild, &swp)) {
3722 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
3723 swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
3724 swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
3725 swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
3726 swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
3727 }
3728 else if (swp.fl & SWP_MAXIMIZE) {
3729 swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
3730 swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
3731 swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
3732 swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
3733 }
3734 cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
3735 cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
3736 x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
3737 y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
3738 if (x < 0)
3739 x = 0;
3740 if (y < 0)
3741 y = 0;
3742 ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
3743 uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
3744 ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
3745 ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
3746 if (ux + ucx > newcx)
3747 ucx = newcx - ux;
3748 if (uy + ucy > newcy)
3749 ucy = newcy - uy;
3750
3751 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
3752 WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
3753 SWP_MOVE | SWP_SIZE | SWP_SHOW);
3754 else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
3755 WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
3756 WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
3757 WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
3758 SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
3759 WinSetWindowUShort(hwndChild, QWS_XRESTORE, (USHORT) ux);
3760 WinSetWindowUShort(hwndChild, QWS_YRESTORE, (USHORT) uy);
3761 WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ucx);
3762 WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ucy);
3763 }
3764 else {
3765 WinGetMaxPosition(hwndChild, &swp);
3766 WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
3767 SWP_MOVE | SWP_SIZE | SWP_SHOW);
3768 WinSetWindowUShort(hwndChild, QWS_XRESTORE, (USHORT) ux);
3769 WinSetWindowUShort(hwndChild, QWS_YRESTORE, (USHORT) uy);
3770 WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ucx);
3771 WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ucy);
3772 }
3773 }
3774 }
3775 WinEndEnumWindows(henum);
3776 }
3777 if (!fFreeTree) {
3778
3779 RECTL Rectl;
3780 SWP swp;
3781
3782 WinQueryWindowRect(hwndClient, &Rectl);
3783 AdjustSizeOfClient(NULL, &Rectl);
3784 WinQueryWindowPos(hwndTree, &swp);
3785 if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
3786
3787 if (!fNoTreeGap) {
3788 INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
3789 if (swp.y < height)
3790 swp.y = height; // Force bottom to position
3791 }
3792 else
3793 swp.y = 0; // Force bottom to position
3794
3795 swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
3796 if (swp.cy < 0)
3797 swp.cy = 0;
3798
3799 if (swp.x != 0)
3800 swp.x = 0; // Left align
3801
3802 // AdjustSizeOfClient can return bogus xRight values - fixme someday
3803 if (Rectl.xRight >= Rectl.xLeft) {
3804 if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
3805 swp.cx = Rectl.xRight - Rectl.xLeft;
3806 }
3807 WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
3808 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
3809 }
3810 }
3811}
3812
3813static VOID MinResChildren(HWND hwndClient, ULONG cmd)
3814{
3815 HENUM henum;
3816 HWND hwndChild;
3817
3818 {
3819 SWP swp;
3820
3821 WinQueryWindowPos(hwndClient, &swp);
3822 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE))
3823 return;
3824 }
3825 henum = WinBeginEnumWindows(hwndClient);
3826 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
3827 if (!WinQueryWindowUShort(hwndChild, QWS_ID))
3828 continue;
3829 WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, cmd);
3830 }
3831}
3832
3833//=== ChildFrameButtonProc: subclass handler for WALKBUTTON and QUICKBUTTON windows ===
3834
3835static MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd,
3836 ULONG msg,
3837 MPARAM mp1, MPARAM mp2)
3838{
3839 USHORT id;
3840 static BOOL emphasized = FALSE;
3841
3842 switch (msg) {
3843 case WM_BUTTON1CLICK:
3844 case WM_CHORD:
3845 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
3846 break;
3847
3848 case WM_MOUSEMOVE:
3849 if (fOtherHelp) {
3850 if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
3851 && !WinQueryCapture(HWND_DESKTOP)) {
3852 id = WinQueryWindowUShort(hwnd, QWS_ID);
3853 switch (id) {
3854 case IDM_OPENWALK:
3855 MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
3856 break;
3857 case IDM_USERLIST:
3858 MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
3859 break;
3860 }
3861 }
3862 }
3863 break;
3864
3865 case WM_BUTTON3CLICK:
3866 case WM_BUTTON2CLICK:
3867 {
3868 USHORT cmd = 0;
3869
3870 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
3871 id = WinQueryWindowUShort(hwnd, QWS_ID);
3872 switch (id) {
3873 case IDM_OPENWALK:
3874 switch (msg) {
3875 case WM_BUTTON2CLICK:
3876 if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
3877 (KC_ALT | KC_SHIFT | KC_CTRL))
3878 cmd = IDM_GREP;
3879 else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
3880 CascadeChildren(hwndMain);
3881
3882#ifdef NEVER
3883 else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
3884 cmd = IDM_SYSINFO;
3885#endif
3886
3887 else if (shiftstate & KC_SHIFT)
3888 cmd = IDM_WINDOWDLG;
3889 else if (shiftstate & KC_CTRL)
3890 cmd = IDM_SEEALL;
3891 else if (shiftstate & KC_ALT)
3892 TileChildren(hwndMain, TRUE);
3893 else
3894 cmd = IDM_WALKDIR;
3895 break;
3896 case WM_BUTTON3CLICK:
3897 TileChildren(hwndMain, TRUE);
3898 break;
3899 }
3900 break;
3901 case IDM_USERLIST:
3902 switch (msg) {
3903 case WM_BUTTON2CLICK:
3904 if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
3905 (KC_ALT | KC_SHIFT | KC_CTRL))
3906 cmd = IDM_COLORPALETTE;
3907 else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
3908 cmd = IDM_HIDEMENU;
3909 else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
3910 cmd = IDM_NOTEBOOK;
3911 else if (shiftstate & KC_SHIFT)
3912 cmd = IDM_TOOLTITLES;
3913 else if (shiftstate & KC_CTRL)
3914 cmd = IDM_TEXTTOOLS;
3915 else if (shiftstate & KC_ALT)
3916 cmd = IDM_FONTPALETTE;
3917 else
3918 cmd = IDM_TOOLBAR;
3919 break;
3920 case WM_BUTTON3CLICK:
3921 cmd = IDM_DRIVEBAR;
3922 break;
3923 }
3924 break;
3925 } // switch id
3926
3927 if (cmd) {
3928 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
3929 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
3930 }
3931 }
3932 break;
3933
3934 case DM_DRAGOVER:
3935 id = WinQueryWindowUShort(hwnd, QWS_ID);
3936 if (id == IDM_OPENWALK) {
3937 if (!emphasized) {
3938 emphasized = TRUE;
3939 DrawTargetEmphasis(hwnd, emphasized);
3940 }
3941 if (AcceptOneDrop(hwnd, mp1, mp2))
3942 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
3943 }
3944 return MRFROM2SHORT(DOR_NEVERDROP, 0);
3945
3946 case DM_DRAGLEAVE:
3947 if (emphasized) {
3948 emphasized = FALSE;
3949 DrawTargetEmphasis(hwnd, emphasized);
3950 }
3951 break;
3952
3953 case DM_DROPHELP:
3954 DropHelp(mp1, mp2, hwnd, GetPString(IDS_OPENDROPHELP));
3955 return 0;
3956
3957 case DM_DROP:
3958 {
3959 char szFrom[CCHMAXPATH + 2];
3960
3961 if (emphasized) {
3962 emphasized = FALSE;
3963 DrawTargetEmphasis(hwnd, emphasized);
3964 }
3965 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
3966 if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
3967 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
3968 }
3969 }
3970 }
3971 return 0;
3972
3973 case WM_CLOSE:
3974 WinDestroyWindow(hwnd);
3975 return 0;
3976 }
3977 return PFNWPButton(hwnd, msg, mp1, mp2);
3978}
3979
3980static MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
3981 MPARAM mp2)
3982{
3983 PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
3984 static ULONG aheight = 0L;
3985
3986 switch (msg) {
3987 case WM_ADJUSTWINDOWPOS:
3988 {
3989 SWP *pswp;
3990
3991 pswp = (SWP *) mp1;
3992 if (fDataMin && !fAmClosing) {
3993 if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
3994
3995 SWP swp;
3996
3997 WinQueryWindowPos(hwnd, &swp);
3998 PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
3999 HideNote();
4000 }
4001 else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
4002 if (DataHwnd)
4003 PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
4004 }
4005 }
4006 if (!fAmClosing) {
4007 if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
4008 HideNote();
4009 }
4010 }
4011 break;
4012
4013 case UM_FOCUSME:
4014 CreateDataBar(HWND_DESKTOP, (ULONG) mp1);
4015 return 0;
4016
4017 case WM_BUTTON1UP:
4018 case WM_BUTTON2UP:
4019 case WM_BUTTON3UP:
4020 case WM_MOUSEMOVE:
4021 case WM_CHORD:
4022 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
4023 break;
4024
4025 case WM_CHAR:
4026 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
4027 break;
4028
4029 case WM_CONTROL:
4030 return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1,
4031 mp2);
4032
4033 case WM_COMMAND:
4034 return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
4035
4036 case WM_CALCFRAMERECT:
4037 {
4038 MRESULT mr;
4039 PRECTL prectl;
4040 LONG sheight = 20, bheight = 20;
4041
4042 mr = oldproc(hwnd, msg, mp1, mp2);
4043
4044 /*
4045 * Calculate the position of the client rectangle.
4046 * Otherwise, we'll see a lot of redraw when we move the
4047 * client during WM_FORMATFRAME.
4048 */
4049
4050 if (mr && mp2) {
4051 prectl = (PRECTL) mp1;
4052 if (prectl->yBottom != prectl->yTop) {
4053 {
4054 HPS hps;
4055 POINTL aptl[TXTBOX_COUNT];
4056
4057 hps = WinGetPS(hwndStatus);
4058 if (hps) {
4059 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
4060 bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
4061 WinReleasePS(hps);
4062 }
4063 }
4064 prectl->yBottom += (sheight + 4);
4065 prectl->yTop -= (sheight + 4);
4066 if (fMoreButtons) {
4067
4068 HPS hps;
4069 POINTL aptl[TXTBOX_COUNT];
4070
4071 hps = WinGetPS(hwndName);
4072 if (hps) {
4073 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
4074 bheight = aptl[TXTBOX_TOPLEFT].y + 6;
4075 WinReleasePS(hps);
4076 }
4077 prectl->yBottom += (bheight + 4);
4078 prectl->yTop -= (bheight + 4);
4079 }
4080 if (fToolbar) {
4081 if (!fTextTools)
4082 prectl->yTop -= ((fToolTitles) ? 50 : 40);
4083 else
4084 prectl->yTop -= 32;
4085 }
4086 if (fDrivebar) {
4087 ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
4088 ((prectl->xRight -
4089 (WinQuerySysValue(HWND_DESKTOP,
4090 SV_CYSIZEBORDER) * 2)) - 4));
4091 prectl->yTop -= (16 * (DriveLines * DRIVE_BUTTON_HEIGHT));
4092 }
4093 if (fUserComboBox) {
4094 if (!aheight) {
4095 SWP swpTemp;
4096 WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
4097 &swpTemp);
4098 aheight = swpTemp.cy;
4099 }
4100 prectl->yTop -= (aheight + 6L);
4101 }
4102 if (fAutoView) {
4103 AutoviewHeight = min(AutoviewHeight,
4104 (prectl->yTop - prectl->yBottom) - 116);
4105 AutoviewHeight = max(AutoviewHeight, 36);
4106 prectl->yBottom += (AutoviewHeight + 6);
4107 }
4108 }
4109 }
4110 return mr;
4111 }
4112
4113 case WM_FORMATFRAME:
4114 {
4115 SHORT sCount, soldCount;
4116 PSWP pswp, pswpClient, pswpNew;
4117 SWP swpClient;
4118 LONG theight = 48L, dheight = DRIVE_BUTTON_HEIGHT, width, sheight = 20, bheight = 20;
4119
4120 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
4121 soldCount = sCount;
4122
4123 /*
4124 * Reformat the frame to "squeeze" the client
4125 * and make room for status window sibling beneath
4126 * and toolbar above (if toolbar's on) and userlists
4127 * (if userlists are on).
4128 */
4129
4130 pswp = (PSWP) mp1;
4131 {
4132 SHORT x;
4133
4134 for (x = 0; x < soldCount; x++) {
4135 if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
4136 pswpClient = pswp;
4137 break;
4138 }
4139 pswp++;
4140 }
4141 }
4142
4143 {
4144 HPS hps;
4145 POINTL aptl[TXTBOX_COUNT];
4146
4147 hps = WinGetPS(hwndStatus);
4148 if (hps) {
4149 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
4150 bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
4151 WinReleasePS(hps);
4152 }
4153 if (fMoreButtons) {
4154 hps = WinGetPS(hwndName);
4155 if (hps) {
4156 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
4157 bheight = aptl[TXTBOX_TOPLEFT].y + 6;
4158 WinReleasePS(hps);
4159 }
4160 }
4161 }
4162 pswpNew = (PSWP) mp1 + soldCount;
4163 *pswpNew = *pswpClient;
4164 swpClient = *pswpClient;
4165 pswpNew->hwnd = hwndStatus;
4166 pswpNew->hwndInsertBehind = HWND_BOTTOM;
4167 pswpNew->x = swpClient.x + 3;
4168 pswpNew->y = swpClient.y + 2;
4169 if (!fSplitStatus)
4170 width = swpClient.cx - (16 + (sheight * 2) + 4);
4171 else
4172 width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
4173 width = max(width, 10);
4174 if (fSplitStatus)
4175 pswpNew->cx = width - 6;
4176 else
4177 pswpNew->cx = width - 8;
4178 pswpNew->cy = sheight;
4179 pswpClient->y = pswpNew->y + pswpNew->cy + 3;
4180 pswpClient->cy = (swpClient.cy - pswpNew->cy) - 3;
4181 sCount++;
4182
4183 if (fSplitStatus) {
4184 pswpNew = (PSWP) mp1 + (soldCount + 1);
4185 *pswpNew = *pswpClient;
4186 pswpNew->hwnd = hwndStatus2;
4187 pswpNew->hwndInsertBehind = HWND_BOTTOM;
4188 pswpNew->x = width + 8;
4189 pswpNew->y = swpClient.y + 2;
4190 pswpNew->cx = width - 6;
4191 pswpNew->cy = sheight;
4192 sCount++;
4193 }
4194 else {
4195 WinShowWindow(hwndStatus2, FALSE);
4196 WinSetWindowText(hwndStatus2, NullStr);
4197 }
4198
4199 if (fToolbar) {
4200 if (fTextTools)
4201 theight = 32L;
4202 else if (!fToolTitles)
4203 theight = 40L;
4204 pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
4205 *pswpNew = *pswpClient;
4206 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
4207 pswpNew->hwndInsertBehind = HWND_BOTTOM;
4208 pswpNew->x = swpClient.x + 2;
4209 pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
4210 pswpNew->cx = swpClient.cx - 4;
4211 pswpNew->cy = theight - 4;
4212 pswpClient->cy -= theight;
4213 sCount++;
4214 }
4215 else
4216 WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
4217
4218 if (fDrivebar) {
4219 ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
4220 pswpNew = (PSWP) mp1 + (soldCount + 1 +
4221 (fSplitStatus != FALSE) +
4222 (fToolbar != FALSE));
4223 *pswpNew = *pswpClient;
4224 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
4225 pswpNew->hwndInsertBehind = HWND_BOTTOM;
4226 pswpNew->x = swpClient.x + 2;
4227 dheight += ((dheight) * DriveLines);
4228 pswpNew->y = (swpClient.y + swpClient.cy) - (dheight);
4229 if (fToolbar)
4230 pswpNew->y -= theight;
4231 pswpNew->cx = swpClient.cx - 4;
4232 pswpNew->cy = dheight;
4233 pswpClient->cy -= dheight;
4234 sCount++;
4235 }
4236 else
4237 WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
4238
4239 if (fAutoView) {
4240 pswpNew = (PSWP) mp1 + (soldCount + 1 +
4241 (fToolbar != FALSE) +
4242 (fDrivebar != FALSE) +
4243 (fSplitStatus != FALSE));
4244 *pswpNew = *pswpClient;
4245 pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
4246 pswpNew->x = pswpClient->x + 3;
4247 pswpNew->y = pswpClient->y + 3;
4248 if (fMoreButtons)
4249 pswpNew->y += (bheight + 4);
4250 pswpNew->cx = pswpClient->cx - 6;
4251 AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
4252 AutoviewHeight = max(AutoviewHeight, 40);
4253 pswpNew->cy = AutoviewHeight;
4254 pswpClient->y += (AutoviewHeight + 6);
4255 pswpClient->cy -= (AutoviewHeight + 6);
4256 sCount++;
4257 WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
4258 }
4259 else {
4260 WinShowWindow(hwndAutoview, FALSE);
4261 WinShowWindow(hwndAutoMLE, FALSE);
4262 }
4263
4264 pswpNew = (PSWP) mp1 + (soldCount + 1 +
4265 (fToolbar != FALSE) +
4266 (fDrivebar != FALSE) +
4267 (fSplitStatus != FALSE) + (fAutoView != FALSE));
4268 *pswpNew = *pswpClient;
4269 pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWALK);
4270 pswpNew->x = swpClient.cx - ((sheight * 2) + 4);
4271 pswpNew->y = swpClient.y;
4272 pswpNew->cx = sheight + 4;
4273 pswpNew->cy = sheight + 4;
4274 sCount++;
4275 pswpNew = (PSWP) mp1 + (soldCount + 2 +
4276 (fToolbar != FALSE) +
4277 (fDrivebar != FALSE) +
4278 (fSplitStatus != FALSE) + (fAutoView != FALSE));
4279 *pswpNew = *pswpClient;
4280 pswpNew->hwnd = WinWindowFromID(hwnd, IDM_USERLIST);
4281 pswpNew->x = swpClient.cx - (sheight + 2);
4282 pswpNew->y = swpClient.y;
4283 pswpNew->cx = sheight + 4;
4284 pswpNew->cy = sheight + 4;
4285 sCount++;
4286 pswpNew = (PSWP) mp1 + (soldCount + 3 +
4287 (fToolbar != FALSE) +
4288 (fDrivebar != FALSE) +
4289 (fSplitStatus != FALSE) + (fAutoView != FALSE));
4290 *pswpNew = *pswpClient;
4291 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED);
4292 pswpNew->x = swpClient.cx - ((sheight * 2) + 16);
4293 pswpNew->y = swpClient.y;
4294 pswpNew->cx = 12;
4295 pswpNew->cy = 12;
4296 sCount++;
4297 pswpNew = (PSWP) mp1 + (soldCount + 4 +
4298 (fToolbar != FALSE) +
4299 (fDrivebar != FALSE) +
4300 (fSplitStatus != FALSE) + (fAutoView != FALSE));
4301 *pswpNew = *pswpClient;
4302 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
4303 pswpNew->x = swpClient.cx - ((sheight * 2) + 16);
4304 pswpNew->y = swpClient.y + 12;
4305 pswpNew->cx = 12;
4306 pswpNew->cy = sheight - 8;
4307 sCount++;
4308 if (fUserComboBox) {
4309 if (!aheight) {
4310 SWP swpTemp;
4311 WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
4312 &swpTemp);
4313 aheight = swpTemp.cy;
4314 }
4315 pswpNew = (PSWP) mp1 + (soldCount + 5 +
4316 (fToolbar != FALSE) +
4317 (fSplitStatus != FALSE) +
4318 (fDrivebar != FALSE) + (fAutoView != FALSE));
4319 *pswpNew = *pswpClient;
4320 pswpNew->hwnd = hwndDrivelist;
4321 pswpNew->x = swpClient.x;
4322 pswpNew->cx = 48;
4323 pswpClient->cy -= (aheight + 6L);
4324 pswpNew->y = pswpClient->y;
4325 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4326 sCount++;
4327 pswpNew = (PSWP) mp1 + (soldCount + 6 +
4328 (fToolbar != FALSE) +
4329 (fDrivebar != FALSE) +
4330 (fSplitStatus != FALSE) +
4331 (fAutoView != FALSE));
4332 *pswpNew = *pswpClient;
4333 pswpNew->hwnd = hwndStatelist;
4334 pswpNew->x = swpClient.x + 48;
4335 pswpNew->cx = (swpClient.cx - 48) / 7;
4336 pswpNew->y = pswpClient->y;
4337 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4338 sCount++;
4339 pswpNew = (PSWP) mp1 + (soldCount + 7 +
4340 (fToolbar != FALSE) +
4341 (fDrivebar != FALSE) +
4342 (fSplitStatus != FALSE) +
4343 (fAutoView != FALSE));
4344 *pswpNew = *pswpClient;
4345 pswpNew->hwnd = hwndCmdlist;
4346 pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
4347 pswpNew->cx = (swpClient.cx - 48) / 5 +
4348 ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
4349 pswpNew->y = pswpClient->y;
4350 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4351 sCount++;
4352 pswpNew = (PSWP) mp1 + (soldCount + 8 +
4353 (fToolbar != FALSE) +
4354 (fDrivebar != FALSE) +
4355 (fSplitStatus != FALSE) +
4356 (fAutoView != FALSE));
4357 *pswpNew = *pswpClient;
4358 pswpNew->hwnd = hwndUserlist;
4359 pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
4360 pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
4361 ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
4362 pswpNew->y = pswpClient->y;
4363 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4364 sCount++;
4365 if (fToolbar) {
4366 pswpNew = (PSWP) mp1 + (soldCount + 9 +
4367 (fToolbar != FALSE) +
4368 (fDrivebar != FALSE) +
4369 (fSplitStatus != FALSE) +
4370 (fAutoView != FALSE));
4371 *pswpNew = *pswpClient;
4372 pswpNew->hwnd = hwndButtonlist;
4373 pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
4374 pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
4375 pswpNew->y = pswpClient->y;
4376 pswpNew->cy = pswpClient->cy + (aheight + 5L);
4377 sCount++;
4378 }
4379 else
4380 WinShowWindow(hwndButtonlist, FALSE);
4381 }
4382 else {
4383 WinShowWindow(hwndUserlist, FALSE);
4384 WinShowWindow(hwndDrivelist, FALSE);
4385 WinShowWindow(hwndStatelist, FALSE);
4386 WinShowWindow(hwndButtonlist, FALSE);
4387 WinShowWindow(hwndCmdlist, FALSE);
4388 }
4389 {
4390 PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
4391 SHORT x;
4392
4393 pswpNew = (PSWP) mp1 + (soldCount + 5 +
4394 (fToolbar != FALSE) +
4395 (fDrivebar != FALSE) +
4396 (fSplitStatus != FALSE) +
4397 (fAutoView != FALSE) +
4398 ((fUserComboBox != FALSE) * 4) +
4399 (fUserComboBox != FALSE &&
4400 fToolbar != FALSE));
4401 pswp = (PSWP) mp1;
4402 for (x = 0; x < soldCount; x++) {
4403 if (!pswpTitlebar &&
4404 WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
4405 pswpTitlebar = pswp;
4406 else if (!pswpMinbutton &&
4407 WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
4408 pswpMinbutton = pswp;
4409 if (pswpTitlebar && pswpMinbutton)
4410 break;
4411 pswp++;
4412 }
4413 if (pswpMinbutton && pswpTitlebar) {
4414 *pswpNew = *pswpMinbutton;
4415 pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
4416 pswpNew->cy = pswpMinbutton->cy + 3;
4417 pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
4418 pswpTitlebar->cx -= (pswpNew->cx - 1);
4419 pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
4420 pswpNew->y = pswpMinbutton->y - 1;
4421 sCount++;
4422 }
4423 else
4424 WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
4425 }
4426
4427 if (fMoreButtons) {
4428
4429 LONG lastx;
4430
4431 pswpNew = (PSWP) mp1 + (soldCount + 6 +
4432 (fToolbar != FALSE) +
4433 (fDrivebar != FALSE) +
4434 (fSplitStatus != FALSE) +
4435 (fAutoView != FALSE) +
4436 ((fUserComboBox != FALSE) * 4) +
4437 (fUserComboBox != FALSE &&
4438 fToolbar != FALSE));
4439 *pswpNew = *pswpClient;
4440 pswpNew->hwnd = hwndName;
4441 pswpNew->x = swpClient.x + 3;
4442 pswpNew->y = swpClient.y + (sheight + 6);
4443 pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
4444 lastx = pswpNew->x + pswpNew->cx;
4445 pswpNew->cy = bheight;
4446 pswpClient->y += (bheight + 4);
4447 pswpClient->cy -= (bheight + 4);
4448 sCount++;
4449 pswpNew = (PSWP) mp1 + (soldCount + 7 +
4450 (fToolbar != FALSE) +
4451 (fDrivebar != FALSE) +
4452 (fSplitStatus != FALSE) +
4453 (fAutoView != FALSE) +
4454 ((fUserComboBox != FALSE) * 4) +
4455 (fUserComboBox != FALSE &&
4456 fToolbar != FALSE));
4457 *pswpNew = *pswpClient;
4458 pswpNew->hwnd = hwndDate;
4459 pswpNew->x = lastx + 3;
4460 pswpNew->y = swpClient.y + (sheight + 6);
4461 pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
4462 lastx = pswpNew->x + pswpNew->cx;
4463 pswpNew->cy = bheight;
4464 sCount++;
4465 pswpNew = (PSWP) mp1 + (soldCount + 8 +
4466 (fToolbar != FALSE) +
4467 (fDrivebar != FALSE) +
4468 (fSplitStatus != FALSE) +
4469 (fAutoView != FALSE) +
4470 ((fUserComboBox != FALSE) * 4) +
4471 (fUserComboBox != FALSE &&
4472 fToolbar != FALSE));
4473 *pswpNew = *pswpClient;
4474 pswpNew->hwnd = hwndAttr;
4475 pswpNew->x = lastx + 3;
4476 pswpNew->y = swpClient.y + (sheight + 6);
4477 pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
4478 pswpNew->cy = bheight;
4479 sCount++;
4480 }
4481 else {
4482 WinShowWindow(hwndAttr, FALSE);
4483 WinShowWindow(hwndName, FALSE);
4484 WinShowWindow(hwndDate, FALSE);
4485 }
4486 return MRFROMSHORT(sCount);
4487 }
4488
4489 case WM_QUERYFRAMECTLCOUNT:
4490 {
4491 SHORT sCount;
4492
4493 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
4494
4495 sCount += 6;
4496 if (fSplitStatus)
4497 sCount++;
4498 if (fToolbar)
4499 sCount++;
4500 if (fUserComboBox) {
4501 sCount += 4;
4502 if (fToolbar)
4503 sCount++;
4504 }
4505 if (fDrivebar)
4506 sCount++;
4507 if (fAutoView)
4508 sCount++;
4509 if (fMoreButtons)
4510 sCount += 3;
4511 return MRFROMSHORT(sCount);
4512 }
4513
4514 case WM_CLOSE:
4515 WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
4516 return 0;
4517 }
4518 return oldproc(hwnd, msg, mp1, mp2);
4519}
4520
4521MRESULT EXPENTRY MainWMCommand(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
4522{
4523 SetShiftState();
4524 switch (SHORT1FROMMP(mp1)) {
4525
4526 case IDM_CONTEXTMENU:
4527 {
4528 HWND hwnd = WinQueryFocus(HWND_DESKTOP);
4529 // DbgMsg(pszSrcFile, __LINE__, "IDM_CONTEXTMENU %x", hwnd);
4530 if (hwnd != NULLHANDLE) {
4531 HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
4532 USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
4533 switch (id) {
4534 case MAIN_SETUPLIST:
4535 case MAIN_USERLIST:
4536 case MAIN_CMDLIST:
4537 // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
4538 WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
4539 }
4540 }
4541 }
4542 break;
4543
4544 case IDM_SETTARGET:
4545 SetTargetDir(hwnd, FALSE);
4546 break;
4547
4548 case IDM_TOAUTOMLE:
4549 if (fComments && fAutoView)
4550 WinSetFocus(HWND_DESKTOP, hwndAutoMLE);
4551 break;
4552
4553 case IDM_HIDENOTEWND:
4554 HideNote();
4555 break;
4556 case IDM_SHOWNOTEWND:
4557 ShowNote();
4558 break;
4559
4560 case IDM_COMPARE:
4561 {
4562 WALK2 wa;
4563 PCNRITEM pci;
4564
4565 memset(&wa, 0, sizeof(wa));
4566 wa.size = sizeof(wa);
4567 pci =
4568 (PCNRITEM)
4569 WinSendMsg(WinWindowFromID
4570 (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
4571 CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
4572 MPFROMSHORT(CRA_CURSORED));
4573 if (pci && (INT) pci != -1) {
4574 strcpy(wa.szCurrentPath1, pci->pszFileName);
4575 MakeValidDir(wa.szCurrentPath1);
4576 }
4577 else
4578 strcpy(wa.szCurrentPath1, pFM2SaveDirectory);
4579 TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2);
4580 if (!*wa.szCurrentPath2)
4581 strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
4582 MakeValidDir(wa.szCurrentPath2);
4583 if (WinDlgBox(HWND_DESKTOP,
4584 hwnd,
4585 WalkTwoCmpDlgProc,
4586 FM3ModHandle,
4587 WALK2_FRAME,
4588 MPFROMP(&wa)) &&
4589 !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
4590 if (!*dircompare) {
4591
4592 COMPARE *cmp;
4593
4594 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
4595 if (cmp) {
4596 cmp->size = sizeof(COMPARE);
4597 strcpy(cmp->leftdir, wa.szCurrentPath1);
4598 strcpy(cmp->rightdir, wa.szCurrentPath2);
4599 cmp->hwndParent = hwnd;
4600 cmp->dcd.hwndParent = hwnd;
4601 WinDlgBox(HWND_DESKTOP,
4602 HWND_DESKTOP,
4603 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
4604 }
4605 }
4606 else {
4607
4608 CHAR szPath1[CCHMAXPATH];
4609 CHAR szPath2[CCHMAXPATH];
4610 runemf2(SEPARATE,
4611 HWND_DESKTOP, pszSrcFile, __LINE__,
4612 NULL, NULL,
4613 "%s %s %s",
4614 dircompare,
4615 BldQuotedFileName(szPath1, wa.szCurrentPath1),
4616 BldQuotedFileName(szPath2, wa.szCurrentPath2));
4617 }
4618 }
4619 }
4620 break;
4621
4622 case IDM_EXIT:
4623 case IDM_KILLME:
4624 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
4625 break;
4626
4627 case IDM_CLI:
4628 if (fSplitStatus &&
4629 hwndStatus2 &&
4630 !WinIsWindow(WinQueryAnchorBlock(hwnd),
4631 WinWindowFromID(hwndStatus2, COMMAND_LINE)))
4632 PostMsg(hwndStatus2, UM_CLICKED, MPVOID, MPVOID);
4633 break;
4634
4635 case IDM_ADDTOUSERLIST:
4636 case IDM_DELETEFROMUSERLIST:
4637 {
4638 CHAR temp[CCHMAXPATH], path[CCHMAXPATH];
4639
4640 *temp = 0;
4641 WinQueryWindowText(hwndUserlist, CCHMAXPATH, temp);
4642 bstrip(temp);
4643 if (*temp &&
4644 !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
4645 if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
4646 add_udir(TRUE, path);
4647 if (fUdirsChanged)
4648 save_udirs();
4649 WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
4650 }
4651 else {
4652 if (!remove_udir(path))
4653 Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
4654 else {
4655 if (fUdirsChanged)
4656 save_udirs();
4657 WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
4658 }
4659 }
4660 }
4661 }
4662 break;
4663
4664 case IDM_SAVEDIRCNRSTATE:
4665 case IDM_DELETEDIRCNRSTATE:
4666 {
4667 CHAR szStateName[STATE_NAME_MAX_BYTES + 1], szKeyBase[STATE_NAME_MAX_BYTES + 1];
4668
4669 *szStateName = 0;
4670 WinQueryWindowText(hwndStatelist, STATE_NAME_MAX_BYTES, szStateName);
4671 bstrip(szStateName);
4672 // Complain if attempting to use reserved name
4673 if (stricmp(szStateName, GetPString(IDS_STATETEXT)) == 0 ||
4674 stricmp(szStateName, PCSZ_FM2TEMPTEXT) == 0)
4675 {
4676 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
4677 GetPString(IDS_WARNINGTEXT),
4678 GetPString(IDS_STATERESERVENAMETEXT), szStateName);
4679 }
4680 // Ignore request if blank
4681 else if (*szStateName) {
4682 BOOL fAbortOperation = FALSE;
4683 if (!fNoSaveState && fSaveState && stricmp(szStateName, PCSZ_SHUTDOWNSTATE) == 0)
4684 {
4685 if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
4686 GetPString(IDS_WARNINGTEXT),
4687 GetPString(IDS_SHUTDOWNSTATE_WARNING), szStateName) == MBID_NO)
4688 fAbortOperation = TRUE;
4689 }
4690 if (!fAbortOperation) {
4691 if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
4692 // Save
4693 INT nSaved = SaveDirCnrState(hwnd, szStateName);
4694 if (nSaved >= 0) {
4695 INT ret = add_setup(szStateName);
4696 if (ret == 0) {
4697 WinSendMsg(hwndStatelist, LM_INSERTITEM,
4698 MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
4699 save_setups();
4700 }
4701 else if (ret != 1) {
4702 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
4703 GetPString(IDS_WARNINGTEXT),
4704 GetPString(IDS_STATEADDFAILEDTEXT), szStateName); // 15 Apr 07 SHL failed
4705 WinSetWindowText(hwndStatelist, (CHAR *) GetPString(IDS_STATETEXT));
4706 }
4707 }
4708 else {
4709 saymsg(MB_ENTER | MB_ICONASTERISK,
4710 hwnd,
4711 GetPString(IDS_WARNINGTEXT),
4712 GetPString(IDS_STATEDATASAVEFAILED));
4713 WinSetWindowText(hwndStatelist, (CHAR *) GetPString(IDS_STATETEXT));
4714 }
4715 }
4716 else {
4717 // Delete
4718 ULONG numsaves = 0, size, x;
4719 CHAR szKey[STATE_NAME_MAX_BYTES + 80];
4720
4721 INT ret = remove_setup(szStateName);
4722 if (ret == 1)
4723 save_setups();
4724 sprintf(szKey, "%s.NumDirsLastTime", szStateName);
4725 size = sizeof(ULONG);
4726 if (!PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, &size)) {
4727 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
4728 GetPString(IDS_WARNINGTEXT),
4729 GetPString(IDS_DOESNTEXISTTEXT), szStateName);
4730 }
4731 else if (!size)
4732 Runtime_Error(pszSrcFile, __LINE__, NULL);
4733 else {
4734 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
4735 for (x = 0; x < numsaves; x++) {
4736 sprintf(szKeyBase, "%s.DirCnr.%lu", szStateName, x);
4737 RemoveCnrSwitches(szKeyBase, szStateName);
4738 size = 0;
4739 sprintf(szKey, "%sVersion", szStateName);
4740 if (PrfQueryProfileSize(fmprof, FM3Str, szKey, &size) && size)
4741 RemoveOldCnrSwitches(szStateName, x);
4742 }
4743 }
4744 PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
4745 }
4746 }
4747 }
4748 }
4749 break;
4750
4751 case IDM_IDEALSIZE:
4752 {
4753 SWP swp, swpD;
4754 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
4755 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
4756
4757 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
4758 if (swp.fl & SWP_MAXIMIZE) {
4759 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
4760 MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
4761 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
4762 }
4763 WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD);
4764 swpD.x += bsz;
4765 swpD.cx -= (bsz * 2);
4766 swpD.y += icz;
4767 swpD.cy -= (icz + bsz);
4768 if (swp.x == swpD.x && swp.y == swpD.y &&
4769 swp.cx == swpD.cx && swp.cy == swpD.cy &&
4770 // fixme to be #defined someday
4771 WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
4772 WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
4773 swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
4774 swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
4775 swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
4776 swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
4777 }
4778 else {
4779 WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
4780 WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
4781 WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
4782 WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
4783 }
4784 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP,
4785 swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
4786 }
4787 break;
4788
4789 case IDM_BLINK:
4790 {
4791 BOOL changed = FALSE;
4792
4793 if (fDataMin) {
4794 fDataMin = FALSE;
4795 changed = TRUE;
4796 }
4797 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
4798 SWP_MINIMIZE);
4799 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
4800 SWP_RESTORE | SWP_ZORDER);
4801 if (changed)
4802 fDataMin = TRUE;
4803 break;
4804 }
4805
4806 case DID_CANCEL:
4807 {
4808 HWND hwndTop = TopWindow(hwndMain, (HWND) 0);
4809
4810 if (hwndTop)
4811 WinSetFocus(HWND_DESKTOP, hwndTop);
4812 }
4813 break;
4814
4815 case IDM_NOTEBOOK:
4816 case IDM_DIRCNRSETTINGS:
4817 case IDM_DIRVIEWSETTINGS:
4818 case IDM_DIRSORTSETTINGS:
4819 case IDM_COLLECTORVIEWSETTINGS:
4820 case IDM_COLLECTORSORTSETTINGS:
4821 case IDM_ARCHIVERSETTINGS:
4822 case IDM_TREECNRVIEWSETTINGS:
4823 case IDM_TREECNRSORTSETTINGS:
4824 case IDM_VIEWERSETTINGS:
4825 case IDM_VIEWERSETTINGS2:
4826 case IDM_COMPARESETTINGS:
4827 case IDM_MONOLITHICSETTINGS:
4828 case IDM_GENERALSETTINGS:
4829 case IDM_SCANSETTINGS:
4830 case IDM_BUBBLESSETTINGS:
4831 case IDM_QUICKSETTINGS:
4832 WinDlgBox(HWND_DESKTOP,
4833 hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
4834 break;
4835
4836 case IDM_VIEWHELPS:
4837 case IDM_VIEWINFS:
4838 WinDlgBox(HWND_DESKTOP,
4839 HWND_DESKTOP,
4840 ViewInfProc,
4841 FM3ModHandle,
4842 VINF_FRAME,
4843 ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
4844 MPFROMP(NullStr) : MPVOID));
4845 break;
4846
4847 case IDM_OPENWALK:
4848 {
4849 char newpath[CCHMAXPATH];
4850
4851 *newpath = 0;
4852 TopWindowName(hwnd, (HWND) 0, newpath);
4853 if (WinDlgBox(HWND_DESKTOP,
4854 hwnd,
4855 WalkAllDlgProc,
4856 FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
4857 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
4858 }
4859 break;
4860
4861 case IDM_WINDOWDLG:
4862 WindowList(hwnd);
4863 break;
4864
4865 case IDM_HELPMOUSE:
4866 case IDM_HELPCONTEXT:
4867 case IDM_HELPHINTS:
4868 case IDM_HELPPIX:
4869 case IDM_HELPTUTOR:
4870 case IDM_HELPUSERLIST:
4871 case IDM_HELP:
4872 case IDM_HELPCONTENTS:
4873 case IDM_HELPKEYS:
4874 case IDM_HELPGENERAL:
4875 if (hwndHelp) {
4876 if (SHORT1FROMMP(mp2) == CMDSRC_MENU) {
4877
4878 RECTL rcl;
4879 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
4880
4881 WinQueryWindowRect(HWND_DESKTOP, &rcl);
4882 rcl.yBottom += icz;
4883 rcl.yTop -= icz;
4884 rcl.xLeft += icz;
4885 rcl.xRight -= icz;
4886 WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
4887 }
4888 else {
4889
4890 RECTL rcl;
4891
4892 WinQueryWindowRect(HWND_DESKTOP, &rcl);
4893 rcl.yBottom += 8;
4894 rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
4895 rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
4896 rcl.xRight -= 8;
4897 WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
4898 }
4899 switch (SHORT1FROMMP(mp1)) {
4900 case IDM_HELPCONTEXT:
4901 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4902 MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
4903 break;
4904
4905 case IDM_HELPMOUSE:
4906 if (hwndHelp)
4907 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4908 MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
4909 break;
4910
4911 case IDM_HELPPIX:
4912 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4913 MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
4914 break;
4915
4916 case IDM_HELPTUTOR:
4917 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4918 MPFROM2SHORT(HELP_TUTORIAL, 0),
4919 MPFROMSHORT(HM_RESOURCEID));
4920 break;
4921
4922 case IDM_HELPHINTS:
4923 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4924 MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
4925 break;
4926
4927 case IDM_HELPGENERAL:
4928 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4929 MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
4930 break;
4931 case IDM_HELPKEYS:
4932 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4933 MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
4934 break;
4935
4936 case IDM_HELP:
4937 case IDM_HELPCONTENTS:
4938 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
4939 break;
4940
4941 case IDM_HELPUSERLIST:
4942 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
4943 MPFROM2SHORT(HELP_USERLISTS, 0),
4944 MPFROMSHORT(HM_RESOURCEID));
4945 break;
4946 }
4947 }
4948 break;
4949
4950 case IDM_EDITANYARCHIVER:
4951 EditArchiverDefinition(hwnd);
4952 break;
4953
4954 case IDM_ABOUT:
4955 WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle,
4956 ABT_FRAME, MPVOID);
4957 break;
4958
4959 case IDM_FONTPALETTE:
4960 OpenObject("<WP_FNTPAL>", Default, hwnd);
4961 break;
4962
4963 case IDM_HICOLORPALETTE:
4964 case IDM_COLORPALETTE:
4965 {
4966 CHAR *palette = "<WP_CLRPAL>";
4967 ULONG version[2];
4968
4969 if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
4970 (PVOID) & version, (ULONG) sizeof(version))) {
4971 if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
4972 if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
4973 palette = "<WP_HIRESCLRPAL>";
4974 else
4975 palette = "<WP_LORESCLRPAL>";
4976 }
4977 }
4978 OpenObject(palette, Default, hwnd);
4979 }
4980 break;
4981
4982 case IDM_SYSTEMSETUP:
4983 OpenObject("<WP_CONFIG>", Default, hwnd);
4984 break;
4985
4986 case IDM_SCHEMEPALETTE:
4987 {
4988 HOBJECT hWPSObject;
4989
4990 hWPSObject = WinQueryObject("<WP_SCHPAL>");
4991 if (hWPSObject != NULLHANDLE)
4992 WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
4993 "Spring:PM_Spring,Summer:PM_Summer,"
4994 "System:PM_System,Windows:PM_Windows;"
4995 "OPEN=DEFAULT");
4996 }
4997 break;
4998
4999 case IDM_SYSTEMCLOCK:
5000 OpenObject("<WP_CLOCK>", Default, hwnd);
5001 break;
5002
5003#ifdef NEVER
5004 case IDM_SYSINFO:
5005 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle,
5006 SYS_FRAME, NULL);
5007 break;
5008#endif
5009
5010 case IDM_INSTANT:
5011 {
5012 CHAR path[CCHMAXPATH];
5013 PCNRITEM pci = (PCNRITEM) 0;
5014
5015 if (hwndTree)
5016 pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
5017 MPFROMLONG(CMA_FIRST),
5018 MPFROMSHORT(CRA_CURSORED));
5019 if (pci && (INT) pci != -1) {
5020 strcpy(path, pci->pszFileName);
5021 MakeValidDir(path);
5022 }
5023 else
5024 strcpy(path, pFM2SaveDirectory);
5025 WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle,
5026 BAT_FRAME, MPFROMP(path));
5027 }
5028 break;
5029
5030 case IDM_WINFULLSCREEN:
5031 case IDM_DOSCOMMANDLINE:
5032 case IDM_COMMANDLINE:
5033 {
5034 CHAR *env = GetCmdSpec(FALSE), path[CCHMAXPATH];
5035 INT type = SEPARATE | WINDOWED;
5036
5037 *path = 0;
5038 TopWindowName(hwnd, (HWND) 0, path);
5039 if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE)
5040 env = GetCmdSpec(TRUE);
5041 else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) {
5042 env = "WINOS2.COM";
5043 type = SEPARATE | FULLSCREEN;
5044 }
5045 runemf2(type, hwnd, pszSrcFile, __LINE__,
5046 path, NULL, "%s", env);
5047 }
5048 break;
5049
5050 case IDM_KILLPROC:
5051 WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle,
5052 KILL_FRAME, NULL);
5053 break;
5054
5055 case IDM_AUTOVIEWCOMMENTS:
5056 case IDM_AUTOVIEWFILE:
5057 if (SHORT1FROMMP(mp1) == IDM_AUTOVIEWFILE)
5058 fComments = FALSE;
5059 else
5060 fComments = TRUE;
5061 PrfWriteProfileData(fmprof, FM3Str, "Comments", &fComments, sizeof(BOOL));
5062 WinSetWindowText((fComments) ? hwndAutoview : hwndAutoMLE, NullStr);
5063 goto AutoChange;
5064
5065 case IDM_AUTOVIEW:
5066 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
5067 &fAutoView, TRUE, "AutoView");
5068 AutoChange:
5069 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
5070 MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5071 if (fAutoView) {
5072
5073 CHAR s[CCHMAXPATH];
5074 HWND hwndDir;
5075 PCNRITEM pci;
5076
5077 hwndDir = TopWindowName(hwnd, (HWND) 0, s);
5078 if (hwndDir) {
5079 hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
5080 if (hwndDir) {
5081 hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
5082 if (hwndDir) {
5083 pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
5084 MPFROMLONG(CMA_FIRST),
5085 MPFROMSHORT(CRA_CURSORED));
5086 if (pci && (INT) pci != -1 &&
5087 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
5088 WinSendMsg(hwnd,
5089 UM_LOADFILE,
5090 MPFROMP(pci->pszFileName),
5091 (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
5092 MPVOID : MPFROMLONG(1));
5093 }
5094 }
5095 }
5096 }
5097 break;
5098
5099 case IDM_TEXTTOOLS:
5100 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
5101 &fTextTools, TRUE, "TextTools");
5102 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5103 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
5104 MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5105 break;
5106
5107 case IDM_TOOLTITLES:
5108 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
5109 &fToolTitles, TRUE, "ToolTitles");
5110 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5111 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
5112 MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5113 break;
5114
5115 case IDM_HIDEMENU:
5116 {
5117 HWND hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
5118 MenuInvisible = MenuInvisible ? FALSE : TRUE;
5119 if (MenuInvisible) {
5120 WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
5121 WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5122 FID_SYSMENU), IDM_HIDEMENU,
5123 GetPString(IDS_UNHIDEMENUTEXT));
5124 }
5125 else {
5126 WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
5127 WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5128 FID_SYSMENU), IDM_HIDEMENU,
5129 GetPString(IDS_HIDEMENUTEXT));
5130 }
5131 PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
5132 MPFROMLONG(FCF_MENU), MPVOID);
5133 PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible",
5134 &MenuInvisible, sizeof(BOOL));
5135 }
5136 break;
5137
5138 case IDM_SEEALL:
5139 case IDM_GREP:
5140 case IDM_COLLECTOR:
5141 {
5142 HWND hwndC;
5143 SWP swp;
5144 BOOL already = FALSE;
5145
5146 if (Collector)
5147 already = TRUE;
5148 if (!already && !fAutoTile && !fExternalCollector)
5149 GetNextWindowPos(hwnd, &swp, NULL, NULL);
5150 hwndC = StartCollector(fExternalCollector ? HWND_DESKTOP : hwnd, 4);
5151 if (hwndC) {
5152 if (!already && !fAutoTile && !fExternalCollector)
5153 WinSetWindowPos(hwndC, HWND_TOP,
5154 swp.x, swp.y, swp.cx, swp.cy,
5155 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
5156 else if (fAutoTile && !already)
5157 TileChildren(hwnd, TRUE);
5158 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
5159 SWP_ACTIVATE);
5160 if (SHORT1FROMMP(mp1) == IDM_GREP)
5161 PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
5162 MPFROM2SHORT(IDM_GREP, 0), MPVOID);
5163 if (SHORT1FROMMP(mp1) == IDM_SEEALL)
5164 PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
5165 MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
5166 }
5167 }
5168 break;
5169
5170 case IDM_DATABAR:
5171 CreateDataBar(HWND_DESKTOP, 0);
5172 break;
5173
5174 case IDM_TOOLLEFT:
5175 case IDM_TOOLRIGHT:
5176 {
5177 TOOL *tool;
5178
5179 if (!toolhead || !toolhead->next) {
5180 firsttool = (toolhead) ? toolhead->id : 0;
5181 break;
5182 }
5183 tool = find_tool(firsttool);
5184 if (!tool)
5185 tool = toolhead;
5186 if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) {
5187 tool = prev_tool(tool, TRUE);
5188 firsttool = tool->id;
5189 }
5190 else {
5191 tool = next_tool(tool, TRUE);
5192 firsttool = tool->id;
5193 }
5194 ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5195 MAIN_TOOLS));
5196 }
5197 break;
5198
5199 case IDM_CREATETOOL:
5200 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5201 break;
5202
5203 case IDM_TOOLBAR:
5204 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5205 IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
5206 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5207 WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5208 MAIN_TOOLS), fToolbar);
5209 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
5210 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5211 if (fDrivebar)
5212 WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5213 MAIN_DRIVES), NULL, TRUE);
5214 break;
5215
5216 case IDM_DRIVEBAR:
5217 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5218 IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
5219 WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5220 MAIN_DRIVES), fDrivebar);
5221 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
5222 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5223 PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
5224 break;
5225
5226 case IDM_USERLIST:
5227 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5228 SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
5229 WinShowWindow(hwndUserlist, fUserComboBox);
5230 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
5231 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5232 PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
5233 PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
5234 PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID);
5235 PostMsg(hwnd, UM_FILLBUTTONLIST, MPVOID, MPVOID);
5236 break;
5237
5238 case IDM_MOREBUTTONS:
5239 WinSetWindowText(hwndName, NullStr);
5240 WinSetWindowText(hwndDate, NullStr);
5241 WinSetWindowText(hwndAttr, NullStr);
5242 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5243 SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
5244 if (fMoreButtons) {
5245
5246 HWND hwndTemp;
5247
5248 hwndTemp = TopWindow(hwnd, (HWND) 0);
5249
5250 if (hwndTemp) {
5251 WinSetFocus(HWND_DESKTOP, hwnd);
5252 WinSetFocus(HWND_DESKTOP, hwndTemp);
5253 }
5254 }
5255 PostMsg(WinQueryWindow(hwnd, QW_PARENT),
5256 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
5257 break;
5258
5259 case IDM_TOGGLEDRAGDIALOG:
5260 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5261 IDM_TOGGLEDRAGDIALOG,
5262 &fDragndropDlg,
5263 TRUE,
5264 "Drag&DropDlg");
5265 break;
5266
5267 case IDM_SYNCUPDATES:
5268 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5269 IDM_SYNCUPDATES,
5270 &fSyncUpdates,
5271 TRUE,
5272 "SyncUpdates");
5273 break;
5274
5275 case IDM_FREETREE:
5276 if (fFreeTree) {
5277 SWP swp, swpT;
5278
5279 WinQueryWindowPos(hwndTree, &swpT);
5280 WinQueryWindowPos(hwnd, &swp);
5281 WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0,
5282 SWP_MOVE);
5283 }
5284 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
5285 &fFreeTree, TRUE, "FreeTree");
5286 if (fAutoTile)
5287 TileChildren(hwnd, TRUE);
5288 break;
5289
5290 case IDM_AUTOTILE:
5291 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5292 SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
5293 if (fAutoTile)
5294 TileChildren(hwnd, TRUE);
5295 break;
5296
5297 case IDM_TILEBACKWARDS:
5298 SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
5299 SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
5300 if (fAutoTile)
5301 TileChildren(hwnd, TRUE);
5302 break;
5303
5304 case IDM_NEXTWINDOW:
5305 case IDM_PREVWINDOW:
5306 NextChild(hwnd, (SHORT1FROMMP(mp1) == IDM_PREVWINDOW));
5307 break;
5308
5309 case IDM_CASCADE:
5310 CascadeChildren(hwnd);
5311 break;
5312
5313 case IDM_TILE:
5314 TileChildren(hwnd, TRUE);
5315 break;
5316
5317 case IDM_RESTORE:
5318 MinResChildren(hwnd, SWP_RESTORE);
5319 break;
5320
5321 case IDM_MINIMIZE:
5322 MinResChildren(hwnd, SWP_MINIMIZE);
5323 break;
5324
5325 case IDM_ARRANGEICONS:
5326 ArrangeIcons(hwnd);
5327 break;
5328
5329 case IDM_INIVIEWER:
5330 StartIniEditor(hwnd, NULL, 4);
5331 break;
5332
5333 case IDM_INIVIEWERSYS:
5334 StartIniEditor(hwnd, "SYS", 4);
5335 break;
5336
5337 case IDM_INIVIEWERFM2:
5338 StartIniEditor(hwnd, profile, 4);
5339 break;
5340
5341 case IDM_EDITASSOC:
5342 EditAssociations(hwnd);
5343 break;
5344
5345 case IDM_EDITCOMMANDS:
5346 EditCommands(hwnd);
5347 PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID);
5348 break;
5349
5350 default:
5351 if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER),
5352 SHORT1FROMMP(mp1))) {
5353 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
5354 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
5355
5356 INT x;
5357 HWND hwndCnr;
5358
5359 if (!cmdloaded)
5360 load_commands();
5361 hwndCnr = TopWindow(hwnd, (HWND) 0);
5362 hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
5363 UM_CONTAINERHWND, MPVOID, MPVOID);
5364 if (!hwndCnr) {
5365 Runtime_Error(pszSrcFile, __LINE__, NULL);
5366 break;
5367 }
5368 x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART;
5369 if (x >= 0) {
5370 //x++;
5371 RunCommand(hwndCnr, x);
5372 if (fUnHilite) {
5373
5374 PCNRITEM pci;
5375 DIRCNRDATA *dcd = NULL;
5376
5377 // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
5378 if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
5379 dcd = INSTDATA(hwndCnr);
5380 pci = (PCNRITEM) WinSendMsg(hwndCnr,
5381 CM_QUERYRECORDEMPHASIS,
5382 MPFROMLONG(CMA_FIRST),
5383 MPFROMSHORT(CRA_CURSORED));
5384 if (pci && (INT) pci != -1 &&
5385 (pci->rc.flRecordAttr & CRA_SELECTED))
5386 {
5387 UnHilite(hwnd,
5388 TRUE,
5389 dcd ? &dcd->lastselection : NULL,
5390 dcd ? dcd ->ulItemsToUnHilite : 0);
5391 }
5392 }
5393 }
5394 }
5395 else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
5396 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) {
5397 if (!qtloaded)
5398 load_quicktools();
5399 if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) {
5400 if (fToolsChanged)
5401 save_tools(NULL);
5402 if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]))
5403 load_tools(NULL);
5404 else {
5405 strcpy(lasttoolbar,
5406 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]);
5407 PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
5408 }
5409 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5410 }
5411 }
5412 else {
5413
5414 HWND hwndActive;
5415
5416 hwndActive = TopWindow(hwnd, (HWND) 0);
5417 if (hwndActive)
5418 PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
5419 WM_COMMAND, mp1, mp2);
5420 }
5421 }
5422 break; // default
5423 } // switch mp1
5424 return 0;
5425}
5426
5427static MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1,
5428 MPARAM mp2)
5429{
5430 TID tid;
5431 SWP swp;
5432 PFNWP oldproc;
5433 HWND hwndTmp;
5434 HWND hwndFrame;
5435 HWND hwndSysMenu, hwndSysSubMenu, hwndMenu;
5436 USHORT idSysMenu;
5437 MENUITEM mi, mit;
5438 ULONG size;
5439 BOOL temp = FALSE;
5440
5441 switch (msg) {
5442 case WM_CREATE:
5443 WinQueryWindowProcess(hwnd, &mypid, &tid);
5444 hwndMain = hwnd;
5445 WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
5446 WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
5447 WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
5448 WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
5449 if (xbeginthread(MakeMainObjWin,
5450 245760,
5451 MPVOID,
5452 pszSrcFile,
5453 __LINE__) == -1)
5454 {
5455 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
5456 return 0;
5457 }
5458 else
5459 DosSleep(32);//05 Aug 07 GKY 64
5460
5461 hwndFrame = WinQueryWindow(hwnd, QW_PARENT);
5462
5463 /*
5464 * create frame children (not client children, frame children)
5465 */
5466 DosSleep(1);
5467 WinQueryWindowPos(hwndFrame, &swp);
5468 oldproc = WinSubclassWindow(hwndFrame, MainFrameWndProc);
5469 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
5470 CommonCreateMainChildren(hwnd, &swp);
5471
5472 if (!WinCreateWindow(hwndFrame,
5473 (CHAR *) WC_BUTTON,
5474 "I",
5475 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
5476 ((swp.cx -
5477 WinQuerySysValue(HWND_DESKTOP,
5478 SV_CXMINMAXBUTTON)) -
5479 WinQuerySysValue(HWND_DESKTOP,
5480 SV_CXMINMAXBUTTON) / 2) -
5481 WinQuerySysValue(HWND_DESKTOP,
5482 SV_CXSIZEBORDER),
5483 (swp.cy - WinQuerySysValue(HWND_DESKTOP,
5484 SV_CYMINMAXBUTTON)) -
5485 WinQuerySysValue(HWND_DESKTOP,
5486 SV_CYSIZEBORDER),
5487 WinQuerySysValue(HWND_DESKTOP,
5488 SV_CXMINMAXBUTTON) / 2,
5489 WinQuerySysValue(HWND_DESKTOP,
5490 SV_CYMINMAXBUTTON),
5491 hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
5492 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
5493 PCSZ_WINCREATEWINDOW);
5494 }
5495 else {
5496 WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_IDEALSIZE),
5497 IdealButtonProc);
5498 //fixme to allow user to change presparams 1-10-09 GKY
5499 SetPresParams(WinWindowFromID(hwndFrame,
5500 IDM_IDEALSIZE),
5501 NULL, NULL, NULL, FNT_10SYSTEMVIO);
5502 }
5503
5504 hwndTmp = WinCreateWindow(hwndFrame,
5505 (CHAR *) WC_BUTTON,
5506 "#1019",
5507 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
5508 BS_BITMAP,
5509 swp.cx - 46,
5510 swp.y + 2,
5511 24,
5512 22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
5513 if (!hwndTmp)
5514 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
5515 PCSZ_WINCREATEWINDOW);
5516
5517 hwndTmp = WinCreateWindow(hwndFrame,
5518 (CHAR *) WC_BUTTON,
5519 "#3062",
5520 WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
5521 BS_BITMAP,
5522 swp.cx - 22,
5523 swp.y + 2,
5524 24,
5525 22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
5526 if (!hwndTmp)
5527 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
5528 PCSZ_WINCREATEWINDOW);
5529
5530 hwndUserlist = WinCreateWindow(hwndFrame,
5531 (CHAR *) WC_COMBOBOX,
5532 (PSZ) NULL,
5533 WS_VISIBLE | CBS_DROPDOWN |
5534 LS_HORZSCROLL,
5535 (swp.x +
5536 WinQuerySysValue(HWND_DESKTOP,
5537 SV_CXSIZEBORDER) + 48L),
5538 (swp.cy -
5539 WinQuerySysValue(HWND_DESKTOP,
5540 SV_CYSIZEBORDER)) - 60,
5541 ((swp.cx -
5542 (WinQuerySysValue(HWND_DESKTOP,
5543 SV_CXSIZEBORDER) *
5544 2)) - 64L), 60L, hwndFrame, HWND_TOP,
5545 MAIN_USERLIST, NULL, NULL);
5546 if (!hwndUserlist)
5547 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
5548 PCSZ_WINCREATEWINDOW);
5549 hwndCmdlist = WinCreateWindow(hwndFrame,
5550 (CHAR *) WC_COMBOBOX,
5551 (PSZ) NULL,
5552 WS_VISIBLE | CBS_DROPDOWN |
5553 LS_HORZSCROLL,
5554 (swp.x +
5555 WinQuerySysValue(HWND_DESKTOP,
5556 SV_CXSIZEBORDER) + 48L),
5557 (swp.cy -
5558 WinQuerySysValue(HWND_DESKTOP,
5559 SV_CYSIZEBORDER)) - 60,
5560 ((swp.cx -
5561 (WinQuerySysValue(HWND_DESKTOP,
5562 SV_CXSIZEBORDER) * 2)) -
5563 64L), 60L, hwndFrame, HWND_TOP,
5564 MAIN_CMDLIST, NULL, NULL);
5565 if (!hwndCmdlist)
5566 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
5567 PCSZ_WINCREATEWINDOW);
5568 WinSetWindowText(hwndCmdlist, (CHAR *) GetPString(IDS_COMMANDSTEXT));
5569 hwndStatelist = WinCreateWindow(hwndFrame,
5570 (CHAR *) WC_COMBOBOX,
5571 (PSZ) NULL,
5572 WS_VISIBLE | CBS_DROPDOWN |
5573 LS_HORZSCROLL,
5574 (swp.x +
5575 WinQuerySysValue(HWND_DESKTOP,
5576 SV_CXSIZEBORDER) + 48L),
5577 (swp.cy -
5578 WinQuerySysValue(HWND_DESKTOP,
5579 SV_CYSIZEBORDER)) - 60,
5580 ((swp.cx -
5581 (WinQuerySysValue(HWND_DESKTOP,
5582 SV_CXSIZEBORDER) *
5583 2)) - 64L), 60L, hwndFrame, HWND_TOP,
5584 MAIN_SETUPLIST, NULL, NULL);
5585 if (!hwndStatelist)
5586 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
5587 PCSZ_WINCREATEWINDOW);
5588
5589 hwndDrivelist = WinCreateWindow(hwndFrame,
5590 (CHAR *) WC_COMBOBOX,
5591 (PSZ) NULL,
5592 //WS_VISIBLE |
5593 CBS_DROPDOWN,
5594 (swp.x +
5595 WinQuerySysValue(HWND_DESKTOP,
5596 SV_CXSIZEBORDER)),
5597 (swp.cy -
5598 WinQuerySysValue(HWND_DESKTOP,
5599 SV_CYSIZEBORDER)) - 60,
5600 48L,
5601 60L,
5602 hwndFrame,
5603 HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
5604 if (!hwndDrivelist)
5605 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
5606 PCSZ_WINCREATEWINDOW);
5607 //fixme to allow user to change presparams 1-10-09 GKY
5608 SetPresParams(hwndDrivelist,
5609 NULL, NULL, NULL, FNT_10SYSTEMMONOTEXT);
5610 hwndButtonlist = WinCreateWindow(hwndFrame,
5611 (CHAR *) WC_COMBOBOX,
5612 (PSZ) NULL,
5613 WS_VISIBLE | CBS_DROPDOWN |
5614 LS_HORZSCROLL,
5615 (swp.cx -
5616 WinQuerySysValue(HWND_DESKTOP,
5617 SV_CXSIZEBORDER)) -
5618 164L,
5619 (swp.cy -
5620 WinQuerySysValue(HWND_DESKTOP,
5621 SV_CYSIZEBORDER)) - 60,
5622 164L, 60L, hwndFrame, HWND_TOP,
5623 MAIN_BUTTONLIST, NULL, NULL);
5624 if (!hwndButtonlist)
5625 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
5626 PCSZ_WINCREATEWINDOW);
5627 WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT),
5628 EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
5629 WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT),
5630 EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
5631 WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT),
5632 EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
5633 WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT),
5634 EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
5635 WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT),
5636 EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
5637
5638 oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT),
5639 DropDownListProc);
5640 WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT),
5641 QWL_USER, (PVOID) oldproc);
5642 oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT),
5643 DropDownListProc);
5644 WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT),
5645 QWL_USER, (PVOID) oldproc);
5646 oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT),
5647 DropDownListProc);
5648 WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT),
5649 QWL_USER, (PVOID) oldproc);
5650 oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT),
5651 DropDownListProc);
5652 WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT),
5653 QWL_USER, (PVOID) oldproc);
5654 oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT),
5655 DropDownListProc);
5656 WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT),
5657 QWL_USER, (PVOID) oldproc);
5658 oldproc = WinSubclassWindow(hwndUserlist, DropDownListProc);
5659 WinSetWindowPtr(hwndUserlist, QWL_USER, (PVOID) oldproc);
5660 oldproc = WinSubclassWindow(hwndCmdlist, DropDownListProc);
5661 WinSetWindowPtr(hwndCmdlist, QWL_USER, (PVOID) oldproc);
5662 oldproc = WinSubclassWindow(hwndStatelist, DropDownListProc);
5663 WinSetWindowPtr(hwndStatelist, QWL_USER, (PVOID) oldproc);
5664 oldproc = WinSubclassWindow(hwndDrivelist, DropDownListProc);
5665 WinSetWindowPtr(hwndDrivelist, QWL_USER, (PVOID) oldproc);
5666 oldproc = WinSubclassWindow(hwndButtonlist, DropDownListProc);
5667 WinSetWindowPtr(hwndButtonlist, QWL_USER, (PVOID) oldproc);
5668 oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_USERLIST),
5669 ChildFrameButtonProc);
5670 WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_USERLIST),
5671 QWL_USER, (PVOID) oldproc);
5672 oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_OPENWALK),
5673 ChildFrameButtonProc);
5674 WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_OPENWALK),
5675 QWL_USER, (PVOID) oldproc);
5676 hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
5677 WinSendMsg(hwnd, UM_ADDTOMENU, MPVOID, MPVOID);
5678 SetToggleChecks(hwndMenu);
5679 CfgMenuInit(hwndMenu, FALSE); // 14 Feb 08 SHL
5680 SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE);
5681 if (fProtectOnly) {
5682 WinEnableMenuItem(hwndMenu, IDM_DOSCOMMANDLINE, FALSE);
5683 WinEnableMenuItem(hwndMenu, IDM_WINFULLSCREEN, FALSE);
5684 }
5685 SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
5686 SetConditionalCascade(hwndMenu, IDM_AUTOVIEWSUBMENU, IDM_AUTOVIEW);
5687 SetConditionalCascade(hwndMenu, IDM_TILEMENU, IDM_TILE);
5688 WinSetWindowULong(hwnd, QWL_USER, hwndMenu);
5689 memset(&mi, 0, sizeof(mi));
5690 memset(&mit, 0, sizeof(mit));
5691 hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
5692 idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu,
5693 MM_ITEMIDFROMPOSITION,
5694 MPVOID, MPVOID));
5695 WinSendMsg(hwndSysMenu,
5696 MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
5697 hwndSysSubMenu = mit.hwndSubMenu;
5698 mi.iPosition = MIT_END;
5699 mi.afStyle = MIS_SEPARATOR;
5700 mi.id = (USHORT) - 1;
5701 WinSendMsg(hwndSysSubMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(NULL));
5702 mi.afStyle = MIS_TEXT;
5703 mi.id = IDM_IDEALSIZE;
5704 WinSendMsg(hwndSysSubMenu,
5705 MM_INSERTITEM,
5706 MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
5707 mi.afStyle = MIS_TEXT;
5708 mi.id = IDM_HIDEMENU;
5709 WinSendMsg(hwndSysSubMenu,
5710 MM_INSERTITEM,
5711 MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
5712 SetSysMenu(hwndSysMenu);
5713
5714 size = sizeof(BOOL);
5715 if (PrfQueryProfileData(fmprof, FM3Str, "MenuInvisible", &temp, &size) &&
5716 size && temp)
5717 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HIDEMENU, 0), MPVOID);
5718 size = sizeof(BOOL);
5719 if (PrfQueryProfileData(fmprof, FM3Str, "FreeTree", &temp, &size) &&
5720 size && temp)
5721 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_FREETREE, 0), MPVOID);
5722 size = sizeof(BOOL);
5723 if (PrfQueryProfileData(fmprof, FM3Str, "AutoTile", &temp, &size) &&
5724 size && !temp)
5725 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_AUTOTILE, 0), MPVOID);
5726 size = sizeof(BOOL);
5727 if (PrfQueryProfileData(fmprof, appname, "Toolbar", &temp, &size) && size && !temp)
5728 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
5729
5730 WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "FM/2");
5731 FixSwitchList(hwndFrame, NULL);
5732 break; // WM_CREATE
5733
5734 case UM_SETUP:
5735 /*
5736 * start up some initial children
5737 */
5738 WinShowWindow(WinQueryWindow(hwnd, QW_PARENT), TRUE);
5739 PostMsg(MainObjectHwnd, UM_SETUP2, mp1, mp2);
5740 return 0;
5741
5742 case UM_SETUP2:
5743 {
5744 SWP swp;
5745 ULONG size = sizeof(SWP);
5746
5747 WinQueryWindowPos(hwnd, &swp);
5748 hwndTree = StartTreeCnr(hwnd, 4);
5749 if (!hwndTree)
5750 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
5751 else {
5752 if (!fSaveState ||
5753 !PrfQueryProfileData(fmprof,
5754 FM3Str,
5755 "LastTreePos",
5756 &swp, &size) || size != sizeof(SWP)) {
5757
5758 INT ratio, height = 0;
5759
5760 if (!fNoTreeGap)
5761 height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
5762 size = sizeof(ratio);
5763 if (!PrfQueryProfileData(fmprof,
5764 FM3Str,
5765 "TreeWindowRatio",
5766 (PVOID) & ratio,
5767 &size) || size < sizeof(ratio))
5768 ratio = 400;
5769 WinSetWindowPos(hwndTree,
5770 HWND_TOP,
5771 0,
5772 height,
5773 (swp.cx * 100) / ratio,
5774 swp.cy - height,
5775 SWP_SHOW | SWP_SIZE | SWP_MOVE |
5776 SWP_ACTIVATE | SWP_ZORDER);
5777 }
5778 else
5779 WinSetWindowPos(hwndTree,
5780 HWND_TOP,
5781 swp.x,
5782 swp.y,
5783 swp.cx,
5784 swp.cy,
5785 swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
5786 SWP_ZORDER | SWP_ACTIVATE);
5787 }
5788// ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
5789// MAIN_TOOLS));
5790 }
5791 PostMsg(MainObjectHwnd, UM_SETUP3, mp1, mp2);
5792 return 0;
5793
5794 case UM_SETUP3:
5795 /* start remaining child windows */
5796 if (!fNoSaveState && fSaveState) {
5797 PCSZ pszStatename = PCSZ_SHUTDOWNSTATE;
5798 PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszStatename), MPVOID);
5799 if (!add_setup(pszStatename))
5800 save_setups();
5801 }
5802 else {
5803 load_tools(NULL);
5804 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
5805 }
5806 PostMsg(MainObjectHwnd, UM_SETUP4, mp1, mp2);
5807 return 0;
5808
5809 case UM_SETUP4:
5810 {
5811 INT argc = (INT) mp1, x;
5812 CHAR **argv = (CHAR **) mp2;
5813
5814 for (x = 1; x < argc; x++) {
5815 if (*argv[x] == '/' || *argv[x] == ';')
5816 continue;
5817 if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE)) {
5818 OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
5819 }
5820 }
5821 }
5822 PostMsg(MainObjectHwnd, UM_SETUP5, MPVOID, MPVOID);
5823 return 0;
5824
5825 case UM_SETUP5:
5826// if (fAutoTile)
5827// TileChildren(hwnd, TRUE);
5828 PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
5829 PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
5830 PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID);
5831 PostMsg(hwnd, UM_FILLBUTTONLIST, MPVOID, MPVOID);
5832 {
5833 HWND hwndActive;
5834
5835 hwndActive = TopWindow(hwnd, hwndTree);
5836 if (hwndActive)
5837 WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
5838 }
5839 if (fStartMinimized || fReminimize)
5840 PostMsg(hwndTree, UM_MINIMIZE, MPVOID, MPVOID);
5841 else if (fStartMaximized)
5842 PostMsg(hwndTree, UM_MAXIMIZE, MPVOID, MPVOID);
5843 fRunning = TRUE;
5844 if (fWantFirstTimeInit) {
5845 fWantFirstTimeInit = FALSE;
5846 PostMsg(hwnd, WM_COMMAND, MPFROMLONG(IDM_QUICKSETTINGS), MPVOID);
5847 }
5848 return 0;
5849 }
5850
5851 return WinDefWindowProc(hwnd, msg, mp1, mp2);
5852}
5853
5854MRESULT EXPENTRY MainWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
5855{
5856 switch (msg) {
5857 case WM_CREATE:
5858# ifdef FORTIFY
5859 Fortify_EnterScope();
5860# endif
5861 case UM_SETUP:
5862 case UM_SETUP2:
5863 case UM_SETUP3:
5864 case UM_SETUP4:
5865 case UM_SETUP5:
5866 return MainWMOnce(hwnd, msg, mp1, mp2);
5867
5868 case WM_CONTROLPOINTER:
5869 if (!fNoFinger &&
5870 (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
5871 SHORT1FROMMP(mp1) == IDM_USERLIST))
5872 return MRFROMLONG(hptrFinger);
5873 break;
5874
5875 case UM_LOADFILE:
5876 case UM_THREADUSE:
5877 case UM_BUILDDRIVEBAR:
5878 case WM_TIMER:
5879 return CommonMainWndProc(hwnd, msg, mp1, mp2);
5880
5881 case WM_BUTTON1UP:
5882 case WM_BUTTON2UP:
5883 case WM_BUTTON3UP:
5884 case WM_MOUSEMOVE:
5885 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
5886 break;
5887
5888 case WM_CHAR:
5889 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
5890 break;
5891
5892 case WM_MENUEND:
5893 if ((HWND) mp2 == MainPopupMenu) {
5894 WinDestroyWindow(MainPopupMenu);
5895 MainPopupMenu = (HWND) 0;
5896 }
5897 break;
5898
5899 case UM_CONTEXTMENU:
5900 case WM_CONTEXTMENU:
5901 if (CheckMenu(hwndMainMenu, &MainPopupMenu, MAIN_POPUP)) {
5902 SetToggleChecks(MainPopupMenu);
5903 PopupMenu(hwnd, hwnd, MainPopupMenu);
5904 }
5905 if (msg == UM_CONTEXTMENU)
5906 return 0;
5907 return MRFROMSHORT(TRUE);
5908
5909 case UM_SETUSERLISTNAME:
5910 if (mp1) {
5911 if (fUserComboBox)
5912 WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
5913 (CHAR *)mp1);
5914 if (add_udir(FALSE, (CHAR *)mp1)) {
5915 if (fUserComboBox && fAutoAddDirs) {
5916 WinSendMsg(hwndUserlist, LM_INSERTITEM,
5917 MPFROM2SHORT(LIT_SORTASCENDING, 0),
5918 MPFROMP((CHAR *)mp1));
5919 }
5920 }
5921 }
5922 return 0;
5923
5924 case UM_ARRANGEICONS:
5925 ArrangeIcons(hwnd);
5926 return 0;
5927
5928 case WM_CHORD:
5929 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
5930 break;
5931
5932 case WM_SETFOCUS:
5933 if (mp2)
5934 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
5935 break;
5936
5937 case UM_FOCUSME:
5938 WinSetFocus(hwndTree, TRUE);
5939 return 0;
5940
5941 case UM_RESCAN:
5942 TileChildren(hwnd, TRUE);
5943 return 0;
5944
5945 case WM_SAVEAPPLICATION:
5946 {
5947 SWP swp;
5948
5949 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
5950 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
5951 WinStoreWindowPos((CHAR *) FM2Str,
5952 "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
5953 if (!fNoSaveState && fSaveState)
5954 SaveDirCnrState(hwnd, PCSZ_SHUTDOWNSTATE);
5955 }
5956 }
5957 break;
5958
5959 case MM_PORTHOLEINIT:
5960 switch (SHORT1FROMMP(mp1)) {
5961 case 0:
5962 case 1:
5963 {
5964 HWND hwndCurrent;
5965 ULONG wmsg;
5966
5967 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
5968 hwndCurrent = TopWindow(hwnd, (HWND) 0);
5969 PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
5970 FID_CLIENT), wmsg,
5971 MPVOID, MPVOID), mp1, mp2);
5972 }
5973 break;
5974 }
5975 break;
5976
5977 case WM_INITMENU:
5978 switch (SHORT1FROMMP(mp1)) {
5979 case IDM_CONFIGMENU:
5980 SetToggleChecks((HWND) WinQueryWindowULong(hwnd, QWL_USER));
5981 break;
5982
5983 case IDM_WINDOWSMENU:
5984 /*
5985 * add child windows of client
5986 * and switchlist entries to end of pulldown menu
5987 */
5988 {
5989 HWND hwndMenu, hwndSubMenu;
5990 MENUITEM mi;
5991
5992 hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
5993 memset(&mi, 0, sizeof(mi));
5994 mi.iPosition = MIT_END;
5995 mi.afStyle = MIS_TEXT;
5996 if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
5997 MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
5998 break;
5999 hwndSubMenu = mi.hwndSubMenu;
6000 SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
6001 }
6002 break;
6003
6004 default:
6005 {
6006 HWND hwndCurrent;
6007
6008 hwndCurrent = TopWindow(hwnd, (HWND) 0);
6009 if (hwndCurrent)
6010 WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
6011 }
6012 break;
6013 }
6014 break;
6015
6016 case UM_ADDTOMENU:
6017 AddToMenu((
6018 CHAR *)mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
6019 FID_MENU));
6020 return 0;
6021
6022 case UM_FILLCMDLIST:
6023 WinSendMsg(hwndCmdlist, LM_DELETEALL, MPVOID, MPVOID);
6024 if (!cmdloaded)
6025 load_commands();
6026 if (cmdhead) {
6027
6028 LINKCMDS *info;
6029
6030 info = cmdhead;
6031 while (info) {
6032 WinSendMsg(hwndCmdlist, LM_INSERTITEM,
6033 MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
6034 info = info->next;
6035 }
6036 }
6037 return 0;
6038
6039 case UM_FILLSETUPLIST:
6040 fill_setups_list();
6041 return 0;
6042
6043 case UM_FILLBUTTONLIST:
6044 WinSendMsg(hwndButtonlist, LM_DELETEALL, MPVOID, MPVOID);
6045 if (fUserComboBox) {
6046
6047 BOOL foundit = FALSE, thisone;
6048 ULONG ulSearchCount;
6049 SHORT sSelect;
6050 FILEFINDBUF3 findbuf;
6051 HDIR hDir;
6052 CHAR *p;
6053
6054 DosError(FERR_DISABLEHARDERR);
6055 hDir = HDIR_CREATE;
6056 ulSearchCount = 1;
6057 if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED,
6058 &findbuf, sizeof(FILEFINDBUF3),
6059 &ulSearchCount, FIL_STANDARD)) {
6060 do {
6061 priority_bumped();
6062 if (!foundit) {
6063 thisone = FALSE;
6064 p = strrchr(lasttoolbar, '\\');
6065 if (!p)
6066 p = lasttoolbar;
6067 else
6068 p++;
6069 if (!stricmp(findbuf.achName, p))
6070 thisone = TRUE;
6071 }
6072 p = strrchr(findbuf.achName, '.');
6073 if (p)
6074 *p = 0;
6075 sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
6076 MPFROM2SHORT(LIT_SORTASCENDING, 0),
6077 MPFROMP(findbuf.achName));
6078 if (!foundit && thisone && sSelect >= 0) {
6079 WinSendMsg(hwndButtonlist, LM_SELECTITEM,
6080 MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
6081 foundit = TRUE;
6082 }
6083 }
6084 while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
6085 &ulSearchCount));
6086 DosFindClose(hDir);
6087 priority_bumped();
6088 }
6089 WinSetWindowText(hwndButtonlist, (CHAR *) GetPString(IDS_TOOLBARTEXT));
6090 }
6091 return 0;
6092
6093 case UM_FILLUSERLIST:
6094 WinSendMsg(hwndUserlist, LM_DELETEALL, MPVOID, MPVOID);
6095 if (fUserComboBox) {
6096 ULONG ulDriveNum;
6097 ULONG ulDriveMap;
6098 ULONG ulSearchCount;
6099 FILEFINDBUF3 findbuf;
6100 HDIR hDir;
6101 APIRET rc;
6102 LINKDIRS *info;
6103 LINKDIRS *temp;
6104
6105 if (!loadedudirs)
6106 load_udirs();
6107 DosError(FERR_DISABLEHARDERR);
6108 DosQCurDisk(&ulDriveNum, &ulDriveMap);
6109 info = udirhead;
6110 while (info) {
6111 if (IsFullName(info->path) &&
6112 !(driveflags[toupper(*info->path) - 'A'] &
6113 (DRIVE_IGNORE | DRIVE_INVALID))) {
6114 DosError(FERR_DISABLEHARDERR);
6115 hDir = HDIR_CREATE;
6116 ulSearchCount = 1;
6117 if (!IsRoot(info->path))
6118 rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
6119 MUST_HAVE_DIRECTORY | FILE_READONLY |
6120 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
6121 &findbuf, sizeof(FILEFINDBUF3),
6122 &ulSearchCount, FIL_STANDARD);
6123 else {
6124 rc = 0;
6125 findbuf.attrFile = FILE_DIRECTORY;
6126 }
6127 priority_bumped();
6128 if (!rc) {
6129 if (!IsRoot(info->path))
6130 DosFindClose(hDir);
6131 if (findbuf.attrFile & FILE_DIRECTORY)
6132 WinSendMsg(hwndUserlist, LM_INSERTITEM,
6133 MPFROM2SHORT(LIT_SORTASCENDING, 0),
6134 MPFROMP(info->path));
6135 else {
6136 temp = info->next;
6137 remove_udir(info->path);
6138 info = temp;
6139 continue;
6140 }
6141 }
6142 else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
6143 temp = info->next;
6144 remove_udir(info->path);
6145 info = temp;
6146 continue;
6147 }
6148 }
6149 info = info->next;
6150 }
6151 info = ldirhead;
6152 while (info) {
6153 if (IsFullName(info->path) &&
6154 !(driveflags[toupper(*info->path) - 'A'] &
6155 (DRIVE_IGNORE | DRIVE_INVALID))) {
6156 DosError(FERR_DISABLEHARDERR);
6157 hDir = HDIR_CREATE;
6158 ulSearchCount = 1;
6159 if (!IsRoot(info->path))
6160 rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
6161 MUST_HAVE_DIRECTORY | FILE_READONLY |
6162 FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
6163 &findbuf, sizeof(FILEFINDBUF3),
6164 &ulSearchCount, FIL_STANDARD);
6165 else {
6166 rc = 0;
6167 findbuf.attrFile = FILE_DIRECTORY;
6168 }
6169 priority_bumped();
6170 if (!rc) {
6171 if (!IsRoot(info->path))
6172 DosFindClose(hDir);
6173 if (findbuf.attrFile & FILE_DIRECTORY)
6174 WinSendMsg(hwndUserlist, LM_INSERTITEM,
6175 MPFROM2SHORT(LIT_SORTASCENDING, 0),
6176 MPFROMP(info->path));
6177 else {
6178 temp = info->next;
6179 remove_udir(info->path);
6180 info = temp;
6181 continue;
6182 }
6183 }
6184 else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
6185 temp = info->next;
6186 remove_udir(info->path);
6187 info = temp;
6188 continue;
6189 }
6190 }
6191 info = info->next;
6192 }
6193 WinSendMsg(hwndUserlist, LM_INSERTITEM,
6194 MPFROM2SHORT(0, 0),
6195 MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
6196 WinSetWindowText(hwndUserlist, (CHAR *) GetPString(IDS_COMMONDIRTEXT));
6197 }
6198 return 0;
6199
6200 case UM_SIZE:
6201 if (fAutoTile)
6202 TileChildren(hwnd, FALSE);
6203 else
6204 MoveChildrenAwayFromTree(hwnd);
6205 return 0;
6206
6207 case WM_SIZE:
6208 ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1),
6209 SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
6210 break;
6211
6212 case WM_ERASEBACKGROUND:
6213 WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
6214 return 0;
6215
6216 case WM_PAINT:
6217 {
6218 HPS hps;
6219 RECTL rcl;
6220
6221 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
6222 if (hps) {
6223 WinQueryWindowRect(hwnd, &rcl);
6224 WinFillRect(hps, &rcl, CLR_PALEGRAY);
6225 WinEndPaint(hps);
6226 }
6227 }
6228 break;
6229
6230 case UM_CONTROL:
6231 switch (SHORT1FROMMP(mp1)) {
6232 case MAIN_CMDLIST:
6233 case MAIN_SETUPLIST:
6234 case MAIN_DRIVELIST:
6235 case MAIN_USERLIST:
6236 case MAIN_BUTTONLIST:
6237 switch (SHORT2FROMMP(mp1)) {
6238 case CBN_ENTER:
6239 {
6240 HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
6241 SHORT1FROMMP(mp1));
6242 CHAR path[CCHMAXPATH];
6243 ULONG ul;
6244
6245 switch (SHORT1FROMMP(mp1)) {
6246 case MAIN_USERLIST:
6247 ul = CCHMAXPATH;
6248 break;
6249 case MAIN_SETUPLIST:
6250 ul = STATE_NAME_MAX_BYTES;
6251 break;
6252 default:
6253 ul = 13; // fixme to not be hardcoded
6254 }
6255
6256 SetShiftState();
6257 WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
6258 bstrip(path);
6259 if (*path) {
6260 if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
6261 // 06 Oct 09 SHL Ctrl-select selects, but suppresses open
6262 if ((shiftstate & (KC_CTRL | KC_SHIFT | KC_ALT)) == KC_CTRL)
6263 break;
6264 if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
6265 if (!LastDir ||
6266 !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
6267 UM_CONTAINERDIR, MPFROMP(path), MPVOID))
6268 strcpy(path, pFM2SaveDirectory);
6269 if (!PMMkDir(hwnd, path, TRUE)) {
6270 WinSetWindowText(hwndUL, (CHAR *) GetPString(IDS_COMMONDIRTEXT));
6271 break;
6272 }
6273 }
6274 if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
6275
6276 HWND hwndDir;
6277
6278 if ((fUserListSwitches &&
6279 !(shiftstate & KC_SHIFT)) ||
6280 (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
6281 hwndDir = FindDirCnr(hwnd);
6282 if (hwndDir) {
6283 WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
6284 break;
6285 }
6286 }
6287 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
6288 }
6289 }
6290 else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
6291 ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
6292 FID_CLIENT),
6293 TREE_CNR), path, FALSE, TRUE);
6294 WinSetFocus(HWND_DESKTOP, hwndTree);
6295 }
6296 else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
6297 strcat(path, PCSZ_DOTTLS);
6298 load_tools(path);
6299 PrfWriteProfileString(fmprof,
6300 FM3Str, "LastToolbar", lasttoolbar);
6301 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
6302 WinSetWindowText(hwndButtonlist, (CHAR *) GetPString(IDS_TOOLBARTEXT));
6303 }
6304 else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
6305 CHAR szKey[80];
6306 ULONG numsaves = 0;
6307 ULONG size = sizeof(ULONG);
6308 // 06 Oct 09 SHL Ctrl-select selects, but suppresses open
6309 if ((shiftstate & (KC_CTRL | KC_SHIFT | KC_ALT)) == KC_CTRL)
6310 break;
6311 sprintf(szKey, "%s.NumDirsLastTime", path); // path is state name
6312 if (!PrfQueryProfileData(fmprof,
6313 FM3Str,
6314 szKey,
6315 (PVOID)&numsaves,
6316 &size))
6317 {
6318 if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
6319 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
6320 GetPString(IDS_WARNINGTEXT),
6321 GetPString(IDS_DOESNTEXISTTEXT), path);
6322 }
6323 else {
6324 Win_Error(hwnd, hwnd, __FILE__, __LINE__,
6325 PCSZ_INIQUERYPRFTEXT);
6326 }
6327 }
6328 else {
6329 char *pszStateName;
6330 if ((shiftstate & KC_SHIFT) == 0)
6331 PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
6332 pszStateName = xstrdup(path, pszSrcFile, __LINE__);
6333 if (!pszStateName) {
6334 // Fall back if out of memory - already complained
6335 if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
6336 // Autotile requested or forced
6337 PostMsg(MainObjectHwnd,
6338 UM_RESTORE,
6339 MPVOID,
6340 MPFROMLONG(1)); // Autotile
6341 }
6342 }
6343 else if (!PostMsg(MainObjectHwnd,
6344 UM_RESTORE,
6345 MPFROMP(pszStateName),
6346 MPVOID)) {
6347 free(pszStateName);
6348 }
6349 }
6350 }
6351 else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
6352
6353 SHORT sSelect = (SHORT) WinSendMsg(hwndCmdlist,
6354 LM_QUERYSELECTION,
6355 MPFROMSHORT(LIT_FIRST), MPVOID);
6356 if (sSelect >= 0) {
6357 CHAR s[CCHMAXPATH];
6358 CHAR *p;
6359
6360 WinSendMsg(hwndCmdlist, LM_QUERYITEMTEXT,
6361 MPFROM2SHORT(sSelect, CCHMAXPATH), MPFROMP(s));
6362 p = strrchr(s, '}');
6363 p = 0;
6364 p = strrchr(s, '{');
6365 p++;
6366 WinPostMsg(hwnd,
6367 WM_COMMAND,
6368 MPFROM2SHORT(atol(p), 0), //IDM_COMMANDSTART + sSelect, 0),
6369 MPVOID);
6370 }
6371 WinSetWindowText(hwndCmdlist, (CHAR *) GetPString(IDS_COMMANDSTEXT));
6372 }
6373 }
6374 } // CBN_ENTER
6375 break;
6376
6377 default:
6378 break;
6379 }
6380 break;
6381
6382 default:
6383 break;
6384 }
6385 return 0;
6386
6387 case WM_HELP:
6388 if (hwndHelp)
6389 PostMsg(hwndHelp, HM_DISPLAY_HELP, MPFROMSHORT(1), MPFROMSHORT(HM_RESOURCEID));
6390 break;
6391
6392 case UM_COMMAND:
6393 case WM_COMMAND:
6394
6395 return MainWMCommand(hwnd, msg, mp1, mp2);
6396
6397 case WM_CLOSE:
6398 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
6399 WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
6400 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
6401 fAmClosing = TRUE;
6402 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
6403 WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
6404 if (CloseChildren(hwnd)) {
6405 fAmClosing = FALSE;
6406 if (fAutoTile)
6407 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
6408 return 0;
6409 }
6410 if (hwndTree) {
6411 if (!PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID))
6412 WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
6413 }
6414 DosSleep(1);
6415 return 0; // Hold off WM_QUIT
6416
6417 case UM_CLOSE:
6418 HideNote();
6419 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
6420 return 0;
6421
6422 case UM_RESTORE:
6423 {
6424 // Try to restore saved shutdown state
6425 char *pszDefaultStateName = xstrdup(PCSZ_SHUTDOWNSTATE, pszSrcFile, __LINE__);
6426 if (pszDefaultStateName) {
6427 if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
6428 // 05 Feb 08 SHL fixme to complain?
6429 free(pszDefaultStateName);
6430 }
6431 }
6432 return 0;
6433
6434 case UM_SETDIR:
6435 /* mp1 == name of directory to open */
6436 if (mp1)
6437 return MRFROMLONG(OpenDirCnr((HWND) 0,
6438 hwndMain,
6439 hwndTree, (BOOL) mp2, (char *)mp1));
6440 return 0;
6441
6442 case WM_DESTROY:
6443# ifdef FORTIFY
6444 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 22 Jul 08 SHL fixme
6445# endif
6446 hwndMain = (HWND) 0;
6447 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
6448 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
6449# ifdef FORTIFY
6450 free_commands();
6451 free_associations();
6452 free_udirs();
6453 free_ldir();
6454 free_archivers();
6455 free_tools();
6456 free_setups();
6457 Fortify_LeaveScope();
6458# endif
6459 break;
6460 }
6461 return WinDefWindowProc(hwnd, msg, mp1, mp2);
6462}
6463
6464#pragma alloc_text(MISC8,SetToggleChecks,FindDirCnrByName,TopWindow)
6465#pragma alloc_text(MISC8,TopWindowName,CountDirCnrs)
6466#pragma alloc_text(MAINWND,AdjustSizeOfClient,FillClient,ChildButtonProc)
6467#pragma alloc_text(MAINWND,ToolBackProc,StatusProc)
6468#pragma alloc_text(MAINWND,MoveChildrenAwayFromTree,ArrangeIcons,NextChild)
6469#pragma alloc_text(MAINWND,ChildFrameButtonProc)
6470#pragma alloc_text(MAINWND2,CloseChildren,CountChildren,GetNextWindowPos)
6471#pragma alloc_text(MAINWND2,CascadeChildren,TileChildren,ResizeChildren)
6472#pragma alloc_text(MAINWND2,MinResChildren,MainFrameWndProc,MainWndProc)
6473#pragma alloc_text(MAINWND2,DropDownListProc)
6474#pragma alloc_text(MAINWND3,RestoreDirCnrState,SaveDirCnrState)
6475#pragma alloc_text(MAINWND3,CloseDirCnrChildren,TransformSwp)
6476#pragma alloc_text(MAINWND3,ResizeTools,BuildTools,CommandLineProc)
6477#pragma alloc_text(MAINWND4,DriveProc,DriveBackProc,BuildDriveBarButtons,ResizeDrives)
6478#pragma alloc_text(MAINWND4,LEDProc,IdealButtonProc)
6479#pragma alloc_text(MAINWND5,MainWMOnce)
6480#pragma alloc_text(MAINWND6,MainWMCommand)
6481#pragma alloc_text(BUBBLE,MakeBubble,BubbleProc,BubbleHelp)
6482#pragma alloc_text(MAINOBJ,MainObjectWndProc,MakeMainObjWin)
6483
Note: See TracBrowser for help on using the repository browser.