source: trunk/dll/mainwnd.c@ 1394

Last change on this file since 1394 was 1394, checked in by Steven Levine, 17 years ago

Ticket 340: Convert GetPString to use STRINGTABLE.

Drop fm3dll.str and mkstr.exe from makefiles and wpi builders

Convert many functions to expect PCSZ arguments.
Correct walk, compare and dirsizes dialog setups to ignore saved dialog size
Drop copyright.c logic from makefile

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