source: trunk/dll/mainwnd.c@ 1543

Last change on this file since 1543 was 1533, checked in by Gregg Young, 16 years ago

Fixed possible loss of precision compiler warnings by casting the variables in question.

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