source: trunk/dll/mainwnd.c@ 1657

Last change on this file since 1657 was 1635, checked in by Steven Levine, 14 years ago

Add needTile to ensure containers opened on command line render correctly
Minor code cleanup

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