source: trunk/dll/mainwnd.c@ 1223

Last change on this file since 1223 was 1209, checked in by John Small, 17 years ago

Ticket 187: Move data declarations/definitions out of fm3dll.h

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