source: trunk/dll/mainwnd.c@ 130

Last change on this file since 130 was 130, checked in by root, 20 years ago

Use QWL_USER

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