source: trunk/dll/mainwnd.c@ 1155

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

Comments added for recent changes

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