source: trunk/dll/mainwnd.c@ 1395

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

Allow user to turn off alert and/or error beeps in settings notebook. Ticket 341 Move repeated strings to PCSZs. Ticket 6 Add *DateFormat functions to format dates based on locale Ticket 28 Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error Ticket 6

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