source: trunk/dll/mainwnd.c@ 1313

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

Last part of remove or replace with a mutex semaphore DosEnterCriSec where appropriate. (Ticket 308) Note the partial commits for this ticket won't build without this.

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