source: trunk/dll/mainwnd.c@ 1138

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

Ticket 259: Fix save of "TargetDir=<None>"

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