source: trunk/dll/mainwnd.c@ 1370

Last change on this file since 1370 was 1369, checked in by Gregg Young, 17 years ago

Add check for p-rotectonly system to gray out dos/win commandline choices etc. Ticket 325 It also fixes problem with some drives not being scanned on startup.

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