source: trunk/dll/mainwnd.c@ 1446

Last change on this file since 1446 was 1444, checked in by Gregg Young, 16 years ago

Rework of drivebar to rescan all drives and refresh media buttons and menu items grey out inappropriate menu items. Streamline Tree scan code and use semaphores to serialize access. Add NOEASUPPORT and LOCALHD driveflag; .LONGNAME usage fixes; (Tickets 377-386)

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