source: trunk/dll/dircnrs.c@ 687

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

Add CheckPmDrgLimit function to fix crash when dragging to FM/2 for other apps

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