source: trunk/dll/mainwnd.c@ 1331

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

Code cleanup replace sizeof calls for threaded drive scans

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