source: trunk/dll/mainwnd.c@ 1093

Last change on this file since 1093 was 1077, checked in by Steven Levine, 17 years ago

Enhance Fortify infrastructure
Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT support
Add more fm/2 Fortify tooling and rework existing tooling for correct nesting
Still lots to do for cross-thread allocations
Add misc.h
Add walkem.h

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