source: trunk/dll/mainwnd.c@ 1067

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

Ticket 246: Allow saved directory container states to have no directory containers
(i.e. just a directory tree container).

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