source: trunk/dll/mainwnd.c@ 1405

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

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

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