source: trunk/dll/mainwnd.c@ 1354

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

Added driveflags to over ride write verify for USB removable drives that fail when it is on (Ticket 323); A flag to prevent directory name from being broadcast to drives in the tree cnr prior to a recursive scan of the drive (causes dbl directory names Ticket 321) Add option for multithreaded recursive scan of user selected drives at startup (Ticket 322).

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