source: trunk/dll/mainwnd.c@ 1387

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

Updated history; comments minor code cleanup for recent changes

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