source: trunk/dll/mainwnd.c@ 1790

Last change on this file since 1790 was 1778, checked in by Steven Levine, 11 years ago

Rework dircnrs.c DirObjWndProc UM_RESCAN to avoid hanging FM/2 Lite when
drive tree hidden. Also speeds up startup if Switch Tree on directory change
not enabled.

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