source: trunk/dll/mainwnd.c@ 593

Last change on this file since 593 was 593, checked in by Gregg Young, 18 years ago

Changes to remove GetPString from window class names

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