source: trunk/dll/mainwnd.c@ 1062

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

Added a comment for the Ticket 242 changes.

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