source: trunk/dll/mainwnd.c@ 33

Last change on this file since 33 was 33, checked in by root, 23 years ago

Drop obsolete xor code

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