source: trunk/dll/dircnrs.c@ 552

Last change on this file since 552 was 552, checked in by Gregg Young, 19 years ago

font cleanup; new image and archiver masks; messages moved to string file; new drive flags including David's icons mostly working

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