source: trunk/dll/dircnrs.c@ 551

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

Indentation cleanup

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