source: trunk/dll/mainwnd.c@ 554

Last change on this file since 554 was 552, checked in by Gregg Young, 19 years ago

font cleanup; new image and archiver masks; messages moved to string file; new drive flags including David's icons mostly working

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