source: trunk/dll/mainwnd.c@ 1371

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

Add check for p-rotectonly system to gray out dos/win commandline choices etc. Ticket 325 It also fixes problem with some drives not being scanned on startup.

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