source: trunk/dll/mainwnd.c@ 1455

Last change on this file since 1455 was 1455, checked in by Steven Levine, 16 years ago

Blink thread LEDs while worker threads are working
Drop expermental code

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