source: trunk/dll/mainwnd.c@ 2

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

Initial revision

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