source: trunk/dll/mainwnd.c@ 1391

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

Move nontranslated strings to init.c and codepage.c; use those strings in place of GetPString calls. Move other strings to a StringTable; minor cleanup and code changes to codepage.c to use a string array instead of GetPString calls. Ticket 340

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