source: trunk/dll/dircnrs.c@ 688

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

Update History and file headers for CheckPmDrgLimit etc changes

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