source: trunk/dll/mainwnd.c@ 1375

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

Updated history; comments minor code cleanup for recent changes

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