source: trunk/dll/dircnrs.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: 132.3 KB
Line 
1#define INCL_DOS
2#define INCL_WIN
3#define INCL_GPI
4#define INCL_DOSERRORS
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 <limits.h>
13#include "fm3dll.h"
14#include "fm3dlg.h"
15#include "fm3str.h"
16#include "mle.h"
17
18#pragma data_seg(DATA1)
19#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
20#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
21#pragma alloc_text(STARTUP,StartDirCnr)
22
23
24MRESULT EXPENTRY DirFrameWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
25
26 return CommonFrameWndProc(DIR_CNR,hwnd,msg,mp1,mp2);
27}
28
29
30MRESULT EXPENTRY DirTextProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
31
32 static BOOL emphasized = FALSE;
33 static HWND hwndButtonPopup = (HWND)0;
34 static USHORT lastid = 0;
35 static ULONG timestamp = ULONG_MAX;
36
37 switch(msg) {
38 case WM_CREATE:
39 return CommonTextProc(hwnd,msg,mp1,mp2);
40
41 case WM_COMMAND:
42 {
43 DIRCNRDATA *dcd;
44 MRESULT mr;
45
46 mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
47 QW_PARENT),
48 DIR_CNR),
49 msg,
50 mp1,
51 mp2);
52 if(hwndButtonPopup &&
53 SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
54 SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
55 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
56 QW_PARENT),
57 DIR_CNR),
58 0);
59 if(dcd)
60 SetDetailsSwitches(hwndButtonPopup,
61 dcd);
62 }
63 return mr;
64 }
65
66 case UM_CONTEXTMENU:
67 case WM_CONTEXTMENU:
68 {
69 USHORT id;
70
71 id = WinQueryWindowUShort(hwnd,QWS_ID);
72 switch(id) {
73 case DIR_FOLDERICON:
74 if(fNoFoldMenu) {
75 PostMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
76 DIR_CNR),
77 WM_COMMAND,
78 MPFROM2SHORT(IDM_PREVIOUS,0),
79 mp2);
80 break;
81 }
82 /* else intentional fallthru */
83 case DIR_SELECTED:
84 case DIR_VIEW:
85 case DIR_SORT:
86 {
87 POINTL ptl = {0,0};
88 SWP swp;
89 DIRCNRDATA *dcd;
90
91 if(hwndButtonPopup)
92 WinDestroyWindow(hwndButtonPopup);
93 if(id == DIR_SELECTED && msg == WM_CONTEXTMENU)
94 id = DIR_MAX;
95 if(id == lastid) {
96
97 ULONG check;
98
99 DosQuerySysInfo(QSV_MS_COUNT,
100 QSV_MS_COUNT,
101 &check,
102 sizeof(check));
103 if(check < timestamp + 500) {
104 lastid = 0;
105 goto MenuAbort;
106 }
107 }
108 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP,
109 FM3ModHandle,
110 id);
111 if(hwndButtonPopup) {
112 WinSetWindowUShort(hwndButtonPopup,
113 QWS_ID,
114 id);
115 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
116 QW_PARENT),
117 DIR_CNR),
118 0);
119 if(id == DIR_SORT) { /* don't have sort pathname in dirs */
120 WinSendMsg(hwndButtonPopup,
121 MM_DELETEITEM,
122 MPFROM2SHORT(IDM_SORTNAME,
123 FALSE),
124 MPVOID);
125 WinSendMsg(hwndButtonPopup,
126 MM_DELETEITEM,
127 MPFROM2SHORT(IDM_SORTNONE,
128 FALSE),
129 MPVOID);
130 if(dcd)
131 SetSortChecks(hwndButtonPopup,
132 dcd->sortFlags);
133 }
134 else if(id == DIR_VIEW) {
135 if(dcd) {
136 SetViewMenu(hwndButtonPopup,
137 dcd->flWindowAttr);
138 SetDetailsSwitches(hwndButtonPopup,
139 dcd);
140 }
141 }
142 else if(id == DIR_MAX) {
143
144 int x;
145 BOOL enable;
146 USHORT ids[] = {IDM_SELECTBOTH,
147 IDM_SELECTMORE,
148 IDM_SELECTONE,
149 IDM_SELECTNEWER,
150 IDM_SELECTOLDER,
151 IDM_SELECTBIGGER,
152 IDM_SELECTSMALLER,
153 IDM_DESELECTBOTH,
154 IDM_DESELECTMORE,
155 IDM_DESELECTONE,
156 IDM_DESELECTNEWER,
157 IDM_DESELECTOLDER,
158 IDM_DESELECTBIGGER,
159 IDM_DESELECTSMALLER,
160 0};
161
162 enable = (CountDirCnrs(dcd->hwndParent) > 1);
163 for(x = 0;ids[x];x++)
164 WinEnableMenuItem(hwndButtonPopup,
165 ids[x],
166 enable);
167 }
168 else if(id == DIR_SELECTED) {
169 if(dcd)
170 WinEnableMenuItem(hwndButtonPopup,
171 IDM_RESELECT,
172 (dcd->lastselection != NULL));
173 }
174 ptl.x = 0;
175 if(WinPopupMenu(HWND_OBJECT,
176 HWND_OBJECT,
177 hwndButtonPopup,
178 -32767,
179 -32767,
180 0,
181 0)) {
182 WinQueryWindowPos(hwndButtonPopup,
183 &swp);
184 ptl.y = -(swp.cy + 2);
185 }
186 else {
187 WinQueryWindowPos(hwnd,
188 &swp);
189 ptl.y = swp.cy + 2;
190 }
191 if(WinPopupMenu(hwnd,
192 hwnd,
193 hwndButtonPopup,
194 ptl.x,
195 ptl.y,
196 0,
197 PU_HCONSTRAIN | PU_VCONSTRAIN |
198 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
199 CenterOverWindow(hwndButtonPopup);
200 PaintRecessedWindow(hwnd,
201 (HPS)0,
202 FALSE,
203 FALSE);
204 }
205 }
206 }
207 break;
208 default:
209 PostMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
210 DIR_CNR),
211 WM_CONTROL,
212 MPFROM2SHORT(DIR_CNR,
213 CN_CONTEXTMENU),
214 MPVOID);
215 break;
216 }
217 }
218MenuAbort:
219 if(msg == UM_CONTEXTMENU)
220 return 0;
221 break;
222
223 case WM_MENUEND:
224 if(hwndButtonPopup == (HWND)mp2) {
225 lastid = WinQueryWindowUShort((HWND)mp2,QWS_ID);
226 WinDestroyWindow(hwndButtonPopup);
227 hwndButtonPopup = (HWND)0;
228 DosQuerySysInfo(QSV_MS_COUNT,
229 QSV_MS_COUNT,
230 &timestamp,
231 sizeof(timestamp));
232 switch(lastid) {
233 case DIR_VIEW:
234 case DIR_SORT:
235 case DIR_FOLDERICON:
236 case DIR_SELECTED:
237 case DIR_MAX:
238 PaintRecessedWindow(hwnd,(HPS)0,TRUE,FALSE);
239 break;
240 }
241 }
242 break;
243
244 case WM_BUTTON3DOWN:
245 case WM_BUTTON1DOWN:
246 case WM_BUTTON3UP:
247 case WM_BUTTON1UP:
248 {
249 USHORT id;
250
251 id = WinQueryWindowUShort(hwnd,QWS_ID);
252 switch(id) {
253 case DIR_FILTER:
254 case DIR_VIEW:
255 case DIR_SORT:
256 case DIR_SELECTED:
257 case DIR_FOLDERICON:
258 case DIR_MAX:
259 return CommonTextButton(hwnd,msg,mp1,mp2);
260 }
261 }
262 break;
263
264 case WM_BUTTON1DBLCLK:
265 {
266 NOTIFYRECORDENTER nr;
267
268 memset(&nr,0,sizeof(NOTIFYRECORDENTER));
269 nr.hwndCnr = WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
270 DIR_CNR);
271 WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),
272 WM_CONTROL,
273 MPFROM2SHORT(DIR_CNR,
274 CN_ENTER),
275 MPFROMP(&nr));
276 }
277 break;
278
279 case WM_MOUSEMOVE:
280 {
281 USHORT id = WinQueryWindowUShort(hwnd,QWS_ID);
282 char *s = NULL;
283
284 if(fOtherHelp) {
285 if((!hwndBubble ||
286 WinQueryWindowULong(hwndBubble,0) != hwnd) &&
287 !WinQueryCapture(HWND_DESKTOP)) {
288 switch(id) {
289 case DIR_TOTALS:
290 s = GetPString(IDS_DIRCNRTOTALHELP);
291 break;
292 case DIR_SELECTED:
293 s = GetPString(IDS_DIRCNRSELECTEDHELP);
294 break;
295 case DIR_VIEW:
296 s = GetPString(IDS_DIRCNRVIEWHELP);
297 break;
298 case DIR_SORT:
299 s = GetPString(IDS_DIRCNRSORTHELP);
300 break;
301 case DIR_FILTER:
302 s = GetPString(IDS_DIRCNRFILTERHELP);
303 break;
304 case DIR_MAX:
305 s = GetPString(IDS_DIRCNRMAXHELP);
306 break;
307 case DIR_FOLDERICON:
308 s = GetPString(IDS_DIRCNRFOLDERHELP);
309 break;
310 default:
311 break;
312 }
313 if(s)
314 MakeBubble(hwnd,TRUE,s);
315 else if(hwndBubble)
316 WinDestroyWindow(hwndBubble);
317 }
318 }
319 switch(id) {
320 case DIR_MAX:
321 case DIR_FOLDERICON:
322 case DIR_FILTER:
323 case DIR_SORT:
324 case DIR_VIEW:
325 case DIR_SELECTED:
326 return CommonTextButton(hwnd,msg,mp1,mp2);
327 }
328 }
329 break;
330
331 case WM_CHORD:
332 case WM_BUTTON3CLICK:
333 case WM_BUTTON1CLICK:
334 case UM_CLICKED:
335 case UM_CLICKED3:
336 {
337 USHORT id,cmd = 0;
338
339 id = WinQueryWindowUShort(hwnd,QWS_ID);
340 if(msg == UM_CLICKED || msg == UM_CLICKED3) {
341 switch(id) {
342 case DIR_MAX:
343 cmd = IDM_MAXIMIZE;
344 break;
345 case DIR_VIEW:
346 case DIR_SELECTED:
347 case DIR_SORT:
348 PostMsg(hwnd,
349 UM_CONTEXTMENU,
350 MPVOID,
351 MPVOID);
352 break;
353 case DIR_FILTER:
354 cmd = IDM_FILTER;
355 break;
356 default:
357 break;
358 }
359 }
360 else if(id == DIR_FOLDERICON) {
361 if((msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_CTRL)))
362 cmd = IDM_PREVIOUS;
363 else if(msg == WM_BUTTON3CLICK || msg == WM_CHORD)
364 cmd = IDM_RESCAN;
365 else if(msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_SHIFT))
366 cmd = IDM_WALKDIR;
367 else if(msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_ALT))
368 cmd = IDM_WINDOWDLG;
369 else
370 cmd = IDM_PARENT;
371 }
372 if(cmd)
373 PostMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
374 DIR_CNR),
375 WM_COMMAND,
376 MPFROM2SHORT(cmd,0),
377 MPVOID);
378 }
379 if(msg == UM_CLICKED || msg == UM_CLICKED3)
380 return 0;
381 break;
382
383 case DM_DROP:
384 case DM_DRAGOVER:
385 case DM_DRAGLEAVE:
386 case DM_DROPHELP:
387 case WM_BEGINDRAG:
388 if(msg == DM_DRAGOVER) {
389 if(!emphasized) {
390 emphasized = TRUE;
391 DrawTargetEmphasis(hwnd,emphasized);
392 }
393 }
394 else if(msg != WM_BEGINDRAG){
395 if(emphasized) {
396 emphasized = FALSE;
397 DrawTargetEmphasis(hwnd,emphasized);
398 }
399 }
400 switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
401 case DIR_FOLDERICON:
402 switch(msg) {
403 case DM_DRAGOVER:
404 if(AcceptOneDrop(mp1,mp2))
405 return MRFROM2SHORT(DOR_DROP,
406 DO_MOVE);
407 return(MRFROM2SHORT(DOR_NODROP,0)); /* Drop not valid */
408 case DM_DROPHELP:
409 DropHelp(mp1,mp2,hwnd,
410 GetPString(IDS_DIRCNRFOLDERDROPHELP));
411 return 0;
412 case DM_DROP:
413 {
414 char szFrom[CCHMAXPATH + 2];
415
416 if(emphasized) {
417 emphasized = FALSE;
418 DrawTargetEmphasis(hwnd,emphasized);
419 }
420 if(GetOneDrop(mp1,mp2,szFrom,sizeof(szFrom)))
421 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
422 DIR_CNR),
423 WM_COMMAND,MPFROM2SHORT(IDM_SWITCH,0),
424 MPFROMP(szFrom));
425 }
426 return 0;
427 default:
428 return PFNWPStatic(hwnd,msg,mp1,mp2);
429 }
430 case DIR_MAX:
431 if(msg == WM_BEGINDRAG)
432 return PFNWPStatic(hwnd,msg,mp1,mp2);
433 default:
434 {
435 CNRDRAGINFO cnd;
436 USHORT dcmd;
437
438 switch(msg) {
439 case DM_DROP:
440 dcmd = CN_DROP;
441 break;
442 case DM_DRAGOVER:
443 dcmd = CN_DRAGOVER;
444 break;
445 case DM_DRAGLEAVE:
446 dcmd = CN_DRAGLEAVE;
447 break;
448 case DM_DROPHELP:
449 dcmd = CN_DROPHELP;
450 break;
451 case WM_BEGINDRAG:
452 dcmd = CN_INITDRAG;
453 break;
454 }
455 memset(&cnd,0,sizeof(cnd));
456 cnd.pDragInfo = (PDRAGINFO)mp1;
457 cnd.pRecord = NULL;
458 return WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),
459 WM_CONTROL,
460 MPFROM2SHORT(DIR_CNR,dcmd),
461 MPFROMP(&cnd));
462 }
463 }
464 }
465 return PFNWPStatic(hwnd,msg,mp1,mp2);
466}
467
468
469MRESULT EXPENTRY DirClientWndProc (HWND hwnd,ULONG msg,MPARAM mp1,
470 MPARAM mp2) {
471
472 switch(msg) {
473 case UM_CONTAINERDIR:
474 if(mp1) {
475
476 DIRCNRDATA *dcd;
477
478 *(CHAR *)mp1 = 0;
479 dcd = WinQueryWindowPtr(WinWindowFromID(hwnd,DIR_CNR),0);
480 if(dcd)
481 strcpy((CHAR *)mp1,dcd->directory);
482 return MRFROMLONG(TRUE);
483 }
484 return 0;
485
486 case UM_CONTAINERHWND:
487 return MRFROMLONG(WinWindowFromID(hwnd,DIR_CNR));
488
489 case UM_VIEWSMENU:
490 return MRFROMLONG(CheckMenu(&DirCnrMenu,DIRCNR_POPUP));
491
492 case UM_DRIVECMD:
493 case WM_INITMENU:
494 case UM_FILTER:
495 case UM_INITMENU:
496 case MM_PORTHOLEINIT:
497 case UM_COMMAND:
498 case UM_FILESMENU:
499 case UM_UPDATERECORD:
500 case UM_UPDATERECORDLIST:
501 return WinSendMsg(WinWindowFromID(hwnd,DIR_CNR),msg,mp1,mp2);
502
503
504 case WM_PSETFOCUS:
505 case WM_SETFOCUS:
506 if(mp2)
507 PostMsg(hwnd,UM_FOCUSME,MPVOID,MPVOID);
508 break;
509
510 case UM_FOCUSME:
511 WinSetFocus(HWND_DESKTOP,WinWindowFromID(hwnd,DIR_CNR));
512 break;
513
514 case WM_PAINT:
515 {
516 HPS hps;
517 RECTL rcl;
518
519 hps = WinBeginPaint(hwnd,(HPS)0,NULL);
520 if(hps) {
521 WinQueryWindowRect(hwnd,&rcl);
522 WinFillRect(hps,&rcl,CLR_PALEGRAY);
523 CommonTextPaint(hwnd,hps);
524 WinEndPaint(hps);
525 }
526 }
527 break;
528
529 case UM_SIZE:
530 case WM_SIZE:
531 if(msg == UM_SIZE) {
532
533 SWP swp;
534
535 WinQueryWindowPos(hwnd,&swp);
536 mp1 = MPFROM2SHORT(swp.cx,swp.cy);
537 mp2 = MPFROM2SHORT(swp.cx,swp.cy);
538 }
539 {
540 USHORT cx,cy,bx;
541
542 cx = SHORT1FROMMP(mp2);
543 cy = SHORT2FROMMP(mp2);
544 WinSetWindowPos(WinWindowFromID(hwnd,DIR_CNR),HWND_TOP,
545 0,
546 0,
547 cx,
548 cy - 24,
549 SWP_SHOW | SWP_MOVE | SWP_SIZE);
550 if(WinWindowFromID(hwnd,DIR_MAX) != (HWND)0) {
551 WinSetWindowPos(WinWindowFromID(hwnd,DIR_MAX),HWND_TOP,
552 cx - 22,
553 cy - 22,
554 20,20,SWP_SHOW | SWP_MOVE | SWP_SIZE);
555 cx -= 24;
556 }
557 WinSetWindowPos(WinWindowFromID(hwnd,DIR_FOLDERICON),HWND_TOP,
558 2,
559 cy - 22,
560 24,
561 20,
562 SWP_SHOW | SWP_MOVE | SWP_SIZE);
563 WinSetWindowPos(WinWindowFromID(hwnd,DIR_TOTALS),HWND_TOP,
564 29,
565 cy - 22,
566 (cx / 3) - 2,
567 20,
568 SWP_SHOW | SWP_MOVE | SWP_SIZE);
569 WinSetWindowPos(WinWindowFromID(hwnd,DIR_SELECTED),HWND_TOP,
570 29 + (cx / 3) + 2,
571 cy - 22,
572 (cx / 3) - 2,
573 20,
574 SWP_SHOW | SWP_MOVE | SWP_SIZE);
575 bx = (cx - (29 + (((cx / 3) + 2) * 2))) / 3;
576 WinSetWindowPos(WinWindowFromID(hwnd,DIR_VIEW),HWND_TOP,
577 29 + (((cx / 3) + 2) * 2),
578 cy - 22,
579 bx - 4,
580 20,
581 SWP_SHOW | SWP_MOVE | SWP_SIZE);
582 WinSetWindowPos(WinWindowFromID(hwnd,DIR_SORT),HWND_TOP,
583 29 + (((cx / 3) + 2) * 2) + bx,
584 cy - 22,
585 bx - 4,
586 20,
587 SWP_SHOW | SWP_MOVE | SWP_SIZE);
588 WinSetWindowPos(WinWindowFromID(hwnd,DIR_FILTER),HWND_TOP,
589 29 + (((cx / 3) + 2) * 2) + (bx * 2),
590 cy - 22,
591 bx - 4,
592 20,
593 SWP_SHOW | SWP_MOVE | SWP_SIZE);
594 }
595 CommonTextPaint(hwnd,(HPS)0);
596 if(msg == UM_SIZE) {
597 WinSetWindowPos(WinQueryWindow(hwnd,QW_PARENT),HWND_TOP,0,0,0,0,
598 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
599 return 0;
600 }
601 break;
602
603 case WM_COMMAND:
604 case WM_CONTROL:
605 case WM_CLOSE:
606 return WinSendMsg(WinWindowFromID(hwnd,DIR_CNR),
607 msg,
608 mp1,
609 mp2);
610 }
611 return WinDefWindowProc(hwnd,msg,mp1,mp2);
612}
613
614
615MRESULT EXPENTRY DirObjWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
616
617 DIRCNRDATA *dcd;
618
619 switch(msg) {
620 case WM_CREATE:
621 break;
622
623 case DM_PRINTOBJECT:
624 return MRFROMLONG(DRR_TARGET);
625
626 case DM_DISCARDOBJECT:
627 dcd = INSTDATA(hwnd);
628 if(fFM2Deletes && dcd) {
629
630 LISTINFO *li;
631 CNRDRAGINFO cni;
632
633 cni.pRecord = NULL;
634 cni.pDragInfo = (PDRAGINFO)mp1;
635 li = DoFileDrop(dcd->hwndCnr,dcd->directory,FALSE,MPVOID,MPFROMP(&cni));
636 if(li) {
637 li->type = (fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE;
638 if(!PostMsg(hwnd,UM_MASSACTION,MPFROMP(li),MPVOID))
639 FreeListInfo(li);
640 else
641 return MRFROMLONG(DRR_SOURCE);
642 }
643 }
644 return MRFROMLONG(DRR_TARGET);
645
646 case UM_UPDATERECORDLIST:
647 dcd = WinQueryWindowPtr(hwnd,0);
648 if(dcd && mp1) {
649
650 INT numentries = 0;
651 CHAR **list = (CHAR **)mp1;
652
653 while(list[numentries])
654 numentries++;
655 if(numentries)
656 UpdateCnrList(dcd->hwndCnr,
657 list,
658 numentries,
659 TRUE,
660 dcd);
661 }
662 return 0;
663
664 case UM_SETUP:
665 dcd = WinQueryWindowPtr(hwnd,0);
666 if(dcd) {
667 /* set unique id */
668 WinSetWindowUShort(hwnd,
669 QWS_ID,
670 DIROBJ_FRAME + (DIR_FRAME - dcd->id));
671 dcd->hwndObject = hwnd;
672 if(ParentIsDesktop(hwnd,dcd->hwndParent))
673 DosSleep(250L);
674 }
675 else
676 PostMsg(hwnd,WM_CLOSE,MPVOID,MPVOID);
677 return 0;
678
679 case UM_RESCAN2:
680 dcd = WinQueryWindowPtr(hwnd,0);
681 if(dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
682
683 FSALLOCATE fsa;
684 CHAR s[CCHMAXPATH * 2],tf[81],tb[81],fbytes[81];
685
686 DosError(FERR_DISABLEHARDERR);
687 if(!DosQueryFSInfo(toupper(*dcd->directory) - '@',
688 FSIL_ALLOC,&fsa,sizeof(FSALLOCATE))) {
689 strcpy(fbytes," {");
690 commafmt(fbytes + 3,sizeof(fbytes) - 5,
691 (fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector)) /
692 1024L);
693 strcat(fbytes,GetPString(IDS_KFREETEXT));
694 strcat(fbytes,"}");
695 }
696 else
697 *fbytes = 0;
698 commafmt(tf,sizeof(tf),dcd->totalfiles);
699 commafmt(tb,sizeof(tb),dcd->totalbytes);
700 if(!fMoreButtons)
701 sprintf(s," [%s / %sb]%s%s%s%s %s",tf,tb,
702 fbytes,
703 (*dcd->mask.szMask || dcd->mask.antiattr ||
704 dcd->mask.attrFile != ALLATTRS) ? " (" : NullStr,
705 (*dcd->mask.szMask) ? dcd->mask.szMask :
706 (dcd->mask.antiattr ||
707 dcd->mask.attrFile != ALLATTRS) ?
708 GetPString(IDS_ALLTEXT) : NullStr,
709 (*dcd->mask.szMask || dcd->mask.antiattr ||
710 dcd->mask.attrFile != ALLATTRS) ? ")" : NullStr,
711 dcd->directory);
712 else
713 sprintf(s," [%s / %sb]%s %s",tf,tb,fbytes,
714 dcd->directory);
715 if(dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
716 WinSetWindowText(hwndStatus,s);
717 }
718 return 0;
719
720 case UM_FLESH:
721 dcd = WinQueryWindowPtr(hwnd,0);
722 if(dcd) {
723
724 PCNRITEM pci,pciC;
725
726 pci = WinSendMsg(dcd->hwndCnr,
727 CM_QUERYRECORD,
728 MPVOID,
729 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
730 while(pci && (INT)pci != -1) {
731 if(pci->attrFile & FILE_DIRECTORY) {
732 pciC = WinSendMsg(dcd->hwndCnr,
733 CM_QUERYRECORD,
734 MPFROMP(pci),
735 MPFROM2SHORT(CMA_FIRSTCHILD,CMA_ITEMORDER));
736 if(!pciC) {
737 Stubby(dcd->hwndCnr,pci);
738 DosSleep(0L);
739 }
740 }
741 pci = WinSendMsg(dcd->hwndCnr,
742 CM_QUERYRECORD,
743 MPFROMP(pci),
744 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
745 }
746 dcd->firsttree = TRUE;
747 }
748 return 0;
749
750 case UM_RESCAN:
751 /*
752 * populate container
753 */
754 dcd = WinQueryWindowPtr(hwnd,0);
755 if(dcd) {
756 DosEnterCritSec();
757 if(dcd->stopflag)
758 dcd->stopflag--;
759 if(dcd->stopflag) {
760 DosExitCritSec();
761 return 0;
762 }
763 DosExitCritSec();
764 if(mp1) {
765 strcpy(dcd->previous,dcd->directory);
766 strcpy(dcd->directory,(CHAR *)mp1);
767 }
768 MakeValidDir(dcd->directory);
769 {
770 CHAR s[CCHMAXPATH + 8];
771
772 sprintf(s,
773 "%s%s%s",
774 (ParentIsDesktop(dcd->hwndFrame,(HWND)0)) ?
775 "VDir" :
776 NullStr,
777 (ParentIsDesktop(dcd->hwndFrame,(HWND)0)) ?
778 (!dcd->dontclose) ?
779 " Master: " :
780 ": " :
781 NullStr,
782 dcd->directory);
783 WinSetWindowText(dcd->hwndFrame,
784 s);
785 WinSetWindowText(WinWindowFromID(dcd->hwndFrame,FID_TITLEBAR),
786 s);
787 }
788 WinSendMsg(dcd->hwndCnr,
789 CM_REMOVERECORD,
790 MPVOID,
791 MPFROM2SHORT(0,CMA_FREE | CMA_INVALIDATE | CMA_ERASE));
792 AdjustCnrColsForFSType(dcd->hwndCnr,
793 dcd->directory,
794 dcd);
795 dcd->totalbytes = dcd->totalfiles =
796 dcd->selectedfiles = dcd->selectedbytes = 0;
797 WinSetDlgItemText(dcd->hwndClient,
798 DIR_TOTALS,
799 "0 / 0k");
800 WinSetDlgItemText(dcd->hwndClient,
801 DIR_SELECTED,
802 "0 / 0k");
803 if(hwndStatus &&
804 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
805 WinSetWindowText(hwndStatus,
806 GetPString(IDS_SCANNINGTEXT));
807 if(hwndMain)
808 WinSendMsg(hwndMain,
809 UM_LOADFILE,
810 MPVOID,
811 MPVOID);
812 }
813 if(fSwitchTree && hwndTree) {
814 if(hwndMain) {
815 if(TopWindow(hwndMain,
816 (HWND)0) == dcd->hwndFrame)
817 WinSendMsg(hwndTree,
818 UM_SHOWME,
819 MPFROMP(dcd->directory),
820 MPVOID);
821 }
822 else
823 WinSendMsg(hwndTree,
824 UM_SHOWME,
825 MPFROMP(dcd->directory),
826 MPVOID);
827 }
828 dcd->firsttree = FALSE;
829 dcd->totalbytes = FillDirCnr(dcd->hwndCnr,
830 dcd->directory,
831 dcd);
832 PostMsg(dcd->hwndCnr,
833 UM_RESCAN,
834 MPVOID,
835 MPVOID);
836 if(mp2 &&
837 !fLeaveTree &&
838 (dcd->flWindowAttr & CV_TREE)) {
839
840 ULONG flWindowAttr = dcd->flWindowAttr;
841 CNRINFO cnri;
842
843 flWindowAttr &= (~(CV_NAME | CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
844 if(dcd->lastattr) {
845 if(dcd->lastattr & CV_TEXT)
846 flWindowAttr |= CV_TEXT;
847 else if(dcd->lastattr & CV_DETAIL)
848 flWindowAttr |= CV_DETAIL;
849 else if(dcd->lastattr & CV_ICON)
850 flWindowAttr |= CV_ICON;
851 else
852 flWindowAttr |= CV_NAME;
853 }
854 else
855 flWindowAttr |= CV_NAME;
856 flWindowAttr |= CV_FLOW;
857 memset(&cnri,0,sizeof(CNRINFO));
858 cnri.cb = sizeof(CNRINFO);
859 if(WinSendMsg(dcd->hwndCnr,CM_QUERYCNRINFO,MPFROMP(&cnri),
860 MPFROMLONG(sizeof(CNRINFO)))) {
861 dcd->flWindowAttr = cnri.flWindowAttr = flWindowAttr;
862 WinSendMsg(dcd->hwndCnr,CM_SETCNRINFO,
863 MPFROMP(&cnri),
864 MPFROMLONG(CMA_FLWINDOWATTR));
865 SayView(WinWindowFromID(dcd->hwndClient,
866 DIR_VIEW),dcd->flWindowAttr);
867 }
868 }
869 if(dcd->flWindowAttr & CV_TREE)
870 PostMsg(dcd->hwndObject,UM_FLESH,MPVOID,MPVOID);
871 if(*dcd->previous) {
872 if(strlen(dcd->previous) > strlen(dcd->directory) &&
873 !strnicmp(dcd->directory,dcd->previous,strlen(dcd->directory))) {
874
875 PCNRITEM pci;
876
877 pci = FindCnrRecord(dcd->hwndCnr,
878 dcd->previous,
879 NULL,
880 TRUE,
881 FALSE,
882 TRUE);
883 if(pci && (INT)pci != -1) {
884 /* make found item current (cursored) item */
885 WinSendMsg(dcd->hwndCnr,CM_SETRECORDEMPHASIS,MPFROMP(pci),
886 MPFROM2SHORT(TRUE,CRA_CURSORED));
887 /* make sure that record shows in viewport */
888 ShowCnrRecord(dcd->hwndCnr,(PMINIRECORDCORE)pci);
889 }
890 }
891 }
892 }
893 return 0;
894
895 case UM_COMMAND:
896 if(mp1) {
897
898 LISTINFO *li = (LISTINFO *)mp1;
899
900 switch(li->type) {
901 case IDM_DOITYOURSELF:
902 case IDM_APPENDTOCLIP:
903 case IDM_SAVETOCLIP:
904 case IDM_ARCHIVE:
905 case IDM_ARCHIVEM:
906 case IDM_VIEWTEXT:
907 case IDM_VIEWBINARY:
908 case IDM_VIEWARCHIVE:
909 case IDM_VIEW:
910 case IDM_EDITTEXT:
911 case IDM_EDITBINARY:
912 case IDM_EDIT:
913 case IDM_OBJECT:
914 case IDM_SHADOW:
915 case IDM_SHADOW2:
916 case IDM_PRINT:
917 case IDM_ATTRS:
918 case IDM_DELETE:
919 case IDM_PERMDELETE:
920 case IDM_MCIPLAY:
921 case IDM_UPDATE:
922 if(PostMsg(hwnd,
923 UM_MASSACTION,
924 mp1,
925 mp2))
926 return (MRESULT)TRUE;
927 break;
928 default:
929 if(PostMsg(hwnd,
930 UM_ACTION,
931 mp1,
932 mp2))
933 return (MRESULT)TRUE;
934 }
935 }
936 return 0;
937
938 case UM_SELECT:
939 dcd = WinQueryWindowPtr(hwnd,0);
940 if(dcd) {
941 switch(SHORT1FROMMP(mp1)) {
942 case IDM_SELECTBOTH:
943 case IDM_SELECTONE:
944 case IDM_SELECTMORE:
945 case IDM_SELECTNEWER:
946 case IDM_SELECTOLDER:
947 case IDM_SELECTBIGGER:
948 case IDM_SELECTSMALLER:
949 case IDM_DESELECTBOTH:
950 case IDM_DESELECTONE:
951 case IDM_DESELECTMORE:
952 case IDM_DESELECTNEWER:
953 case IDM_DESELECTOLDER:
954 case IDM_DESELECTBIGGER:
955 case IDM_DESELECTSMALLER:
956 SpecialSelect2(dcd->hwndParent,SHORT1FROMMP(mp1));
957 break;
958 case IDM_SELECTLIST:
959 {
960 CHAR filename[CCHMAXPATH],*p,*pp;
961 ULONG size;
962
963 strcpy(filename,"*.LST");
964 size = CCHMAXPATH;
965 PrfQueryProfileData(fmprof,appname,"SaveToListName",
966 filename,&size);
967 pp = strrchr(filename,'\\');
968 if(!pp)
969 pp = filename;
970 p = strrchr(pp,'.');
971 if(p && *(p + 1) && p > pp + 1) {
972 if(pp > filename)
973 pp++;
974 *pp = '*';
975 pp++;
976 if(p > pp)
977 memmove(pp,p,strlen(p) + 1);
978 }
979 if(insert_filename(hwnd,filename,FALSE,FALSE))
980 SelectList(dcd->hwndCnr,TRUE,FALSE,FALSE,NULL,filename,NULL);
981 }
982 break;
983 case IDM_SELECTALL:
984 SelectAll(dcd->hwndCnr,TRUE,TRUE,NULL,NULL,FALSE);
985 break;
986 case IDM_DESELECTALL:
987 DeselectAll(dcd->hwndCnr,TRUE,TRUE,NULL,NULL,FALSE);
988 break;
989 case IDM_SELECTALLFILES:
990 SelectAll(dcd->hwndCnr,TRUE,FALSE,NULL,NULL,FALSE);
991 break;
992 case IDM_DESELECTALLFILES:
993 DeselectAll(dcd->hwndCnr,TRUE,FALSE,NULL,NULL,FALSE);
994 break;
995 case IDM_SELECTALLDIRS:
996 SelectAll(dcd->hwndCnr,FALSE,TRUE,NULL,NULL,FALSE);
997 break;
998 case IDM_DESELECTALLDIRS:
999 DeselectAll(dcd->hwndCnr,FALSE,TRUE,NULL,NULL,FALSE);
1000 break;
1001 case IDM_DESELECTMASK:
1002 case IDM_SELECTMASK:
1003 {
1004 MASK mask;
1005 PCNRITEM pci = (PCNRITEM)mp2;
1006
1007 memset(&mask,0,sizeof(MASK));
1008 mask.fNoAttribs = TRUE;
1009 mask.fNoDirs = TRUE;
1010 mask.fText = TRUE;
1011 strcpy(mask.prompt,
1012 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
1013 IDS_SELECTFILTERTEXT :
1014 IDS_DESELECTFILTERTEXT));
1015 if(pci && (INT)pci != -1)
1016 strcpy(mask.szMask,pci->szFileName);
1017 if(WinDlgBox(HWND_DESKTOP,
1018 dcd->hwndCnr,
1019 PickMaskDlgProc,
1020 FM3ModHandle,
1021 MSK_FRAME,
1022 MPFROMP(&mask))) {
1023 if(SHORT1FROMMP(mp1) == IDM_SELECTMASK)
1024 SelectAll(dcd->hwndCnr,
1025 TRUE,
1026 TRUE,
1027 mask.szMask,
1028 mask.szText,
1029 FALSE);
1030 else
1031 DeselectAll(dcd->hwndCnr,
1032 TRUE,
1033 TRUE,
1034 mask.szMask,
1035 mask.szText,
1036 FALSE);
1037 }
1038 }
1039 break;
1040
1041 case IDM_DESELECTCLIP:
1042 case IDM_SELECTCLIP:
1043 {
1044 CHAR **list;
1045
1046 list = ListFromClipboard(hwnd);
1047 if(list) {
1048 SelectList(dcd->hwndCnr,TRUE,FALSE,
1049 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
1050 NULL,NULL,list);
1051 FreeList(list);
1052 }
1053 }
1054 break;
1055
1056 case IDM_INVERT:
1057 InvertAll(dcd->hwndCnr);
1058 break;
1059 }
1060 }
1061 return 0;
1062
1063 case UM_MASSACTION:
1064 if(mp1) {
1065
1066 dcd = WinQueryWindowPtr(hwnd,0);
1067 if(dcd) {
1068
1069 WORKER *wk;
1070
1071 wk = malloc(sizeof(WORKER));
1072 if(wk) {
1073 memset(wk,0,sizeof(WORKER));
1074 wk->size = sizeof(WORKER);
1075 wk->hwndCnr = dcd->hwndCnr;
1076 wk->hwndParent = dcd->hwndParent;
1077 wk->hwndFrame = dcd->hwndFrame;
1078 wk->hwndClient = dcd->hwndClient;
1079 wk->li = (LISTINFO *)mp1;
1080 strcpy(wk->directory,dcd->directory);
1081 if(_beginthread(MassAction,NULL,122880,(PVOID)wk) == -1) {
1082 free(wk);
1083 FreeListInfo((LISTINFO *)mp1);
1084 }
1085 }
1086 else
1087 FreeListInfo((LISTINFO *)mp1);
1088 }
1089 }
1090 return 0;
1091
1092 case UM_ACTION:
1093 if(mp1) {
1094
1095 dcd = WinQueryWindowPtr(hwnd,0);
1096 if(dcd) {
1097
1098 WORKER *wk;
1099
1100 wk = malloc(sizeof(WORKER));
1101 if(wk) {
1102 memset(wk,0,sizeof(WORKER));
1103 wk->size = sizeof(WORKER);
1104 wk->hwndCnr = dcd->hwndCnr;
1105 wk->hwndParent = dcd->hwndParent;
1106 wk->hwndFrame = dcd->hwndFrame;
1107 wk->hwndClient = dcd->hwndClient;
1108 wk->li = (LISTINFO *)mp1;
1109 strcpy(wk->directory,dcd->directory);
1110 if(_beginthread(Action,NULL,122880,(PVOID)wk) == -1) {
1111 free(wk);
1112 FreeListInfo((LISTINFO *)mp1);
1113 }
1114 }
1115 else
1116 FreeListInfo((LISTINFO *)mp1);
1117 }
1118 }
1119 return 0;
1120
1121 case WM_CLOSE:
1122 WinDestroyWindow(hwnd);
1123 break;
1124
1125 case WM_DESTROY:
1126 dcd = WinQueryWindowPtr(hwnd,0);
1127 if(dcd) {
1128 if(dcd->hwndRestore)
1129 WinSetWindowPos(dcd->hwndRestore,
1130 HWND_TOP,
1131 0,
1132 0,
1133 0,
1134 0,
1135 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
1136 FreeList(dcd->lastselection);
1137 free(dcd);
1138 DosPostEventSem(CompactSem);
1139 }
1140 if(!PostMsg((HWND)0,
1141 WM_QUIT,
1142 MPVOID,
1143 MPVOID))
1144 WinSendMsg((HWND)0,
1145 WM_QUIT,
1146 MPVOID,
1147 MPVOID);
1148 break;
1149 }
1150 return WinDefWindowProc(hwnd,msg,mp1,mp2);
1151}
1152
1153
1154MRESULT EXPENTRY DirCnrWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
1155
1156 DIRCNRDATA *dcd = WinQueryWindowPtr(hwnd,0);
1157
1158 switch(msg) {
1159 case DM_PRINTOBJECT:
1160 return MRFROMLONG(DRR_TARGET);
1161
1162 case DM_DISCARDOBJECT:
1163 if(dcd)
1164 return WinSendMsg(dcd->hwndObject,msg,mp1,mp2);
1165 else
1166 return MRFROMLONG(DRR_TARGET);
1167
1168 case WM_CHAR:
1169 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1170 if(SHORT1FROMMP(mp1) & KC_KEYUP)
1171 return (MRESULT)TRUE;
1172 if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1173 switch(SHORT2FROMMP(mp2)) {
1174 case VK_INSERT:
1175 if((shiftstate & KC_CTRL) == KC_CTRL)
1176 PostMsg(hwnd,
1177 WM_COMMAND,
1178 MPFROM2SHORT(IDM_MKDIR,0),
1179 MPVOID);
1180 else if((shiftstate & KC_ALT) == KC_ALT)
1181 PostMsg(hwnd,
1182 WM_COMMAND,
1183 MPFROM2SHORT(IDM_CREATE,0),
1184 MPVOID);
1185 break;
1186 case VK_PAGEUP:
1187 if((shiftstate & KC_CTRL) == KC_CTRL)
1188 PostMsg(hwnd,
1189 WM_COMMAND,
1190 MPFROM2SHORT(IDM_PARENT,0),
1191 MPVOID);
1192 break;
1193 case VK_PAGEDOWN:
1194 if((shiftstate & KC_CTRL) == KC_CTRL)
1195 PostMsg(hwnd,
1196 WM_COMMAND,
1197 MPFROM2SHORT(IDM_PREVIOUS,0),
1198 MPVOID);
1199 break;
1200 case VK_HOME:
1201 if((shiftstate & KC_CTRL) == KC_CTRL && dcd) {
1202
1203 CHAR s[CCHMAXPATH],*p;
1204
1205 strcpy(s,dcd->directory);
1206 p = strchr(s,'\\');
1207 if(p) {
1208 p++;
1209 *p = 0;
1210 WinSendMsg(hwnd,
1211 UM_SETDIR,
1212 MPFROMP(s),
1213 MPVOID);
1214 }
1215 }
1216 break;
1217 case VK_DELETE:
1218 if((shiftstate & KC_CTRL) == KC_CTRL)
1219 PostMsg(hwnd,WM_COMMAND,MPFROM2SHORT(IDM_PERMDELETE,0),MPVOID);
1220 else if((shiftstate & KC_SHIFT) == KC_SHIFT)
1221 PostMsg(hwnd,WM_COMMAND,MPFROM2SHORT(IDM_SAVETOCLIP,0),MPVOID);
1222 else
1223 PostMsg(hwnd,WM_COMMAND,MPFROM2SHORT(IDM_DELETE,0),MPVOID);
1224 break;
1225 }
1226 }
1227 if(shiftstate || fNoSearch)
1228 break;
1229 if(SHORT1FROMMP(mp1) & KC_CHAR) {
1230
1231 ULONG thistime,len;
1232 SEARCHSTRING srch;
1233 PCNRITEM pci;
1234
1235 if(!dcd)
1236 break;
1237 switch(SHORT1FROMMP(mp2)) {
1238 case '\x1b':
1239 case '\r':
1240 case '\n':
1241 dcd->lasttime = 0;
1242 *dcd->comnam = 0;
1243 break;
1244 default:
1245 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1246 if(thistime > dcd->lasttime + 1250)
1247 *dcd->comnam = 0;
1248 dcd->lasttime = thistime;
1249 if(SHORT1FROMMP(mp2) == ' ' && !dcd->comnam)
1250 break;
1251KbdRetry:
1252 len = strlen(dcd->comnam);
1253 if(len >= CCHMAXPATH - 1) {
1254 *dcd->comnam = 0;
1255 len = 0;
1256 }
1257 dcd->comnam[len] = toupper(SHORT1FROMMP(mp2));
1258 dcd->comnam[len + 1] = 0;
1259 memset(&srch,0,sizeof(SEARCHSTRING));
1260 srch.cb = (ULONG)sizeof(SEARCHSTRING);
1261 srch.pszSearch = (PSZ)dcd->comnam;
1262 srch.fsPrefix = TRUE;
1263 srch.fsCaseSensitive = FALSE;
1264 srch.usView = CV_ICON;
1265 pci = WinSendMsg(hwnd,CM_SEARCHSTRING,MPFROMP(&srch),
1266 MPFROMLONG(CMA_FIRST));
1267 if(pci && (INT)pci != -1) {
1268
1269 USHORT attrib = CRA_CURSORED;
1270
1271 /* make found item current item */
1272 if(!stricmp(pci->pszFileName,dcd->comnam))
1273 attrib |= CRA_SELECTED;
1274 WinSendMsg(hwnd,CM_SETRECORDEMPHASIS,MPFROMP(pci),
1275 MPFROM2SHORT(TRUE,attrib));
1276 /* make sure that record shows in viewport */
1277 ShowCnrRecord(hwnd,(PMINIRECORDCORE)pci);
1278 return (MRESULT)TRUE;
1279 }
1280 else {
1281 if(SHORT1FROMMP(mp2) == ' ') {
1282 dcd->comnam[len] = 0;
1283 break;
1284 }
1285 *dcd->comnam = 0;
1286 dcd->lasttime = 0;
1287 if(len) // retry as first letter if no match
1288 goto KbdRetry;
1289 }
1290 break;
1291 }
1292 }
1293 break;
1294
1295 case WM_MOUSEMOVE:
1296 case WM_BUTTON1UP:
1297 case WM_BUTTON2UP:
1298 case WM_BUTTON3UP:
1299 case WM_CHORD:
1300 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1301 break;
1302
1303 case WM_BUTTON1MOTIONEND:
1304 {
1305 CNRINFO cnri;
1306
1307 memset(&cnri,0,sizeof(CNRINFO));
1308 cnri.cb = sizeof(CNRINFO);
1309 if(WinSendMsg(hwnd,CM_QUERYCNRINFO,MPFROMP(&cnri),
1310 MPFROMLONG(sizeof(CNRINFO)))) {
1311 if(cnri.flWindowAttr & CV_DETAIL)
1312 PrfWriteProfileData(fmprof,appname,"CnrSplitBar",
1313 (PVOID)&cnri.xVertSplitbar,sizeof(LONG));
1314 }
1315 }
1316 break;
1317
1318 case UM_COMPARE:
1319 if(dcd && mp1 && mp2) {
1320
1321 COMPARE *cmp;
1322 CHAR *leftdir = (CHAR *)mp1,*rightdir = (CHAR *)mp2;
1323
1324 if(!IsFile(leftdir) &&
1325 !IsFile(rightdir)) {
1326 cmp = malloc(sizeof(COMPARE));
1327 if(cmp) {
1328 memset(cmp,0,sizeof(COMPARE));
1329 cmp->size = sizeof(COMPARE);
1330 strcpy(cmp->leftdir,leftdir);
1331 strcpy(cmp->rightdir,rightdir);
1332 cmp->hwndParent = dcd->hwndParent;
1333 cmp->dcd.hwndParent = dcd->hwndParent;
1334 WinDlgBox(HWND_DESKTOP,
1335 HWND_DESKTOP,
1336 CompareDlgProc,
1337 FM3ModHandle,
1338 COMP_FRAME,
1339 MPFROMP(cmp));
1340 }
1341 }
1342 }
1343 return 0;
1344
1345 case WM_PRESPARAMCHANGED:
1346 PresParamChanged(hwnd,
1347 "DirCnr",
1348 mp1,
1349 mp2);
1350 break;
1351
1352 case UM_UPDATERECORDLIST:
1353 if(dcd && mp1)
1354 WinSendMsg(dcd->hwndObject,
1355 msg,
1356 mp1,
1357 mp2);
1358 return 0;
1359
1360 case UM_UPDATERECORD:
1361 if(dcd && mp1) {
1362
1363 CHAR *filename;
1364
1365 filename = mp1;
1366 if(filename)
1367 UpdateCnrRecord(hwnd,
1368 filename,
1369 TRUE,
1370 dcd);
1371 }
1372 return 0;
1373
1374 case WM_SETFOCUS:
1375 /*
1376 * put name of our window (directory name) on status line
1377 */
1378 if(dcd && hwndStatus && mp2) {
1379
1380 PCNRITEM pci = NULL;
1381
1382 if(fAutoView && hwndMain) {
1383 pci = WinSendMsg(hwnd,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST),
1384 MPFROMSHORT(CRA_CURSORED));
1385 if(pci && (INT)pci != -1 &&
1386 (!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_SLOW)))
1387 WinSendMsg(hwndMain,
1388 UM_LOADFILE,
1389 MPFROMP(pci->szFileName),
1390 MPVOID);
1391 else
1392 WinSendMsg(hwndMain,
1393 UM_LOADFILE,
1394 MPVOID,
1395 MPVOID);
1396 }
1397 if(*dcd->directory) {
1398 if(hwndMain)
1399 WinSendMsg(hwndMain,
1400 UM_SETUSERLISTNAME,
1401 MPFROMP(dcd->directory),
1402 MPVOID);
1403 else
1404 add_udir(FALSE,dcd->directory);
1405 }
1406 if(hwndMain)
1407 PostMsg(hwndMain,
1408 UM_ADVISEFOCUS,
1409 MPFROMLONG(dcd->hwndFrame),
1410 MPVOID);
1411 }
1412 if(mp2) {
1413 LastDir = hwnd;
1414 PostMsg(hwnd,
1415 UM_RESCAN,
1416 MPVOID,
1417 MPVOID);
1418 if(fSwitchTreeOnFocus &&
1419 hwndTree &&
1420 dcd &&
1421 *dcd->directory)
1422 WinSendMsg(hwndTree,
1423 UM_SHOWME,
1424 MPFROMP(dcd->directory),
1425 MPVOID);
1426 }
1427 break;
1428
1429 case UM_SETDIR:
1430 if(dcd && mp1) {
1431
1432 CHAR fullname[CCHMAXPATH];
1433
1434 DosError(FERR_DISABLEHARDERR);
1435 if(!DosQueryPathInfo((CHAR *)mp1,
1436 FIL_QUERYFULLNAME,
1437 fullname,
1438 sizeof(fullname))) {
1439 if(stricmp(dcd->directory,fullname)) {
1440 strcpy(dcd->previous,dcd->directory);
1441 strcpy(dcd->directory,fullname);
1442 DosEnterCritSec();
1443 dcd->stopflag++;
1444 DosExitCritSec();
1445 if(!PostMsg(dcd->hwndObject,
1446 UM_RESCAN,
1447 MPVOID,
1448 MPFROMLONG(1L))) {
1449 strcpy(dcd->directory,dcd->previous);
1450 DosEnterCritSec();
1451 dcd->stopflag--;
1452 DosExitCritSec();
1453 }
1454 else if(*dcd->directory) {
1455 if(hwndMain)
1456 WinSendMsg(hwndMain,
1457 UM_SETUSERLISTNAME,
1458 MPFROMP(dcd->directory),
1459 MPVOID);
1460 else
1461 add_udir(FALSE,
1462 dcd->directory);
1463 }
1464 }
1465 }
1466 }
1467 break;
1468
1469 case UM_RESCAN:
1470 if(dcd) {
1471
1472 CNRINFO cnri;
1473 CHAR s[CCHMAXPATH * 2],tf[81],tb[81];
1474 PCNRITEM pci;
1475
1476 memset(&cnri,0,sizeof(CNRINFO));
1477 cnri.cb = sizeof(CNRINFO);
1478 WinSendMsg(hwnd,
1479 CM_QUERYCNRINFO,
1480 MPFROMP(&cnri),
1481 MPFROMLONG(sizeof(CNRINFO)));
1482 cnri.pszCnrTitle = dcd->directory;
1483 WinSendMsg(hwnd,
1484 CM_SETCNRINFO,
1485 MPFROMP(&cnri),
1486 MPFROMLONG(CMA_CNRTITLE));
1487 dcd->totalfiles = cnri.cRecords;
1488 commafmt(tb,sizeof(tb),dcd->totalfiles);
1489 if(dcd->totalbytes < 1024)
1490 commafmt(tf,sizeof(tf),dcd->totalbytes);
1491 else
1492 commafmt(tf,sizeof(tf),dcd->totalbytes / 1024L);
1493 sprintf(s,"%s / %s%s",tb,tf,(dcd->totalbytes < 1024) ? "b" : "k");
1494 WinSetDlgItemText(dcd->hwndClient,DIR_TOTALS,s);
1495 commafmt(tb,sizeof(tb),dcd->selectedfiles);
1496 if(dcd->selectedbytes < 1024)
1497 commafmt(tf,sizeof(tf),dcd->selectedbytes);
1498 else
1499 commafmt(tf,sizeof(tf),dcd->selectedbytes / 1024L);
1500 sprintf(s,"%s / %s%s",tb,tf,(dcd->selectedbytes < 1024) ? "b" : "k");
1501 WinSetDlgItemText(dcd->hwndClient,DIR_SELECTED,s);
1502 if(hwndStatus &&
1503 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1504 PostMsg(dcd->hwndObject,
1505 UM_RESCAN2,
1506 MPVOID,
1507 MPVOID);
1508 if((fSplitStatus &&
1509 hwndStatus2) ||
1510 fMoreButtons) {
1511 pci = WinSendMsg(hwnd,
1512 CM_QUERYRECORDEMPHASIS,
1513 MPFROMLONG(CMA_FIRST),
1514 MPFROMSHORT(CRA_CURSORED));
1515 if(pci && (INT)pci != -1) {
1516 if(fSplitStatus &&
1517 hwndStatus2) {
1518 commafmt(tb,sizeof(tb),pci->cbFile + pci->easize);
1519 if(!fMoreButtons)
1520 sprintf(s,
1521 " %sb %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
1522 tb,
1523 pci->date.year,
1524 pci->date.month,
1525 pci->date.day,
1526 pci->time.hours,
1527 pci->time.minutes,
1528 pci->time.seconds,
1529 pci->pszDispAttr,
1530 pci->pszFileName);
1531 else {
1532 *tf = 0;
1533 if(pci->cbFile + pci->easize > 1024)
1534 commafmt(tf,sizeof(tf),
1535 (pci->cbFile + pci->easize) / 1024);
1536 sprintf(s,
1537 GetPString(IDS_STATUSSIZETEXT),
1538 tb,
1539 (*tf) ? " (" : NullStr,
1540 tf,
1541 (*tf) ? "k)" : NullStr);
1542 }
1543 WinSetWindowText(hwndStatus2,s);
1544 }
1545 else
1546 WinSetWindowText(hwndStatus2,NullStr);
1547 if(fMoreButtons) {
1548 WinSetWindowText(hwndName,pci->pszFileName);
1549 sprintf(s,
1550 "%04u/%02u/%02u %02u:%02u:%02u",
1551 pci->date.year,
1552 pci->date.month,
1553 pci->date.day,
1554 pci->time.hours,
1555 pci->time.minutes,
1556 pci->time.seconds);
1557 WinSetWindowText(hwndDate,s);
1558 WinSetWindowText(hwndAttr,pci->pszDispAttr);
1559 }
1560 }
1561 else {
1562 WinSetWindowText(hwndStatus2,NullStr);
1563 WinSetWindowText(hwndName,NullStr);
1564 WinSetWindowText(hwndDate,NullStr);
1565 WinSetWindowText(hwndAttr,NullStr);
1566 }
1567 }
1568 }
1569 }
1570 return 0;
1571
1572 case UM_SORTRECORD:
1573 if(dcd) {
1574
1575 CNRINFO cnri;
1576
1577 memset(&cnri,0,sizeof(CNRINFO));
1578 cnri.cb = sizeof(CNRINFO);
1579 WinSendMsg(hwnd,
1580 CM_QUERYCNRINFO,
1581 MPFROMP(&cnri),
1582 MPFROMLONG(sizeof(CNRINFO)));
1583 cnri.pSortRecord = (PVOID)SortDirCnr;
1584 WinSendMsg(hwnd,
1585 CM_SETCNRINFO,
1586 MPFROMP(&cnri),
1587 MPFROMLONG(CMA_PSORTRECORD));
1588 WinSendMsg(hwnd,
1589 CM_SORTRECORD,
1590 MPFROMP(SortDirCnr),
1591 MPFROMLONG(dcd->sortFlags));
1592 }
1593 return 0;
1594
1595 case UM_SETUP:
1596 if(dcd) {
1597 if(!dcd->hwndObject) {
1598 /*
1599 * first time through -- set things up
1600 */
1601
1602 CNRINFO cnri;
1603
1604 RestorePresParams(hwnd,"DirCnr");
1605 LoadDetailsSwitches("DirCnr",dcd);
1606 memset(&cnri,0,sizeof(CNRINFO));
1607 cnri.cb = sizeof(CNRINFO);
1608 WinSendMsg(hwnd,
1609 CM_QUERYCNRINFO,
1610 MPFROMP(&cnri),
1611 MPFROMLONG(sizeof(CNRINFO)));
1612 cnri.cyLineSpacing = 0;
1613 cnri.cxTreeIndent = 12L;
1614
1615 cnri.flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1616 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES | CV_MINI |
1617 CV_FLOW);
1618 cnri.pSortRecord = (PVOID)SortDirCnr;
1619
1620 {
1621 ULONG size = sizeof(ULONG);
1622
1623 PrfQueryProfileData(fmprof,
1624 appname,
1625 "DirflWindowAttr",
1626 (PVOID)&cnri.flWindowAttr,
1627 &size);
1628 size = sizeof(MASK);
1629 if(!*dcd->mask.szMask &&
1630 !dcd->mask.attrFile &&
1631 !dcd->mask.antiattr) {
1632 if(PrfQueryProfileSize(fmprof,
1633 appname,
1634 "DirFilter",
1635 &size) &&
1636 size) {
1637 PrfQueryProfileData(fmprof,
1638 appname,
1639 "DirFilter",
1640 &dcd->mask,
1641 &size);
1642 SetMask(dcd->mask.szMask,&dcd->mask);
1643 }
1644 else
1645 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1646 FILE_ARCHIVED | FILE_DIRECTORY |
1647 FILE_HIDDEN | FILE_SYSTEM);
1648 }
1649 *(dcd->mask.prompt) = 0;
1650 }
1651 if(dcd->flWindowAttr)
1652 cnri.flWindowAttr = dcd->flWindowAttr;
1653 else
1654 dcd->flWindowAttr = cnri.flWindowAttr;
1655 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH |
1656 CA_TITLEREADONLY | CA_TITLESEPARATOR));
1657 cnri.flWindowAttr |= CV_FLOW;
1658 dcd->flWindowAttr |= CV_FLOW;
1659 if(WinWindowFromID(dcd->hwndFrame,FID_TITLEBAR))
1660 cnri.flWindowAttr &= (~CA_CONTAINERTITLE);
1661 else
1662 cnri.flWindowAttr |= CA_CONTAINERTITLE;
1663 if(!dcd->sortFlags)
1664 dcd->sortFlags = sortFlags;
1665 WinSendMsg(hwnd,
1666 CM_SETCNRINFO,
1667 MPFROMP(&cnri),
1668 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1669 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1670 SetCnrCols(hwnd,FALSE);
1671 AdjustCnrColsForPref(hwnd,
1672 NULL,
1673 dcd,
1674 FALSE);
1675 if(_beginthread(MakeObjWin,
1676 NULL,
1677 245760,
1678 (PVOID)dcd) == -1) {
1679 PostMsg(hwnd,
1680 WM_CLOSE,
1681 MPVOID,
1682 MPVOID);
1683 return 0;
1684 }
1685 else
1686 DosSleep(64L);
1687 WinEnableMenuItem(DirCnrMenu,IDM_FINDINTREE,
1688 (hwndTree != (HWND)0));
1689 }
1690 SayFilter(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
1691 DIR_FILTER),&dcd->mask,FALSE);
1692 SaySort(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
1693 DIR_SORT),dcd->sortFlags,FALSE);
1694 SayView(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
1695 DIR_VIEW),dcd->flWindowAttr);
1696 }
1697 else {
1698 PostMsg(hwnd,
1699 WM_CLOSE,
1700 MPVOID,
1701 MPVOID);
1702 return 0;
1703 }
1704 return 0;
1705
1706 case WM_MENUEND:
1707 if(dcd) {
1708
1709 HWND hwndMenu = (HWND)mp2;
1710
1711 if(hwndMenu == DirCnrMenu || hwndMenu == FileMenu ||
1712 hwndMenu == DirMenu) {
1713 MarkAll(hwnd,TRUE,FALSE,TRUE);
1714 if(dcd->cnremphasized) {
1715 WinSendMsg(hwnd,CM_SETRECORDEMPHASIS,MPVOID,
1716 MPFROM2SHORT(FALSE,CRA_SOURCE));
1717 dcd->cnremphasized = FALSE;
1718 }
1719 }
1720 }
1721 break;
1722
1723 case UM_OPENWINDOWFORME:
1724 if(dcd) {
1725 if(mp1 &&
1726 !IsFile((CHAR *)mp1))
1727 OpenDirCnr(hwnd,
1728 dcd->hwndParent,
1729 dcd->hwndFrame,
1730 FALSE,
1731 (char *)mp1);
1732 else if(mp1 &&
1733 IsFile(mp1) == 1)
1734 StartArcCnr(HWND_DESKTOP,
1735 dcd->hwndFrame,
1736 (CHAR *)mp1,
1737 4,
1738 (ARC_TYPE *)mp2);
1739 }
1740 return 0;
1741
1742 case MM_PORTHOLEINIT:
1743 if(dcd) {
1744 switch(SHORT1FROMMP(mp1)) {
1745 case 0:
1746 case 1:
1747 {
1748 ULONG wmsg;
1749
1750 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1751 PortholeInit((HWND)WinSendMsg(dcd->hwndClient,
1752 wmsg,
1753 MPVOID,
1754 MPVOID),
1755 mp1,
1756 mp2);
1757 }
1758 break;
1759 }
1760 }
1761 break;
1762
1763 case UM_INITMENU:
1764 case WM_INITMENU:
1765 if(dcd) {
1766 switch(SHORT1FROMMP(mp1)) {
1767 case IDM_FILESMENU:
1768 if(isalpha(*dcd->directory)) {
1769 if(driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
1770 WinEnableMenuItem((HWND)mp2,IDM_MOVEMENU,FALSE);
1771 WinEnableMenuItem((HWND)mp2,IDM_RENAME,FALSE);
1772 WinEnableMenuItem((HWND)mp2,IDM_MKDIR,FALSE);
1773 WinEnableMenuItem((HWND)mp2,IDM_UNDELETE,FALSE);
1774 WinEnableMenuItem((HWND)mp2,IDM_DELETESUBMENU,FALSE);
1775 WinEnableMenuItem((HWND)mp2,IDM_DELETE,FALSE);
1776 WinEnableMenuItem((HWND)mp2,IDM_EDIT,FALSE);
1777 WinEnableMenuItem((HWND)mp2,IDM_EDITTEXT,FALSE);
1778 WinEnableMenuItem((HWND)mp2,IDM_EDITBINARY,FALSE);
1779 WinEnableMenuItem((HWND)mp2,IDM_ATTRS,FALSE);
1780 }
1781 else {
1782 WinEnableMenuItem((HWND)mp2,IDM_MOVEMENU,TRUE);
1783 WinEnableMenuItem((HWND)mp2,IDM_RENAME,TRUE);
1784 WinEnableMenuItem((HWND)mp2,IDM_MKDIR,TRUE);
1785 WinEnableMenuItem((HWND)mp2,IDM_UNDELETE,TRUE);
1786 WinEnableMenuItem((HWND)mp2,IDM_DELETESUBMENU,TRUE);
1787 WinEnableMenuItem((HWND)mp2,IDM_DELETE,TRUE);
1788 WinEnableMenuItem((HWND)mp2,IDM_EDIT,TRUE);
1789 WinEnableMenuItem((HWND)mp2,IDM_EDITTEXT,TRUE);
1790 WinEnableMenuItem((HWND)mp2,IDM_EDITBINARY,TRUE);
1791 WinEnableMenuItem((HWND)mp2,IDM_ATTRS,TRUE);
1792 }
1793 }
1794 break;
1795
1796 case IDM_VIEWSMENU:
1797 SetViewMenu((HWND)mp2,dcd->flWindowAttr);
1798 WinEnableMenuItem((HWND)mp2,IDM_RESELECT,
1799 (dcd->lastselection != NULL));
1800 if(isalpha(*dcd->directory)) {
1801 if(driveflags[toupper(*dcd->directory) - 'A'] &
1802 DRIVE_NOTWRITEABLE)
1803 WinEnableMenuItem((HWND)mp2,
1804 IDM_MKDIR,
1805 FALSE);
1806 else
1807 WinEnableMenuItem((HWND)mp2,
1808 IDM_MKDIR,
1809 TRUE);
1810 }
1811 WinEnableMenuItem((HWND)mp2,
1812 IDM_SELECTCOMPAREMENU,
1813 (CountDirCnrs(dcd->hwndParent) > 1));
1814 break;
1815
1816 case IDM_DETAILSSETUP:
1817 SetDetailsSwitches((HWND)mp2,dcd);
1818 break;
1819
1820 case IDM_COMMANDSMENU:
1821 SetupCommandMenu((HWND)mp2,hwnd);
1822 break;
1823
1824 case IDM_SORTSUBMENU:
1825 SetSortChecks((HWND)mp2,dcd->sortFlags);
1826 break;
1827
1828 case IDM_WINDOWSMENU:
1829 SetupWinList((HWND)mp2,
1830 (hwndMain) ? hwndMain : (HWND)0,
1831 dcd->hwndFrame);
1832 break;
1833 }
1834 dcd->hwndLastMenu = (HWND)mp2;
1835 }
1836 if(msg == WM_INITMENU)
1837 break;
1838 return 0;
1839
1840 case UM_FILTER:
1841 if(dcd) {
1842
1843 PCNRITEM pci;
1844
1845 if(mp1) {
1846 DosEnterCritSec();
1847 SetMask((CHAR *)mp1,&dcd->mask);
1848 DosExitCritSec();
1849 }
1850 dcd->suspendview = 1;
1851 WinSendMsg(hwnd,CM_FILTER,MPFROMP(Filter),MPFROMP(&dcd->mask));
1852 dcd->suspendview = 0;
1853 if(fAutoView && hwndMain) {
1854 pci = WinSendMsg(hwnd,CM_QUERYRECORDEMPHASIS,
1855 MPFROMLONG(CMA_FIRST),
1856 MPFROMSHORT(CRA_CURSORED));
1857 if(pci && (INT)pci != -1 &&
1858 (!(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_SLOW)))
1859 WinSendMsg(hwndMain,
1860 UM_LOADFILE,
1861 MPFROMP(pci->szFileName),
1862 MPVOID);
1863 else
1864 WinSendMsg(hwndMain,
1865 UM_LOADFILE,
1866 MPVOID,
1867 MPVOID);
1868 }
1869 PostMsg(hwnd,
1870 UM_RESCAN,
1871 MPVOID,
1872 MPVOID);
1873 }
1874 return 0;
1875
1876 case UM_COMMAND:
1877 if(mp1) {
1878 if(dcd) {
1879 if(!PostMsg(dcd->hwndObject,
1880 UM_COMMAND,
1881 mp1,
1882 mp2)) {
1883 FreeListInfo((LISTINFO *)mp1);
1884 DosBeep(50,100);
1885 }
1886 else
1887 return (MRESULT)TRUE;
1888 }
1889 else
1890 FreeListInfo((LISTINFO *)mp1);
1891 }
1892 return 0;
1893
1894 case UM_NOTIFY:
1895 if(mp2)
1896 Notify((CHAR *)mp2);
1897 return 0;
1898
1899 case UM_DRIVECMD:
1900 if(mp1)
1901 WinSendMsg(hwnd,
1902 WM_COMMAND,
1903 MPFROM2SHORT(IDM_SWITCH,0),
1904 mp1);
1905 return 0;
1906
1907 case WM_COMMAND:
1908 DosError(FERR_DISABLEHARDERR);
1909 if(dcd) {
1910 switch(SHORT1FROMMP(mp1)) {
1911 case IDM_SETTARGET:
1912 SetTargetDir(hwnd,FALSE);
1913 break;
1914
1915 case IDM_CREATE:
1916 {
1917 STRINGINPARMS sip;
1918 CHAR filename[CCHMAXPATHCOMP];
1919
1920 memset(&sip,0,sizeof(sip));
1921 sip.help = GetPString(IDS_CREATETEXT);
1922 sip.prompt = GetPString(IDS_CREATEPROMPTTEXT);
1923 sip.inputlen = CCHMAXPATHCOMP - (strlen(dcd->directory) - 1);
1924 strcpy(filename,"NEWFILE.TXT");
1925 sip.ret = filename;
1926 sip.title = GetPString(IDS_CREATETITLETEXT);
1927 if(WinDlgBox(HWND_DESKTOP,hwnd,InputDlgProc,FM3ModHandle,
1928 STR_FRAME,&sip) && *(lstrip(rstrip(sip.ret)))) {
1929
1930 CHAR newfile[CCHMAXPATH];
1931 FILE *fp;
1932 INT test;
1933 PCNRITEM pci;
1934
1935 strcpy(newfile,dcd->directory);
1936 if(newfile[strlen(newfile) - 1] != '\\')
1937 strcat(newfile,"\\");
1938 strcat(newfile,sip.ret);
1939 test = IsFile(newfile);
1940 if(test != 1)
1941 fp = fopen(newfile,"w");
1942 if(test == 1 || fp) {
1943 if(fp) {
1944 WinSendMsg(hwnd,
1945 UM_UPDATERECORD,
1946 MPFROMP(newfile),
1947 MPVOID);
1948 fclose(fp);
1949 }
1950 if(*editor) {
1951
1952 CHAR *dummy[2];
1953
1954 dummy[0] = newfile;
1955 dummy[1] = NULL;
1956 ExecOnList(hwnd,
1957 editor,
1958 WINDOWED | SEPARATE,
1959 NULL,
1960 dummy,
1961 NULL);
1962 }
1963 else
1964 StartMLEEditor(dcd->hwndParent,
1965 4,
1966 newfile,
1967 dcd->hwndFrame);
1968 pci = FindCnrRecord(hwnd,
1969 newfile,
1970 NULL,
1971 TRUE,
1972 FALSE,
1973 TRUE);
1974 if(pci && (INT)pci != -1)
1975 /* make sure that record shows in viewport */
1976 ShowCnrRecord(hwnd,(PMINIRECORDCORE)pci);
1977 }
1978 else
1979 saymsg(MB_ENTER,
1980 hwnd,
1981 GetPString(IDS_ERRORTEXT),
1982 GetPString(IDS_CREATEERRORTEXT),
1983 newfile);
1984 }
1985 }
1986 break;
1987
1988 case IDM_CONTEXTMENU:
1989 {
1990 PCNRITEM pci;
1991
1992 pci = (PCNRITEM)CurrentRecord(hwnd);
1993 PostMsg(hwnd,WM_CONTROL,MPFROM2SHORT(DIR_CNR,CN_CONTEXTMENU),
1994 MPFROMP(pci));
1995 }
1996 break;
1997
1998 case IDM_MAXIMIZE:
1999 PostMsg(hwndMain,
2000 UM_MAXIMIZE,
2001 MPFROMLONG(dcd->hwndFrame),
2002 MPVOID);
2003 break;
2004
2005 case IDM_SHOWALLFILESCNR:
2006 StartSeeAll(HWND_DESKTOP,FALSE,dcd->directory);
2007 break;
2008
2009 case IDM_SHOWALLFILES:
2010 {
2011 PCNRITEM pci;
2012
2013 pci = WinSendMsg(hwnd,CM_QUERYRECORDEMPHASIS,
2014 MPFROMLONG(CMA_FIRST),
2015 MPFROMSHORT(CRA_CURSORED));
2016 if(pci && (INT)pci != -1) {
2017
2018 static CHAR dirname[CCHMAXPATH];
2019
2020 strcpy(dirname,pci->szFileName);
2021 MakeValidDir(dirname);
2022 StartSeeAll(HWND_DESKTOP,FALSE,dirname);
2023 }
2024 }
2025 break;
2026
2027 case IDM_FINDINTREE:
2028 if(hwndTree)
2029 WinSendMsg(hwndTree,UM_SHOWME,MPFROMP(dcd->directory),
2030 MPFROMLONG(1L));
2031 break;
2032
2033 case IDM_BEGINEDIT:
2034 OpenEdit(hwnd);
2035 break;
2036
2037 case IDM_ENDEDIT:
2038 WinSendMsg(hwnd,
2039 CM_CLOSEEDIT,
2040 MPVOID,
2041 MPVOID);
2042 break;
2043
2044 case IDM_SHOWSELECT:
2045 QuickPopup(hwnd,
2046 dcd,
2047 CheckMenu(&DirCnrMenu,DIRCNR_POPUP),
2048 IDM_SELECTSUBMENU);
2049 break;
2050
2051 case IDM_SHOWSORT:
2052 QuickPopup(hwnd,dcd,CheckMenu(&DirCnrMenu,DIRCNR_POPUP),
2053 IDM_SORTSUBMENU);
2054 break;
2055
2056 case IDM_VIEWORARC:
2057 {
2058 SWP swp;
2059 PCNRITEM pci;
2060
2061 pci = (PCNRITEM)WinSendMsg(hwnd,CM_QUERYRECORDEMPHASIS,
2062 MPFROMLONG(CMA_FIRST),
2063 MPFROMSHORT(CRA_CURSORED));
2064 if(pci &&
2065 (INT)pci != -1) {
2066 WinQueryWindowPos(dcd->hwndFrame,&swp);
2067 DefaultViewKeys(hwnd,
2068 dcd->hwndFrame,
2069 dcd->hwndParent,
2070 &swp,
2071 pci->szFileName);
2072 }
2073 }
2074 break;
2075
2076 case IDM_NOTEBOOK:
2077 if(!ParentIsDesktop(dcd->hwndParent,dcd->hwndParent))
2078 PostMsg(dcd->hwndParent,msg,mp1,mp2);
2079 else
2080 WinDlgBox(HWND_DESKTOP,hwnd,CfgDlgProc,FM3ModHandle,
2081 CFG_FRAME,(PVOID)"Directory");
2082 break;
2083
2084 case IDM_QTREE:
2085 case IDM_TREE:
2086 {
2087 CHAR newpath[CCHMAXPATH];
2088 APIRET rc;
2089 PCNRITEM pci;
2090
2091 if(SHORT1FROMMP(mp1) == IDM_TREE) {
2092 pci = (PCNRITEM)CurrentRecord(hwnd);
2093 if(pci && (INT)pci != -1)
2094 strcpy(newpath,pci->szFileName);
2095 else
2096 strcpy(newpath,dcd->directory);
2097 }
2098 else
2099 strcpy(newpath,dcd->directory);
2100 MakeValidDir(newpath);
2101 rc = WinDlgBox(HWND_DESKTOP,dcd->hwndClient,ObjCnrDlgProc,
2102 FM3ModHandle,QTREE_FRAME,MPFROMP(newpath));
2103 if(rc)
2104 WinSendMsg(hwnd,UM_SETDIR,MPFROMP(newpath),MPVOID);
2105 }
2106 break;
2107
2108 case IDM_RESELECT:
2109 SelectList(hwnd,TRUE,FALSE,FALSE,NULL,NULL,
2110 dcd->lastselection);
2111 break;
2112
2113 case IDM_HELP:
2114 if(hwndHelp) {
2115 if(!ParentIsDesktop(dcd->hwndFrame,dcd->hwndParent))
2116 PostMsg(dcd->hwndParent,UM_COMMAND,mp1,mp2);
2117 else
2118 WinSendMsg(hwndHelp,HM_HELP_CONTENTS,MPVOID,MPVOID);
2119 }
2120 break;
2121
2122 case IDM_WINDOWDLG:
2123 if(!ParentIsDesktop(dcd->hwndFrame,dcd->hwndParent))
2124 PostMsg(dcd->hwndParent,UM_COMMAND,
2125 MPFROM2SHORT(IDM_WINDOWDLG,0),MPVOID);
2126 break;
2127
2128 case IDM_SORTSMARTNAME:
2129 case IDM_SORTNAME:
2130 case IDM_SORTFILENAME:
2131 case IDM_SORTSIZE:
2132 case IDM_SORTEASIZE:
2133 case IDM_SORTFIRST:
2134 case IDM_SORTLAST:
2135 case IDM_SORTLWDATE:
2136 case IDM_SORTLADATE:
2137 case IDM_SORTCRDATE:
2138 case IDM_SORTSUBJECT:
2139 dcd->sortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
2140 case IDM_SORTDIRSFIRST:
2141 case IDM_SORTDIRSLAST:
2142 case IDM_SORTREVERSE:
2143 switch(SHORT1FROMMP(mp1)) {
2144 case IDM_SORTSUBJECT:
2145 dcd->sortFlags |= SORT_SUBJECT;
2146 break;
2147 case IDM_SORTSMARTNAME:
2148 case IDM_SORTFILENAME:
2149 dcd->sortFlags |= SORT_FILENAME;
2150 break;
2151 case IDM_SORTSIZE:
2152 dcd->sortFlags |= SORT_SIZE;
2153 break;
2154 case IDM_SORTEASIZE:
2155 dcd->sortFlags |= SORT_EASIZE;
2156 break;
2157 case IDM_SORTFIRST:
2158 dcd->sortFlags |= SORT_FIRSTEXTENSION;
2159 break;
2160 case IDM_SORTLAST:
2161 dcd->sortFlags |= SORT_LASTEXTENSION;
2162 break;
2163 case IDM_SORTLWDATE:
2164 dcd->sortFlags |= SORT_LWDATE;
2165 break;
2166 case IDM_SORTLADATE:
2167 dcd->sortFlags |= SORT_LADATE;
2168 break;
2169 case IDM_SORTCRDATE:
2170 dcd->sortFlags |= SORT_CRDATE;
2171 break;
2172 case IDM_SORTDIRSFIRST:
2173 if(dcd->sortFlags & SORT_DIRSFIRST)
2174 dcd->sortFlags &= (~SORT_DIRSFIRST);
2175 else {
2176 dcd->sortFlags |= SORT_DIRSFIRST;
2177 dcd->sortFlags &= (~SORT_DIRSLAST);
2178 }
2179 break;
2180 case IDM_SORTDIRSLAST:
2181 if(dcd->sortFlags & SORT_DIRSLAST)
2182 dcd->sortFlags &= (~SORT_DIRSLAST);
2183 else {
2184 dcd->sortFlags |= SORT_DIRSLAST;
2185 dcd->sortFlags &= (~SORT_DIRSFIRST);
2186 }
2187 break;
2188 case IDM_SORTREVERSE:
2189 if(dcd->sortFlags & SORT_REVERSE)
2190 dcd->sortFlags &= (~SORT_REVERSE);
2191 else
2192 dcd->sortFlags |= SORT_REVERSE;
2193 break;
2194 }
2195 WinSendMsg(hwnd,CM_SORTRECORD,MPFROMP(SortDirCnr),
2196 MPFROMLONG(dcd->sortFlags));
2197 SaySort(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
2198 DIR_SORT),dcd->sortFlags,FALSE);
2199 break;
2200
2201 case IDM_COLLECT:
2202 if(!Collector) {
2203
2204 HWND hwndC;
2205 SWP swp;
2206
2207 if(!ParentIsDesktop(hwnd,dcd->hwndParent) && !fAutoTile &&
2208 (!fExternalCollector && !strcmp(realappname,FM3Str)))
2209 GetNextWindowPos(dcd->hwndParent,&swp,NULL,NULL);
2210 hwndC = StartCollector((fExternalCollector ||
2211 strcmp(realappname,FM3Str)) ?
2212 HWND_DESKTOP :
2213 dcd->hwndParent,4);
2214 if(hwndC) {
2215 if(!ParentIsDesktop(hwnd,dcd->hwndParent) && !fAutoTile &&
2216 (!fExternalCollector && !strcmp(realappname,FM3Str)))
2217 WinSetWindowPos(hwndC,HWND_TOP,swp.x,swp.y,
2218 swp.cx,swp.cy,SWP_MOVE | SWP_SIZE |
2219 SWP_SHOW | SWP_ZORDER);
2220 else if(!ParentIsDesktop(hwnd,dcd->hwndParent) && fAutoTile &&
2221 !strcmp(realappname,FM3Str))
2222 TileChildren(dcd->hwndParent,TRUE);
2223 WinSetWindowPos(hwndC,HWND_TOP,0,0,0,0,SWP_ACTIVATE);
2224 DosSleep(250L);
2225 }
2226 }
2227 else
2228 StartCollector(dcd->hwndParent,4);
2229 PostMsg(hwnd,WM_COMMAND,MPFROM2SHORT(IDM_COLLECTOR,0),MPVOID);
2230 break;
2231
2232 case IDM_COLLECTOR:
2233 DosSleep(64L);
2234 {
2235 CHAR **list;
2236
2237 list = BuildList(hwnd);
2238 if(list) {
2239 if(Collector) {
2240 if(!PostMsg(Collector,WM_COMMAND,
2241 MPFROM2SHORT(IDM_COLLECTOR,0),
2242 MPFROMP(list)))
2243 FreeList(list);
2244 else if(fUnHilite)
2245 UnHilite(hwnd,TRUE,&dcd->lastselection);
2246 }
2247 else
2248 FreeList(list);
2249 }
2250 }
2251 break;
2252
2253 case IDM_UNDELETE:
2254 {
2255 PCNRITEM pci;
2256 CHAR path[CCHMAXPATH];
2257
2258 pci = (PCNRITEM)CurrentRecord(hwnd);
2259 if(pci && (INT)pci != -1) {
2260 strcpy(path,pci->szFileName);
2261 MakeValidDir(path);
2262 WinDlgBox(HWND_DESKTOP,hwnd,UndeleteDlgProc,FM3ModHandle,
2263 UNDEL_FRAME,MPFROMP(path));
2264 }
2265 }
2266 break;
2267
2268 case IDM_UNDELETESPEC:
2269 WinDlgBox(HWND_DESKTOP,
2270 hwnd,
2271 UndeleteDlgProc,
2272 FM3ModHandle,
2273 UNDEL_FRAME,
2274 MPFROMP(dcd->directory));
2275 break;
2276
2277 case IDM_RESORT:
2278// WinSendMsg(hwnd,
2279// CM_SORTRECORD,
2280// MPFROMP(SortDirCnr),
2281// MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
2282 WinSendMsg(hwnd,
2283 CM_SORTRECORD,
2284 MPFROMP(SortDirCnr),
2285 MPFROMLONG(dcd->sortFlags));
2286 break;
2287
2288 case IDM_FILTER:
2289 {
2290 BOOL empty = FALSE;
2291 PCNRITEM pci;
2292 CHAR *p;
2293
2294 if(!*dcd->mask.szMask) {
2295 empty = TRUE;
2296 pci = (PCNRITEM)CurrentRecord(hwnd);
2297 if(pci && !(pci->attrFile & FILE_DIRECTORY)) {
2298 p = strrchr(pci->szFileName,'\\');
2299 if(p) {
2300 p++;
2301 strcpy(dcd->mask.szMask,p);
2302 }
2303 }
2304 }
2305 *(dcd->mask.prompt) = 0;
2306
2307 if(WinDlgBox(HWND_DESKTOP,hwnd,PickMaskDlgProc,
2308 FM3ModHandle,MSK_FRAME,MPFROMP(&dcd->mask)))
2309 WinSendMsg(hwnd,UM_FILTER,MPVOID,MPVOID);
2310 else if(empty)
2311 *dcd->mask.szMask = 0;
2312 SayFilter(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
2313 DIR_FILTER),&dcd->mask,FALSE);
2314 }
2315 break;
2316
2317 case IDM_HIDEALL:
2318 if(fAutoView && hwndMain)
2319 PostMsg(hwndMain,
2320 UM_LOADFILE,
2321 MPVOID,
2322 MPVOID);
2323 dcd->suspendview = 1;
2324 HideAll(hwnd);
2325 dcd->suspendview = 0;
2326 PostMsg(hwnd,
2327 UM_RESCAN,
2328 MPVOID,
2329 MPVOID);
2330 break;
2331
2332 case IDM_SELECTBOTH:
2333 case IDM_SELECTONE:
2334 case IDM_SELECTMORE:
2335 case IDM_SELECTNEWER:
2336 case IDM_SELECTOLDER:
2337 case IDM_SELECTBIGGER:
2338 case IDM_SELECTSMALLER:
2339 case IDM_DESELECTBOTH:
2340 case IDM_DESELECTONE:
2341 case IDM_DESELECTMORE:
2342 case IDM_DESELECTNEWER:
2343 case IDM_DESELECTOLDER:
2344 case IDM_DESELECTBIGGER:
2345 case IDM_DESELECTSMALLER:
2346 if(ParentIsDesktop(hwnd,dcd->hwndParent)) {
2347 DosBeep(50,100);
2348 break;
2349 }
2350 case IDM_SELECTLIST:
2351 case IDM_SELECTALL:
2352 case IDM_DESELECTALL:
2353 case IDM_SELECTALLFILES:
2354 case IDM_DESELECTALLFILES:
2355 case IDM_SELECTALLDIRS:
2356 case IDM_DESELECTALLDIRS:
2357 case IDM_SELECTMASK:
2358 case IDM_DESELECTMASK:
2359 case IDM_INVERT:
2360 case IDM_SELECTCLIP:
2361 case IDM_DESELECTCLIP:
2362 {
2363 PCNRITEM pci;
2364
2365 pci = (PCNRITEM)CurrentRecord(hwnd);
2366 if((INT)pci == -1)
2367 pci = NULL;
2368 if(SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2369 if(pci) {
2370 if(!(pci->rc.flRecordAttr & CRA_SELECTED))
2371 pci->rc.flRecordAttr |= CRA_FILTERED;
2372 WinSendMsg(hwnd,CM_INVALIDATERECORD,MPFROMP(&pci),
2373 MPFROM2SHORT(1,CMA_ERASE | CMA_REPOSITION));
2374 break;
2375 }
2376 }
2377 PostMsg(dcd->hwndObject,
2378 UM_SELECT,
2379 mp1,
2380 MPFROMP(pci));
2381 }
2382 break;
2383
2384 case IDM_RESCAN:
2385 DosEnterCritSec();
2386 dcd->stopflag++;
2387 DosExitCritSec();
2388 if(!PostMsg(dcd->hwndObject,
2389 UM_RESCAN,
2390 MPVOID,
2391 MPVOID)) {
2392 DosEnterCritSec();
2393 dcd->stopflag--;
2394 DosExitCritSec();
2395 }
2396 break;
2397
2398 case IDM_SHOWLNAMES:
2399 case IDM_SHOWSUBJECT:
2400 case IDM_SHOWEAS:
2401 case IDM_SHOWSIZE:
2402 case IDM_SHOWICON:
2403 case IDM_SHOWLWDATE:
2404 case IDM_SHOWLWTIME:
2405 case IDM_SHOWLADATE:
2406 case IDM_SHOWLATIME:
2407 case IDM_SHOWCRDATE:
2408 case IDM_SHOWCRTIME:
2409 case IDM_SHOWATTR:
2410 AdjustDetailsSwitches(hwnd,
2411 dcd->hwndLastMenu,
2412 SHORT1FROMMP(mp1),
2413 dcd->directory,
2414 "DirCnr",
2415 dcd,
2416 FALSE);
2417 break;
2418
2419 case IDM_TREEVIEW:
2420 case IDM_ICON:
2421 case IDM_TEXT:
2422 case IDM_DETAILS:
2423 case IDM_NAME:
2424 case IDM_MINIICONS:
2425 case IDM_DETAILSTITLES:
2426 {
2427 CNRINFO cnri;
2428
2429 memset(&cnri,0,sizeof(CNRINFO));
2430 cnri.cb = sizeof(CNRINFO);
2431 WinSendMsg(hwnd,CM_QUERYCNRINFO,MPFROMP(&cnri),
2432 MPFROMLONG(sizeof(CNRINFO)));
2433 switch(SHORT1FROMMP(mp1)) {
2434 case IDM_TREEVIEW:
2435 if(!(cnri.flWindowAttr & CV_TREE))
2436 dcd->lastattr = cnri.flWindowAttr;
2437 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2438 CV_DETAIL | CV_NAME | CA_TREELINE));
2439 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2440 if(!dcd->firsttree)
2441 PostMsg(dcd->hwndObject,UM_FLESH,MPVOID,MPVOID);
2442 break;
2443 case IDM_ICON:
2444 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2445 CV_DETAIL | CV_NAME | CA_TREELINE));
2446 cnri.flWindowAttr |= CV_ICON;
2447 break;
2448 case IDM_NAME:
2449 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2450 CV_DETAIL | CV_NAME | CA_TREELINE));
2451 cnri.flWindowAttr |= CV_NAME;
2452 break;
2453 case IDM_TEXT:
2454 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2455 CV_DETAIL | CV_NAME | CA_TREELINE));
2456 cnri.flWindowAttr |= CV_TEXT;
2457 break;
2458 case IDM_DETAILS:
2459 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2460 CV_DETAIL | CV_NAME | CA_TREELINE));
2461 cnri.flWindowAttr |= CV_DETAIL;
2462 break;
2463 case IDM_MINIICONS:
2464 if(cnri.flWindowAttr & CV_MINI)
2465 cnri.flWindowAttr &= (~CV_MINI);
2466 else
2467 cnri.flWindowAttr |= CV_MINI;
2468 break;
2469 case IDM_DETAILSTITLES:
2470 if(cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2471 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2472 else
2473 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2474 break;
2475 }
2476 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH |
2477 CA_MIXEDTARGETEMPH));
2478 cnri.flWindowAttr |= CV_FLOW;
2479 dcd->flWindowAttr = cnri.flWindowAttr;
2480 WinSendMsg(hwnd,CM_SETCNRINFO,MPFROMP(&cnri),
2481 MPFROMLONG(CMA_FLWINDOWATTR));
2482 WinSendMsg(hwnd,CM_INVALIDATERECORD,MPVOID,
2483 MPFROM2SHORT(0,CMA_ERASE | CMA_REPOSITION));
2484 SayView(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
2485 DIR_VIEW),dcd->flWindowAttr);
2486 }
2487 break;
2488
2489 case IDM_SAVETOLIST:
2490 WinDlgBox(HWND_DESKTOP,hwnd,SaveListDlgProc,FM3ModHandle,
2491 SAV_FRAME,MPFROMP(&hwnd));
2492 break;
2493
2494 case IDM_SIZES:
2495 {
2496 PCNRITEM pci;
2497 CHAR path[CCHMAXPATH];
2498
2499 pci = (PCNRITEM)CurrentRecord(hwnd);
2500 if(pci && (INT)pci != -1)
2501 strcpy(path,pci->szFileName);
2502 else
2503 strcpy(path,dcd->directory);
2504 MakeValidDir(path);
2505 WinDlgBox(HWND_DESKTOP,
2506 HWND_DESKTOP,
2507 DirSizeProc,
2508 FM3ModHandle,
2509 DSZ_FRAME,
2510 path);
2511 }
2512 break;
2513
2514 case IDM_MKDIR:
2515 {
2516 PCNRITEM pci;
2517
2518 pci = (PCNRITEM)CurrentRecord(hwnd);
2519 PMMkDir(dcd->hwndParent,
2520 ((pci && (INT)pci != -1) ?
2521 pci->szFileName :
2522 dcd->directory),
2523 FALSE);
2524 }
2525 break;
2526
2527 case IDM_SWITCH:
2528 if(mp2) {
2529 strcpy(dcd->previous,dcd->directory);
2530 strcpy(dcd->directory,(CHAR *)mp2);
2531 DosEnterCritSec();
2532 dcd->stopflag++;
2533 DosExitCritSec();
2534 if(!PostMsg(dcd->hwndObject,
2535 UM_RESCAN,
2536 MPVOID,
2537 MPFROMLONG(1L))) {
2538 strcpy(dcd->directory,
2539 dcd->previous);
2540 DosEnterCritSec();
2541 dcd->stopflag--;
2542 DosExitCritSec();
2543 }
2544 else if(*dcd->directory) {
2545 if(hwndMain)
2546 WinSendMsg(hwndMain,
2547 UM_SETUSERLISTNAME,
2548 MPFROMP(dcd->directory),
2549 MPVOID);
2550 else
2551 add_udir(FALSE,dcd->directory);
2552 }
2553 }
2554 break;
2555
2556 case IDM_PARENT:
2557 {
2558 CHAR tempname1[CCHMAXPATH],
2559 tempname2[CCHMAXPATH];
2560
2561 strcpy(tempname1,dcd->directory);
2562 if(tempname1[strlen(tempname1) - 1] != '\\')
2563 strcat(tempname1,"\\");
2564 strcat(tempname1,"..");
2565 DosError(FERR_DISABLEHARDERR);
2566 if(!DosQueryPathInfo(tempname1,
2567 FIL_QUERYFULLNAME,
2568 tempname2,
2569 sizeof(tempname2))) {
2570 if(stricmp(dcd->directory,tempname2)) {
2571 strcpy(dcd->previous,dcd->directory);
2572 strcpy(dcd->directory,tempname2);
2573 DosEnterCritSec();
2574 dcd->stopflag++;
2575 DosExitCritSec();
2576 if(!PostMsg(dcd->hwndObject,
2577 UM_RESCAN,
2578 MPVOID,
2579 MPFROMLONG(1L))) {
2580 strcpy(dcd->directory,dcd->previous);
2581 DosEnterCritSec();
2582 dcd->stopflag--;
2583 DosExitCritSec();
2584 }
2585 else if(*dcd->directory) {
2586 if(hwndMain)
2587 WinSendMsg(hwndMain,
2588 UM_SETUSERLISTNAME,
2589 MPFROMP(dcd->directory),
2590 MPVOID);
2591 else
2592 add_udir(FALSE,
2593 dcd->directory);
2594 }
2595 }
2596 }
2597 }
2598 break;
2599
2600 case IDM_PREVIOUS:
2601 if(*dcd->previous &&
2602 stricmp(dcd->directory,dcd->previous)) {
2603
2604 CHAR tempname[CCHMAXPATH];
2605
2606 if(IsValidDir(dcd->previous)) {
2607 strcpy(tempname,dcd->directory);
2608 strcpy(dcd->directory,dcd->previous);
2609 strcpy(dcd->previous,tempname);
2610 DosEnterCritSec();
2611 dcd->stopflag++;
2612 DosExitCritSec();
2613 if(!PostMsg(dcd->hwndObject,
2614 UM_RESCAN,
2615 MPVOID,
2616 MPFROMLONG(1L))) {
2617 strcpy(dcd->directory,dcd->previous);
2618 DosEnterCritSec();
2619 dcd->stopflag--;
2620 DosExitCritSec();
2621 }
2622 else if(*dcd->directory) {
2623 if(hwndMain)
2624 WinSendMsg(hwndMain,
2625 UM_SETUSERLISTNAME,
2626 MPFROMP(dcd->directory),
2627 MPVOID);
2628 else
2629 add_udir(FALSE,
2630 dcd->directory);
2631 }
2632 }
2633 else
2634 *dcd->previous = 0;
2635 }
2636 break;
2637
2638 case IDM_WALKDIR:
2639 {
2640 CHAR newdir[CCHMAXPATH];
2641
2642 strcpy(newdir,dcd->directory);
2643 if(!WinDlgBox(HWND_DESKTOP,
2644 dcd->hwndParent,
2645 WalkAllDlgProc,
2646 FM3ModHandle,
2647 WALK_FRAME,
2648 MPFROMP(newdir)) ||
2649 !*newdir)
2650 break;
2651 if(stricmp(newdir,dcd->directory)) {
2652 strcpy(dcd->previous,dcd->directory);
2653 strcpy(dcd->directory,newdir);
2654 DosEnterCritSec();
2655 dcd->stopflag++;
2656 DosExitCritSec();
2657 if(!PostMsg(dcd->hwndObject,
2658 UM_RESCAN,
2659 MPVOID,
2660 MPFROMLONG(1L))) {
2661 strcpy(dcd->directory,dcd->previous);
2662 DosEnterCritSec();
2663 dcd->stopflag--;
2664 DosExitCritSec();
2665 }
2666 else if(*dcd->directory) {
2667 if(hwndMain)
2668 WinSendMsg(hwndMain,
2669 UM_SETUSERLISTNAME,
2670 MPFROMP(dcd->directory),
2671 MPVOID);
2672 else
2673 add_udir(FALSE,
2674 dcd->directory);
2675 }
2676 }
2677 }
2678 break;
2679
2680 case IDM_OPENICONME:
2681 OpenObject(dcd->directory,
2682 "ICON",
2683 dcd->hwndFrame);
2684 break;
2685 case IDM_OPENDETAILSME:
2686 OpenObject(dcd->directory,
2687 "DETAILS",
2688 dcd->hwndFrame);
2689 break;
2690 case IDM_OPENTREEME:
2691 OpenObject(dcd->directory,
2692 "TREE",
2693 dcd->hwndFrame);
2694 break;
2695 case IDM_OPENSETTINGSME:
2696 OpenObject(dcd->directory,
2697 Settings,
2698 dcd->hwndFrame);
2699 break;
2700
2701 case IDM_DOITYOURSELF:
2702 case IDM_UPDATE:
2703 case IDM_OPENWINDOW:
2704 case IDM_OPENSETTINGS:
2705 case IDM_OPENDEFAULT:
2706 case IDM_OPENICON:
2707 case IDM_OPENDETAILS:
2708 case IDM_OPENTREE:
2709 case IDM_OBJECT:
2710 case IDM_SHADOW:
2711 case IDM_SHADOW2:
2712 case IDM_DELETE:
2713 case IDM_PERMDELETE:
2714 case IDM_PRINT:
2715 case IDM_ATTRS:
2716 case IDM_INFO:
2717 case IDM_COPY:
2718 case IDM_MOVE:
2719 case IDM_WPSMOVE:
2720 case IDM_WPSCOPY:
2721 case IDM_WILDCOPY:
2722 case IDM_WILDMOVE:
2723 case IDM_RENAME:
2724 case IDM_COMPARE:
2725 case IDM_EAS:
2726 case IDM_SUBJECT:
2727 case IDM_VIEW:
2728 case IDM_VIEWTEXT:
2729 case IDM_VIEWBINARY:
2730 case IDM_VIEWARCHIVE:
2731 case IDM_EDIT:
2732 case IDM_EDITTEXT:
2733 case IDM_EDITBINARY:
2734 case IDM_SAVETOCLIP:
2735 case IDM_APPENDTOCLIP:
2736 case IDM_ARCHIVE:
2737 case IDM_ARCHIVEM:
2738 case IDM_EXTRACT:
2739 case IDM_MCIPLAY:
2740 case IDM_COLLECTFROMFILE:
2741 case IDM_UUDECODE:
2742 case IDM_MERGE:
2743 {
2744 LISTINFO *li;
2745 ULONG action = UM_ACTION;
2746
2747 li = malloc(sizeof(LISTINFO));
2748 if(li) {
2749 memset(li,0,sizeof(LISTINFO));
2750 li->type = SHORT1FROMMP(mp1);
2751 li->hwnd = hwnd;
2752 li->list = BuildList(hwnd);
2753 switch(SHORT1FROMMP(mp1)) {
2754 case IDM_WILDMOVE:
2755 case IDM_WILDCOPY:
2756 case IDM_MOVE:
2757 case IDM_COPY:
2758 case IDM_WPSMOVE:
2759 case IDM_WPSCOPY:
2760 break;
2761 default:
2762 strcpy(li->targetpath,dcd->directory);
2763 break;
2764 }
2765 if(li->list) {
2766 if(SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2767 if(!Collector) {
2768
2769 HWND hwndC;
2770 SWP swp;
2771
2772 if(!ParentIsDesktop(hwnd,dcd->hwndParent) &&
2773 !fAutoTile &&
2774 (!fExternalCollector && !strcmp(realappname,FM3Str)))
2775 GetNextWindowPos(dcd->hwndParent,&swp,NULL,NULL);
2776 hwndC = StartCollector((fExternalCollector ||
2777 strcmp(realappname,FM3Str)) ?
2778 HWND_DESKTOP :
2779 dcd->hwndParent,4);
2780 if(hwndC) {
2781 if(!ParentIsDesktop(hwnd,dcd->hwndParent) &&
2782 !fAutoTile && (!fExternalCollector &&
2783 !strcmp(realappname,FM3Str)))
2784 WinSetWindowPos(hwndC,HWND_TOP,swp.x,swp.y,
2785 swp.cx,swp.cy,SWP_MOVE | SWP_SIZE |
2786 SWP_SHOW | SWP_ZORDER);
2787 else if(!ParentIsDesktop(hwnd,dcd->hwndParent) &&
2788 fAutoTile && !strcmp(realappname,FM3Str))
2789 TileChildren(dcd->hwndParent,TRUE);
2790 WinSetWindowPos(hwndC,HWND_TOP,0,0,0,0,SWP_ACTIVATE);
2791 DosSleep(250L);
2792 }
2793 }
2794 else
2795 StartCollector(dcd->hwndParent,4);
2796 }
2797 switch(SHORT1FROMMP(mp1)) {
2798 case IDM_APPENDTOCLIP:
2799 case IDM_SAVETOCLIP:
2800 case IDM_ARCHIVE:
2801 case IDM_ARCHIVEM:
2802 case IDM_DELETE:
2803 case IDM_PERMDELETE:
2804 case IDM_ATTRS:
2805 case IDM_PRINT:
2806 case IDM_SHADOW:
2807 case IDM_SHADOW2:
2808 case IDM_OBJECT:
2809 case IDM_VIEW:
2810 case IDM_VIEWTEXT:
2811 case IDM_VIEWBINARY:
2812 case IDM_EDIT:
2813 case IDM_EDITTEXT:
2814 case IDM_EDITBINARY:
2815 case IDM_MCIPLAY:
2816 case IDM_UPDATE:
2817 case IDM_DOITYOURSELF:
2818 case IDM_INFO:
2819 case IDM_EAS:
2820 action = UM_MASSACTION;
2821 break;
2822 }
2823 if(SHORT1FROMMP(mp1) == IDM_OBJECT ||
2824 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2825 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2826 *li->targetpath = 0;
2827 if(!PostMsg(dcd->hwndObject,
2828 action,
2829 MPFROMP(li),
2830 MPVOID)) {
2831 FreeListInfo(li);
2832 DosBeep(50,100);
2833 }
2834 else if(fUnHilite)
2835 UnHilite(hwnd,
2836 TRUE,
2837 &dcd->lastselection);
2838 }
2839 else
2840 free(li);
2841 }
2842 }
2843 break;
2844
2845 case IDM_DRIVESMENU:
2846 if(!hwndMain)
2847 PostMsg(hwnd,
2848 WM_COMMAND,
2849 MPFROM2SHORT(IDM_WALKDIR,0),
2850 MPVOID);
2851 break;
2852
2853 default:
2854 if(SwitchCommand(dcd->hwndLastMenu,
2855 SHORT1FROMMP(mp1)))
2856 return 0;
2857 else {
2858 if(SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2859 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2860
2861 register INT x;
2862
2863 if(!cmdloaded)
2864 load_commands();
2865 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2866 if(x >= 0) {
2867 x++;
2868 RunCommand(hwnd,x);
2869 if(fUnHilite)
2870 UnHilite(hwnd,
2871 TRUE,
2872 &dcd->lastselection);
2873 }
2874 }
2875 }
2876 break;
2877 }
2878 }
2879 return 0;
2880
2881 case UM_FIXCNRMLE:
2882 case UM_FIXEDITNAME:
2883 return CommonCnrProc(hwnd,msg,mp1,mp2);
2884
2885 case UM_FILESMENU:
2886 {
2887 PCNRITEM pci;
2888 HWND menuHwnd = (HWND)0;
2889
2890 pci = (PCNRITEM)CurrentRecord(hwnd);
2891 if(pci && (INT)pci != -1) {
2892 if(pci->attrFile & FILE_DIRECTORY) {
2893 menuHwnd = CheckMenu(&DirMenu,
2894 DIR_POPUP);
2895// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2896 }
2897 else
2898 menuHwnd = CheckMenu(&FileMenu,
2899 FILE_POPUP);
2900 }
2901 return MRFROMLONG(menuHwnd);
2902 }
2903
2904 case WM_CONTROL:
2905 DosError(FERR_DISABLEHARDERR);
2906 if(dcd) {
2907 switch(SHORT2FROMMP(mp1)) {
2908 case CN_COLLAPSETREE:
2909 case CN_EXPANDTREE:
2910 {
2911 PCNRITEM pci = (PCNRITEM)mp2;
2912
2913 if(pci &&
2914 (INT)pci != -1 &&
2915 !(pci->flags & RECFLAGS_ENV)) {
2916 if(driveflags[toupper(*pci->szFileName) - 'A'] &
2917 DRIVE_REMOVABLE) {
2918
2919 struct {
2920 ULONG serial;
2921 CHAR volumelength;
2922 CHAR volumelabel[CCHMAXPATH];
2923 } volser;
2924
2925 memset(&volser,0,sizeof(volser));
2926 DosError(FERR_DISABLEHARDERR);
2927 if(!DosQueryFSInfo(toupper(*pci->szFileName) - '@',
2928 FSIL_VOLSER,
2929 &volser,
2930 (ULONG)sizeof(volser))) {
2931 if(SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2932 !volser.serial ||
2933 driveserial[toupper(*pci->szFileName) - 'A'] !=
2934 volser.serial)
2935 UnFlesh(hwnd,pci);
2936 if(SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2937 (!volser.serial ||
2938 driveserial[toupper(*pci->szFileName) - 'A'] !=
2939 volser.serial)) {
2940 if(Flesh(hwnd,pci) &&
2941 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2942 !dcd->suspendview && fTopDir)
2943 PostMsg(hwnd,UM_TOPDIR,MPFROMP(pci),MPVOID);
2944 }
2945 driveserial[toupper(*pci->szFileName) - 'A'] =
2946 volser.serial;
2947 }
2948 else {
2949 driveserial[toupper(*pci->szFileName) - 'A'] = -1;
2950 UnFlesh(hwnd,pci);
2951 PostMsg(hwnd,
2952 UM_RESCAN,
2953 MPVOID,
2954 MPVOID);
2955 DosBeep(250,100);
2956 }
2957 }
2958 else if(SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2959 if(Flesh(hwnd,pci) &&
2960 !dcd->suspendview && fTopDir)
2961 PostMsg(hwnd,
2962 UM_TOPDIR,
2963 MPFROMP(pci),
2964 MPVOID);
2965 }
2966 if(SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2967 !dcd->suspendview)
2968 WinSendMsg(hwnd,
2969 UM_FILTER,
2970 MPVOID,
2971 MPVOID);
2972 }
2973 }
2974 break;
2975
2976/*
2977 case CN_PICKUP:
2978 return PickUp(hwnd,dcd->hwndObject,mp2);
2979*/
2980
2981 case CN_CONTEXTMENU:
2982 {
2983 PCNRITEM pci = (PCNRITEM)mp2;
2984
2985 if(pci) {
2986 WinSendMsg(hwnd,
2987 CM_SETRECORDEMPHASIS,
2988 MPFROMP(pci),
2989 MPFROM2SHORT(TRUE,CRA_CURSORED));
2990 MarkAll(hwnd,
2991 FALSE,
2992 FALSE,
2993 TRUE);
2994 if(pci->attrFile & FILE_DIRECTORY)
2995 dcd->hwndLastMenu = CheckMenu(&DirMenu,DIR_POPUP);
2996 else
2997 dcd->hwndLastMenu = CheckMenu(&FileMenu,FILE_POPUP);
2998 }
2999 else {
3000 dcd->hwndLastMenu = CheckMenu(&DirCnrMenu,DIRCNR_POPUP);
3001 if(dcd->hwndLastMenu && !dcd->cnremphasized) {
3002 WinSendMsg(hwnd,
3003 CM_SETRECORDEMPHASIS,
3004 MPVOID,
3005 MPFROM2SHORT(TRUE,CRA_SOURCE));
3006 dcd->cnremphasized = TRUE;
3007 }
3008 }
3009 if(dcd->hwndLastMenu) {
3010 if(dcd->hwndLastMenu == DirCnrMenu) {
3011 if(dcd->flWindowAttr & CV_MINI)
3012 WinCheckMenuItem(dcd->hwndLastMenu,
3013 IDM_MINIICONS,
3014 TRUE);
3015 }
3016 if(dcd->hwndLastMenu == DirMenu)
3017 WinEnableMenuItem(DirMenu,
3018 IDM_TREE,
3019 TRUE);
3020 if(!PopupMenu(hwnd,hwnd,dcd->hwndLastMenu)) {
3021 if(dcd->cnremphasized) {
3022 WinSendMsg(hwnd,
3023 CM_SETRECORDEMPHASIS,
3024 MPVOID,
3025 MPFROM2SHORT(FALSE,CRA_SOURCE));
3026 dcd->cnremphasized = TRUE;
3027 }
3028 MarkAll(hwnd,TRUE,FALSE,TRUE);
3029 }
3030 }
3031 }
3032 break;
3033
3034 case CN_DROPHELP:
3035 if(mp2) {
3036
3037 PDRAGINFO pDInfo;
3038 PCNRITEM pci;
3039 ULONG numitems;
3040 USHORT usOperation;
3041
3042 pci = (PCNRITEM)((PCNRDRAGINFO)mp2)->pRecord;
3043 pDInfo = (PDRAGINFO)((PCNRDRAGINFO)mp2)->pDragInfo;
3044 if(!DrgAccessDraginfo(pDInfo)) {
3045 General_Error(WinQueryAnchorBlock(hwnd),
3046 hwnd,
3047 __FILE__,
3048 __LINE__,
3049 "%s",
3050 GetPString(IDS_DROPERRORTEXT));
3051 break;
3052 }
3053 numitems = DrgQueryDragitemCount(pDInfo);
3054 usOperation = pDInfo->usOperation;
3055 DrgDeleteDraginfoStrHandles(pDInfo);
3056 DrgFreeDraginfo(pDInfo);
3057 saymsg(MB_ENTER | MB_ICONASTERISK,
3058 hwnd,
3059 GetPString(IDS_DROPHELPHDRTEXT),
3060 GetPString(IDS_DROPHELPTEXT),
3061 numitems,
3062 &"s"[numitems == 1L],
3063 (pci) ? NullStr : GetPString(IDS_NOTEXT),
3064 (pci) ? NullStr : " ",
3065 (pci) ? pci->szFileName : NullStr,
3066 (pci) ? " " : NullStr,
3067 GetPString((usOperation == DO_COPY) ?
3068 IDS_COPYTEXT :
3069 (usOperation == DO_LINK) ?
3070 IDS_LINKTEXT : IDS_MOVETEXT));
3071 }
3072 return 0;
3073
3074 case CN_DRAGLEAVE:
3075#ifdef NEVER
3076 if(mp2) {
3077
3078 PDRAGINFO pDInfo;
3079
3080 pDInfo = ((PCNRDRAGINFO)mp2)->pDragInfo;
3081 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
3082 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
3083 }
3084#endif
3085 return 0;
3086
3087 case CN_DRAGAFTER:
3088 case CN_DRAGOVER:
3089 if(mp2) {
3090
3091 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
3092 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
3093 PCNRITEM pci;
3094 USHORT uso;
3095
3096 pci = (PCNRITEM)((PCNRDRAGINFO)mp2)->pRecord;
3097 pDInfo = ((PCNRDRAGINFO)mp2)->pDragInfo;
3098 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
3099 if(*dcd->directory &&
3100 (driveflags[toupper(*dcd->directory) - 'A'] &
3101 DRIVE_NOTWRITEABLE)) {
3102 DrgFreeDraginfo(pDInfo);
3103 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
3104 DO_LINK); /* (compare) only */
3105 }
3106 if(pci) {
3107 if(pci->rc.flRecordAttr & CRA_SOURCE) {
3108 DrgFreeDraginfo(pDInfo);
3109 return(MRFROM2SHORT(DOR_NODROP,0));
3110 }
3111 uso = pDInfo->usOperation;
3112 if(uso == DO_DEFAULT)
3113 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
3114 if(!(pci->attrFile & FILE_DIRECTORY)) {
3115 if(uso != DO_LINK && uso != DO_COPY &&
3116 uso != DO_MOVE) {
3117 DrgFreeDraginfo(pDInfo);
3118 return MRFROM2SHORT(DOR_NODROP,0);
3119 }
3120 if(uso != DO_LINK &&
3121 !(driveflags[toupper(*pci->szFileName) - 'A'] &
3122 DRIVE_NOTWRITEABLE)) {
3123
3124 ARC_TYPE *info = NULL;
3125
3126 if(!fQuickArcFind &&
3127 !(driveflags[toupper(*pci->szFileName) - 'A'] &
3128 DRIVE_SLOW))
3129 info = find_type(pci->szFileName,NULL);
3130 else
3131 info = quick_find_type(pci->szFileName,NULL);
3132 if(!info || ((uso == DO_MOVE && !info->move) ||
3133 (uso == DO_COPY && !info->create))) {
3134 DrgFreeDraginfo(pDInfo);
3135 return MRFROM2SHORT(DOR_NODROP,0);
3136 }
3137 }
3138 }
3139 }
3140 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
3141 0); /* Index to DRAGITEM */
3142 if(DrgVerifyRMF(pDItem, /* Check valid rendering */
3143 DRM_OS2FILE, /* mechanisms and data */
3144 NULL) ||
3145 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
3146 DrgVerifyRMF(pDItem,
3147 DRM_FM2ARCMEMBER,
3148 DRF_FM2ARCHIVE))) { /* formats */
3149 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
3150 if(driveflags[toupper(*dcd->directory) - 'A'] &
3151 DRIVE_NOTWRITEABLE)
3152 return MRFROM2SHORT(DOR_DROP,DO_LINK);
3153 if(toupper(*dcd->directory) < 'C')
3154 return MRFROM2SHORT(DOR_DROP,DO_COPY);
3155 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
3156 ((fCopyDefault) ?
3157 DO_COPY :
3158 DO_MOVE));
3159 }
3160 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
3161 }
3162 return MRFROM2SHORT(DOR_NODROP,0); /* Drop not valid */
3163
3164 case CN_INITDRAG:
3165 {
3166 BOOL wasemphasized = FALSE;
3167 PCNRDRAGINIT pcd = (PCNRDRAGINIT)mp2;
3168 PCNRITEM pci;
3169
3170 if(pcd) {
3171 pci = (PCNRITEM)pcd->pRecord;
3172 if(pci) {
3173 if((INT)pci == -1)
3174 pci = NULL;
3175 else if(pci->rc.flRecordAttr & CRA_SELECTED)
3176 wasemphasized = TRUE;
3177 }
3178 else if(!*dcd->directory ||
3179 IsRoot(dcd->directory)) {
3180 DosBeep(50,100);
3181 break;
3182 }
3183 if(hwndStatus2) {
3184 if(pci)
3185 WinSetWindowText(hwndStatus2,
3186 GetPString(IDS_DRAGFILEOBJTEXT));
3187 else
3188 WinSetWindowText(hwndStatus2,
3189 GetPString(IDS_DRAGDIRTEXT));
3190 }
3191 if(DoFileDrag(hwnd,
3192 dcd->hwndObject,
3193 mp2,
3194 NULL,
3195 (pci) ? NULL : dcd->directory,
3196 (pci) ? TRUE : FALSE)) {
3197 if(pci && fUnHilite && wasemphasized)
3198 UnHilite(hwnd,
3199 TRUE,
3200 &dcd->lastselection);
3201 }
3202 if(hwndStatus2) {
3203 WinSetFocus(HWND_DESKTOP,hwnd);
3204 PostMsg(hwnd,
3205 UM_RESCAN,
3206 MPVOID,
3207 MPVOID);
3208 }
3209 }
3210 }
3211 return 0;
3212
3213 case CN_DROP:
3214 if(mp2) {
3215
3216 LISTINFO *li;
3217 ULONG action = UM_ACTION;
3218
3219 li = DoFileDrop(hwnd,dcd->directory,TRUE,mp1,mp2);
3220 if(li) {
3221 if(li->list && li->list[0] && IsRoot(li->list[0]))
3222 li->type = DO_LINK;
3223 else if(fDragndropDlg && (!*li->arcname || !li->info)) {
3224
3225 CHECKLIST cl;
3226
3227 memset(&cl,0,sizeof(cl));
3228 cl.size = sizeof(cl);
3229 cl.flags = li->type;
3230 cl.list = li->list;
3231 cl.cmd = li->type;
3232 cl.prompt = li->targetpath;
3233 li->type = WinDlgBox(HWND_DESKTOP,dcd->hwndParent,
3234 DropListProc,FM3ModHandle,
3235 DND_FRAME,MPFROMP(&cl));
3236 if(!li->type) {
3237 FreeListInfo(li);
3238 return 0;
3239 }
3240 li->list = cl.list;
3241 if(!li->list || !li->list[0]) {
3242 FreeListInfo(li);
3243 return 0;
3244 }
3245 }
3246 switch(li->type) {
3247 case DND_LAUNCH:
3248 strcat(li->targetpath," %a");
3249 ExecOnList(dcd->hwndParent,li->targetpath,
3250 PROMPT | WINDOWED,NULL,li->list,NULL);
3251 FreeList(li->list);
3252 li->list = NULL;
3253 break;
3254 case DO_LINK:
3255 if(fLinkSetsIcon) {
3256 li->type = IDM_SETICON;
3257 action = UM_MASSACTION;
3258 }
3259 else
3260 li->type = IDM_COMPARE;
3261 break;
3262 case DND_EXTRACT:
3263 if(*li->targetpath && !IsFile(li->targetpath))
3264 li->type = IDM_EXTRACT;
3265 break;
3266 case DND_MOVE:
3267 li->type = IDM_MOVE;
3268 if(*li->targetpath && IsFile(li->targetpath) == 1) {
3269 action = UM_MASSACTION;
3270 li->type = IDM_ARCHIVEM;
3271 }
3272 break;
3273 case DND_WILDMOVE:
3274 li->type = IDM_WILDMOVE;
3275 if(*li->targetpath && IsFile(li->targetpath) == 1) {
3276 action = UM_MASSACTION;
3277 li->type = IDM_ARCHIVEM;
3278 }
3279 break;
3280 case DND_OBJECT:
3281 li->type = IDM_OBJECT;
3282 action = UM_MASSACTION;
3283 break;
3284 case DND_SHADOW:
3285 li->type = IDM_SHADOW;
3286 action = UM_MASSACTION;
3287 break;
3288 case DND_COMPARE:
3289 li->type = IDM_COMPARE;
3290 break;
3291 case DND_SETICON:
3292 action = UM_MASSACTION;
3293 li->type = IDM_SETICON;
3294 break;
3295 case DND_COPY:
3296 li->type = IDM_COPY;
3297 if(*li->targetpath && IsFile(li->targetpath) == 1) {
3298 action = UM_MASSACTION;
3299 li->type = IDM_ARCHIVE;
3300 }
3301 break;
3302 case DND_WILDCOPY:
3303 li->type = IDM_WILDCOPY;
3304 if(*li->targetpath && IsFile(li->targetpath) == 1) {
3305 action = UM_MASSACTION;
3306 li->type = IDM_ARCHIVE;
3307 }
3308 break;
3309 default:
3310 if(*li->arcname && li->info) {
3311 action = UM_MASSACTION;
3312 li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
3313 }
3314 else if(*li->targetpath && IsFile(li->targetpath) == 1) {
3315 action = UM_MASSACTION;
3316 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
3317 }
3318 else
3319 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
3320 break;
3321 }
3322 if(!li->list || !li->list[0])
3323 FreeListInfo(li);
3324 else if(!PostMsg(dcd->hwndObject,action,MPFROMP(li),MPVOID))
3325 FreeListInfo(li);
3326 else {
3327
3328 USHORT usop = 0;
3329
3330 switch(li->type) {
3331 case IDM_COPY:
3332 case IDM_WILDCOPY:
3333 usop = DO_COPY;
3334 break;
3335 case IDM_MOVE:
3336 case IDM_WILDMOVE:
3337 case IDM_ARCHIVEM:
3338 usop = DO_MOVE;
3339 break;
3340 }
3341 if(usop)
3342 return MRFROM2SHORT(DOR_DROP,usop);
3343 }
3344 }
3345 }
3346 return 0;
3347
3348 case CN_ENDEDIT:
3349 case CN_BEGINEDIT:
3350 {
3351 PFIELDINFO pfi = ((PCNREDITDATA)mp2)->pFieldInfo;
3352 PCNRITEM pci = (PCNRITEM)((PCNREDITDATA)mp2)->pRecord;
3353
3354 if(pfi || pci) {
3355
3356 MRESULT mre;
3357
3358 mre = CnrDirectEdit(hwnd,msg,mp1,mp2);
3359 if(mre != (MRESULT)-1)
3360 return mre;
3361 }
3362 else if(!pfi && !pci)
3363 PostMsg(hwnd,
3364 UM_FIXCNRMLE,
3365 MPFROMLONG(CCHMAXPATH),
3366 MPVOID);
3367 }
3368 return 0;
3369
3370 case CN_REALLOCPSZ:
3371 {
3372 PFIELDINFO pfi = ((PCNREDITDATA)mp2)->pFieldInfo;
3373 PCNRITEM pci = (PCNRITEM)((PCNREDITDATA)mp2)->pRecord;
3374 HWND hwndMLE;
3375 static CHAR szData[CCHMAXPATH];
3376 CHAR testname[CCHMAXPATH],*p;
3377
3378 if(!pci && !pfi) {
3379 hwndMLE = WinWindowFromID(hwnd,CID_MLE);
3380 WinQueryWindowText(hwndMLE,
3381 sizeof(szData),
3382 szData);
3383 p = strchr(szData,'\n');
3384 if(p)
3385 *p = 0;
3386 p = strchr(szData,'\r');
3387 if(p)
3388 *p = 0;
3389 lstrip(rstrip(szData));
3390 if(*szData) {
3391 if(!DosQueryPathInfo(szData,
3392 FIL_QUERYFULLNAME,
3393 testname,
3394 sizeof(testname))) {
3395 if(!SetDir(dcd->hwndParent,
3396 hwnd,
3397 testname,
3398 1))
3399 PostMsg(hwnd,
3400 UM_SETDIR,
3401 MPFROMP(testname),
3402 MPVOID);
3403 }
3404 }
3405 }
3406 else {
3407
3408 MRESULT mre;
3409
3410 mre = CnrDirectEdit(hwnd,msg,mp1,mp2);
3411 if(mre != (MRESULT)-1)
3412 return mre;
3413 }
3414 }
3415 return 0;
3416
3417 case CN_EMPHASIS:
3418 if(mp2) {
3419
3420 PNOTIFYRECORDEMPHASIS pre = mp2;
3421 PCNRITEM pci;
3422 CHAR s[CCHMAXPATHCOMP + 91],tb[81],tf[81],
3423 *tbk;
3424
3425 pci = (PCNRITEM)((pre) ? pre->pRecord : NULL);
3426 if(!pci) {
3427 if(hwndStatus2)
3428 WinSetWindowText(hwndStatus2,NullStr);
3429 if(fMoreButtons) {
3430 WinSetWindowText(hwndName,NullStr);
3431 WinSetWindowText(hwndDate,NullStr);
3432 WinSetWindowText(hwndAttr,NullStr);
3433 }
3434 if(hwndMain)
3435 WinSendMsg(hwndMain,
3436 UM_LOADFILE,
3437 MPVOID,
3438 MPVOID);
3439 break;
3440 }
3441 if(pre->fEmphasisMask & CRA_SELECTED) {
3442 if(pci->rc.flRecordAttr & CRA_SELECTED) {
3443 dcd->selectedbytes += (pci->cbFile + pci->easize);
3444 dcd->selectedfiles++;
3445 }
3446 else if(dcd->selectedfiles) {
3447 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3448 dcd->selectedfiles--;
3449 }
3450 if(!dcd->suspendview) {
3451 commafmt(tf,sizeof(tf),dcd->selectedfiles);
3452 if(dcd->selectedbytes > 1024) {
3453 tbk = "k";
3454 commafmt(tb,sizeof(tb),dcd->selectedbytes / 1024L);
3455 }
3456 else {
3457 tbk = "b";
3458 commafmt(tb,sizeof(tb),dcd->selectedbytes);
3459 }
3460 sprintf(s,"%s / %s%s",tf,tb,tbk);
3461 WinSetDlgItemText(dcd->hwndClient,DIR_SELECTED,s);
3462 }
3463 }
3464 if(!dcd->suspendview && hwndMain &&
3465 (pre->fEmphasisMask & CRA_CURSORED) &&
3466 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3467 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3468 if(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_SLOW)
3469 WinSendMsg(hwndMain,
3470 UM_LOADFILE,
3471 MPVOID,
3472 MPVOID);
3473 else
3474 WinSendMsg(hwndMain,
3475 UM_LOADFILE,
3476 MPFROMP(pci->szFileName),
3477 MPVOID);
3478 }
3479 if(!dcd->suspendview &&
3480 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3481 if(pre->fEmphasisMask & CRA_CURSORED) {
3482 if(pci->rc.flRecordAttr & CRA_CURSORED) {
3483 if(fSplitStatus && hwndStatus2) {
3484 commafmt(tb,sizeof(tb),pci->cbFile + pci->easize);
3485 if(!fMoreButtons)
3486 sprintf(s," %sb %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
3487 tb,pci->date.year,
3488 pci->date.month,pci->date.day,pci->time.hours,
3489 pci->time.minutes,pci->time.seconds,
3490 pci->pszDispAttr,pci->pszFileName);
3491 else {
3492 *tf = 0;
3493 if(pci->cbFile + pci->easize > 1024)
3494 commafmt(tf,sizeof(tf),
3495 (pci->cbFile + pci->easize) / 1024);
3496 sprintf(s,GetPString(IDS_STATUSSIZETEXT),
3497 tb,
3498 (*tf) ? " (" : NullStr,
3499 tf,
3500 (*tf) ? "k)" : NullStr);
3501 }
3502 WinSetWindowText(hwndStatus2,s);
3503 }
3504 if(fMoreButtons) {
3505 WinSetWindowText(hwndName,pci->pszFileName);
3506 sprintf(s,"%04u/%02u/%02u %02u:%02u:%02u",
3507 pci->date.year,pci->date.month,
3508 pci->date.day,pci->time.hours,pci->time.minutes,
3509 pci->time.seconds);
3510 WinSetWindowText(hwndDate,s);
3511 WinSetWindowText(hwndAttr,pci->pszDispAttr);
3512 }
3513 }
3514 }
3515 }
3516 }
3517 else
3518 DosBeep(2000,100);
3519 break;
3520
3521 case CN_ENTER:
3522 if(mp2) {
3523
3524 PCNRITEM pci = (PCNRITEM)((PNOTIFYRECORDENTER)mp2)->pRecord;
3525 FILEFINDBUF3 ffb;
3526 HDIR hDir = HDIR_CREATE;
3527 ULONG nm = 1L;
3528 APIRET status = 0;
3529
3530 SetShiftState();
3531 if(pci) {
3532 if(pci->rc.flRecordAttr & CRA_INUSE)
3533 break;
3534 DosError(FERR_DISABLEHARDERR);
3535 status = DosFindFirst(pci->szFileName,
3536 &hDir,
3537 FILE_NORMAL | FILE_DIRECTORY |
3538 FILE_ARCHIVED | FILE_READONLY |
3539 FILE_HIDDEN | FILE_SYSTEM,
3540 &ffb,
3541 sizeof(ffb),
3542 &nm,
3543 FIL_STANDARD);
3544 priority_bumped();
3545 if(!status) {
3546 DosFindClose(hDir);
3547 if(ffb.attrFile & FILE_DIRECTORY) {
3548 if((shiftstate & (KC_CTRL | KC_ALT)) ==
3549 (KC_CTRL | KC_ALT))
3550 PostMsg(hwnd,
3551 WM_COMMAND,
3552 MPFROM2SHORT(IDM_SHOWALLFILES,0),
3553 MPVOID);
3554 else if((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3555 (KC_CTRL | KC_SHIFT))
3556 OpenObject(pci->szFileName,
3557 Settings,
3558 dcd->hwndFrame);
3559 else if(shiftstate & KC_CTRL)
3560 OpenObject(pci->szFileName,
3561 Default,
3562 dcd->hwndFrame);
3563 else if(shiftstate & KC_SHIFT) {
3564
3565 HWND hwndDir;
3566
3567 hwndDir = OpenDirCnr((HWND)0,
3568 dcd->hwndParent,
3569 dcd->hwndFrame,
3570 FALSE,
3571 pci->szFileName);
3572 if(hwndDir) {
3573 if(fMinOnOpen)
3574 WinSetWindowPos(dcd->hwndFrame,
3575 HWND_BOTTOM,
3576 0,
3577 0,
3578 0,
3579 0,
3580 SWP_MINIMIZE | SWP_ZORDER);
3581 if(fAutoTile)
3582 TileChildren(dcd->hwndParent,
3583 TRUE);
3584 WinSetWindowPos(hwndDir,
3585 HWND_TOP,
3586 0,
3587 0,
3588 0,
3589 0,
3590 SWP_ACTIVATE);
3591 }
3592 }
3593 else {
3594 strcpy(dcd->previous,dcd->directory);
3595 strcpy(dcd->directory,pci->szFileName);
3596 DosEnterCritSec();
3597 dcd->stopflag++;
3598 DosExitCritSec();
3599 if(!PostMsg(dcd->hwndObject,
3600 UM_RESCAN,
3601 MPVOID,
3602 MPFROMLONG(1L))) {
3603 DosEnterCritSec();
3604 dcd->stopflag--;
3605 DosExitCritSec();
3606 }
3607 else if(*dcd->directory) {
3608 if(hwndMain)
3609 WinSendMsg(hwndMain,
3610 UM_SETUSERLISTNAME,
3611 MPFROMP(dcd->directory),
3612 MPVOID);
3613 else
3614 add_udir(FALSE,
3615 dcd->directory);
3616 }
3617 }
3618 }
3619 else {
3620
3621 SWP swp;
3622
3623 WinQueryWindowPos(dcd->hwndFrame,&swp);
3624 WinSendMsg(hwnd,
3625 CM_SETRECORDEMPHASIS,
3626 MPFROMP(pci),
3627 MPFROM2SHORT(TRUE,CRA_INUSE));
3628 DefaultViewKeys(hwnd,
3629 dcd->hwndFrame,
3630 dcd->hwndParent,
3631 &swp,
3632 pci->szFileName);
3633 WinSendMsg(hwnd,
3634 CM_SETRECORDEMPHASIS,
3635 MPFROMP(pci),
3636 MPFROM2SHORT(FALSE,
3637 CRA_INUSE |
3638 ((fUnHilite) ?
3639 CRA_SELECTED :
3640 0)));
3641 }
3642 }
3643 else {
3644 if(!*dcd->directory ||
3645 IsValidDir(dcd->directory)) {
3646 NotifyError(pci->szFileName,
3647 status);
3648 WinSendMsg(hwnd,
3649 CM_REMOVERECORD,
3650 MPFROMP(&pci),
3651 MPFROM2SHORT(1,
3652 CMA_FREE | CMA_INVALIDATE |
3653 CMA_ERASE));
3654 if(hwndStatus)
3655 WinSetWindowText(hwndStatus,
3656 GetPString(IDS_RESCANSUGGESTEDTEXT));
3657 }
3658 else {
3659 DosEnterCritSec();
3660 dcd->stopflag++;
3661 DosExitCritSec();
3662 if(!PostMsg(dcd->hwndObject,
3663 UM_RESCAN,
3664 MPVOID,
3665 MPFROMLONG(1L))) {
3666 DosEnterCritSec();
3667 dcd->stopflag--;
3668 DosExitCritSec();
3669 }
3670 else if(*dcd->directory) {
3671 if(hwndMain)
3672 WinSendMsg(hwndMain,
3673 UM_SETUSERLISTNAME,
3674 MPFROMP(dcd->directory),
3675 MPVOID);
3676 else
3677 add_udir(FALSE,
3678 dcd->directory);
3679 }
3680 }
3681 }
3682 }
3683 else if(*dcd->directory)
3684 OpenObject(dcd->directory,
3685 Default,
3686 hwnd);
3687 }
3688 break;
3689 }
3690 break;
3691 }
3692 return 0;
3693
3694 case UM_LOADFILE:
3695 if(dcd && mp2) {
3696
3697 HWND ret;
3698
3699 ret = StartMLEEditor(dcd->hwndParent,
3700 (INT)mp1,
3701 (CHAR *)mp2,
3702 dcd->hwndFrame);
3703 if(mp2)
3704 free((CHAR *)mp2);
3705 return MRFROMLONG(ret);
3706 }
3707 return 0;
3708
3709 case WM_SAVEAPPLICATION:
3710 if(dcd &&
3711 ParentIsDesktop(hwnd,dcd->hwndParent)) {
3712
3713 SWP swp;
3714
3715 WinQueryWindowPos(dcd->hwndFrame,&swp);
3716 if(!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3717 PrfWriteProfileData(fmprof,
3718 appname,
3719 "VDirSizePos",
3720 &swp,
3721 sizeof(swp));
3722 }
3723 break;
3724
3725 case WM_CLOSE:
3726 WinSendMsg(hwnd,
3727 WM_SAVEAPPLICATION,
3728 MPVOID,
3729 MPVOID);
3730 if(LastDir == hwnd)
3731 LastDir = (HWND)0;
3732 if(dcd) {
3733 dcd->stopflag++;
3734 if(!dcd->dontclose &&
3735 ParentIsDesktop(dcd->hwndFrame,(HWND)0))
3736 PostMsg((HWND)0,
3737 WM_QUIT,
3738 MPVOID,
3739 MPVOID);
3740 if(!dcd->hwndObject ||
3741 !PostMsg(dcd->hwndObject,
3742 WM_CLOSE,
3743 MPVOID,
3744 MPVOID)) {
3745 if(dcd->hwndObject)
3746 WinSetWindowPtr(dcd->hwndObject,
3747 0,
3748 NULL);
3749 WinSetWindowPtr(hwnd,
3750 0,
3751 NULL);
3752 if(dcd->hwndRestore)
3753 WinSetWindowPos(dcd->hwndRestore,
3754 HWND_TOP,
3755 0,
3756 0,
3757 0,
3758 0,
3759 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE |
3760 SWP_ZORDER);
3761 FreeList(dcd->lastselection);
3762 free(dcd);
3763 DosPostEventSem(CompactSem);
3764 }
3765 }
3766 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),
3767 QW_PARENT));
3768 return 0;
3769
3770 case WM_DESTROY:
3771 if(DirMenu)
3772 WinDestroyWindow(DirMenu);
3773 if(DirCnrMenu)
3774 WinDestroyWindow(DirCnrMenu);
3775 if(FileMenu)
3776 WinDestroyWindow(FileMenu);
3777 DirMenu = DirCnrMenu = FileMenu = (HWND)0;
3778 EmptyCnr(hwnd);
3779 break;
3780 }
3781 return (dcd && dcd->oldproc) ? dcd->oldproc(hwnd,msg,mp1,mp2) :
3782 PFNWPCnr(hwnd,msg,mp1,mp2);
3783}
3784
3785
3786HWND StartDirCnr (HWND hwndParent,CHAR *directory,HWND hwndRestore,
3787 ULONG flags) {
3788
3789 /* bitmapped flags:
3790 * 0x00000001 = don't close app when window closes
3791 * 0x00000002 = no frame controls
3792 */
3793
3794 HWND hwndFrame = (HWND)0,hwndClient;
3795 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3796 FCF_SIZEBORDER | FCF_MINMAX |
3797 FCF_ICON | FCF_NOBYTEALIGN |
3798 FCF_ACCELTABLE;
3799 USHORT id;
3800 static USHORT idinc = 0;
3801 DIRCNRDATA *dcd;
3802 static BOOL first = FALSE;
3803
3804 if(flags & 2)
3805 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3806 FCF_MINMAX | FCF_ICON));
3807 if(!idinc)
3808 idinc = (rand() % 100);
3809 if(!hwndParent)
3810 hwndParent = HWND_DESKTOP;
3811 if(ParentIsDesktop(hwndParent,hwndParent))
3812 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3813 if(!hwndMain && !first) {
3814 if(DirCnrMenu) {
3815
3816 MENUITEM mi;
3817
3818 memset(&mi,0,sizeof(mi));
3819 WinSendMsg(DirCnrMenu,
3820 MM_DELETEITEM,
3821 MPFROM2SHORT(IDM_DRIVESMENU,FALSE),
3822 MPVOID);
3823 mi.iPosition = MIT_END;
3824 mi.afStyle = MIS_TEXT;
3825 mi.id = IDM_DRIVESMENU;
3826 WinSendMsg(DirCnrMenu,
3827 MM_INSERTITEM,
3828 MPFROMP(&mi),
3829 MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3830 }
3831 first = TRUE;
3832 }
3833 if(directory) {
3834 hwndFrame = WinCreateStdWindow(hwndParent,
3835 WS_VISIBLE,
3836 &FrameFlags,
3837 GetPString(IDS_WCDIRCONTAINER),
3838 NULL,
3839 WS_VISIBLE | fwsAnimate,
3840 FM3ModHandle,
3841 DIR_FRAME,
3842 &hwndClient);
3843 if(hwndFrame && hwndClient) {
3844 id = DIR_FRAME + idinc++;
3845 if(idinc > 99)
3846 idinc = 0;
3847 WinSetWindowUShort(hwndFrame,QWS_ID,id);
3848 dcd = malloc(sizeof(DIRCNRDATA));
3849 if(dcd) {
3850 memset(dcd,0,sizeof(DIRCNRDATA));
3851 dcd->size = sizeof(DIRCNRDATA);
3852 dcd->id = id;
3853 dcd->type = DIR_FRAME;
3854 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3855 dcd->hwndFrame = hwndFrame;
3856 dcd->hwndClient = hwndClient;
3857 dcd->hwndRestore = hwndRestore;
3858 dcd->dontclose = ((flags & 1) != 0);
3859 strcpy(dcd->directory,directory);
3860 add_udir(FALSE,directory);
3861 {
3862 PFNWP oldproc;
3863
3864 oldproc = WinSubclassWindow(hwndFrame,
3865 (PFNWP)DirFrameWndProc);
3866 WinSetWindowPtr(hwndFrame,
3867 0,
3868 (PVOID)oldproc);
3869 }
3870 dcd->hwndCnr = WinCreateWindow(hwndClient,
3871 WC_CONTAINER,
3872 NULL,
3873 CCS_AUTOPOSITION | CCS_MINIICONS |
3874 CCS_MINIRECORDCORE | ulCnrType |
3875 WS_VISIBLE,
3876 0,
3877 0,
3878 0,
3879 0,
3880 hwndClient,
3881 HWND_TOP,
3882 (ULONG)DIR_CNR,
3883 NULL,
3884 NULL);
3885 if(dcd->hwndCnr) {
3886 WinSetWindowPtr(dcd->hwndCnr,0,(PVOID)dcd);
3887 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3888 (PFNWP)DirCnrWndProc);
3889 {
3890 USHORT ids[] = {DIR_TOTALS,DIR_SELECTED,DIR_VIEW,DIR_SORT,
3891 DIR_FILTER,DIR_FOLDERICON,DIR_MAX,0};
3892
3893 if(!(flags & 2))
3894 ids[6] = 0;
3895 CommonCreateTextChildren(dcd->hwndClient,
3896 GetPString(IDS_WCDIRSTATUS),
3897 ids);
3898 }
3899 if(!PostMsg(dcd->hwndCnr,
3900 UM_SETUP,
3901 MPVOID,
3902 MPVOID))
3903 WinSendMsg(dcd->hwndCnr,
3904 UM_SETUP,
3905 MPVOID,
3906 MPVOID);
3907 if(FrameFlags & FCF_TASKLIST) {
3908
3909 SWP swp,swpD;
3910 ULONG size = sizeof(swp);
3911 LONG cxScreen,cyScreen;
3912
3913 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame),0,&swp);
3914 if(PrfQueryProfileData(fmprof,
3915 appname,
3916 "VDirSizePos",
3917 &swpD,
3918 &size)) {
3919 cxScreen = WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN);
3920 cyScreen = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN);
3921 if(swp.x + swpD.cx > cxScreen)
3922 swp.x = cxScreen - swpD.cx;
3923 if(swp.y + swpD.cy > cyScreen)
3924 swp.y = cyScreen - swpD.cy;
3925 swp.cx = swpD.cx;
3926 swp.cy = swpD.cy;
3927 }
3928 WinSetWindowPos(hwndFrame,
3929 HWND_TOP,
3930 swp.x,
3931 swp.y,
3932 swp.cx,
3933 swp.cy,
3934 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3935 SWP_ACTIVATE);
3936 }
3937 }
3938 else {
3939 PostMsg(hwndClient,
3940 WM_CLOSE,
3941 MPVOID,
3942 MPVOID);
3943 free(dcd);
3944 hwndFrame = (HWND)0;
3945 }
3946 }
3947 else {
3948 PostMsg(hwndClient,
3949 WM_CLOSE,
3950 MPVOID,
3951 MPVOID);
3952 hwndFrame = (HWND)0;
3953 }
3954 }
3955 }
3956 return hwndFrame;
3957}
3958
Note: See TracBrowser for help on using the repository browser.