source: trunk/dll/dircnrs.c@ 689

Last change on this file since 689 was 689, checked in by Steven Levine, 18 years ago

Commit OpenWatcom compatibility updates

  • 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 689 2007-06-15 06:33:24Z stevenhl $
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#include <process.h> // _beginthread
50
51#pragma data_seg(DATA1)
52#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
53#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
54#pragma alloc_text(STARTUP,StartDirCnr)
55
56static PSZ pszSrcFile = __FILE__;
57
58MRESULT EXPENTRY DirFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
59{
60 return CommonFrameWndProc(DIR_CNR, hwnd, msg, mp1, mp2);
61}
62
63MRESULT EXPENTRY DirTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
64{
65 static BOOL emphasized = FALSE;
66 static HWND hwndButtonPopup = (HWND) 0;
67 static USHORT lastid = 0;
68 static ULONG timestamp = ULONG_MAX;
69
70 switch (msg) {
71 case WM_CREATE:
72 return CommonTextProc(hwnd, msg, mp1, mp2);
73
74 case WM_COMMAND:
75 {
76 DIRCNRDATA *dcd;
77 MRESULT mr;
78
79 mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
80 QW_PARENT),
81 DIR_CNR), msg, mp1, mp2);
82 if (hwndButtonPopup &&
83 SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
84 SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
85 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
86 QW_PARENT),
87 DIR_CNR), QWL_USER);
88 if (dcd)
89 SetDetailsSwitches(hwndButtonPopup, dcd);
90 }
91 return mr;
92 }
93
94 case UM_CONTEXTMENU:
95 case WM_CONTEXTMENU:
96 {
97 USHORT id;
98
99 id = WinQueryWindowUShort(hwnd, QWS_ID);
100 switch (id) {
101 case DIR_FOLDERICON:
102 if (fNoFoldMenu) {
103 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
104 DIR_CNR),
105 WM_COMMAND, MPFROM2SHORT(IDM_PREVIOUS, 0), mp2);
106 break;
107 }
108 /* else intentional fallthru */
109 case DIR_SELECTED:
110 case DIR_VIEW:
111 case DIR_SORT:
112 {
113 POINTL ptl = { 0, 0 };
114 SWP swp;
115 DIRCNRDATA *dcd;
116
117 if (hwndButtonPopup)
118 WinDestroyWindow(hwndButtonPopup);
119 if (id == DIR_SELECTED && msg == WM_CONTEXTMENU)
120 id = DIR_MAX;
121 if (id == lastid) {
122
123 ULONG check;
124
125 DosQuerySysInfo(QSV_MS_COUNT,
126 QSV_MS_COUNT, &check, sizeof(check));
127 if (check < timestamp + 500) {
128 lastid = 0;
129 goto MenuAbort;
130 }
131 }
132 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
133 if (hwndButtonPopup) {
134 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
135 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
136 QW_PARENT),
137 DIR_CNR), QWL_USER);
138 if (id == DIR_SORT) { /* don't have sort pathname in dirs */
139 WinSendMsg(hwndButtonPopup,
140 MM_DELETEITEM,
141 MPFROM2SHORT(IDM_SORTNAME, FALSE), MPVOID);
142 WinSendMsg(hwndButtonPopup,
143 MM_DELETEITEM,
144 MPFROM2SHORT(IDM_SORTNONE, FALSE), MPVOID);
145 if (dcd)
146 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
147 }
148 else if (id == DIR_VIEW) {
149 if (dcd) {
150 SetViewMenu(hwndButtonPopup, dcd->flWindowAttr);
151 SetDetailsSwitches(hwndButtonPopup, dcd);
152 }
153 }
154 else if (id == DIR_MAX) {
155
156 int x;
157 BOOL enable;
158 USHORT ids[] = { IDM_SELECTBOTH,
159 IDM_SELECTMORE,
160 IDM_SELECTONE,
161 IDM_SELECTNEWER,
162 IDM_SELECTOLDER,
163 IDM_SELECTBIGGER,
164 IDM_SELECTSMALLER,
165 IDM_DESELECTBOTH,
166 IDM_DESELECTMORE,
167 IDM_DESELECTONE,
168 IDM_DESELECTNEWER,
169 IDM_DESELECTOLDER,
170 IDM_DESELECTBIGGER,
171 IDM_DESELECTSMALLER,
172 0
173 };
174
175 enable = (CountDirCnrs(dcd->hwndParent) > 1);
176 for (x = 0; ids[x]; x++)
177 WinEnableMenuItem(hwndButtonPopup, ids[x], enable);
178 }
179 else if (id == DIR_SELECTED) {
180 if (dcd)
181 WinEnableMenuItem(hwndButtonPopup,
182 IDM_RESELECT, (dcd->lastselection != NULL));
183 }
184 ptl.x = 0;
185 if (WinPopupMenu(HWND_OBJECT,
186 HWND_OBJECT,
187 hwndButtonPopup, -32767, -32767, 0, 0)) {
188 WinQueryWindowPos(hwndButtonPopup, &swp);
189 ptl.y = -(swp.cy + 2);
190 }
191 else {
192 WinQueryWindowPos(hwnd, &swp);
193 ptl.y = swp.cy + 2;
194 }
195 if (WinPopupMenu(hwnd,
196 hwnd,
197 hwndButtonPopup,
198 ptl.x,
199 ptl.y,
200 0,
201 PU_HCONSTRAIN | PU_VCONSTRAIN |
202 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
203 CenterOverWindow(hwndButtonPopup);
204 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
205 }
206 }
207 }
208 break;
209 default:
210 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), DIR_CNR),
211 WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU), MPVOID);
212 break;
213 }
214 } // case WM_CONTENT_MENU
215
216 MenuAbort:
217
218 if (msg == UM_CONTEXTMENU)
219 return 0;
220 break;
221
222 case WM_MENUEND:
223 if (hwndButtonPopup == (HWND) mp2) {
224 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
225 WinDestroyWindow(hwndButtonPopup);
226 hwndButtonPopup = (HWND) 0;
227 DosQuerySysInfo(QSV_MS_COUNT,
228 QSV_MS_COUNT, &timestamp, sizeof(timestamp));
229 switch (lastid) {
230 case DIR_VIEW:
231 case DIR_SORT:
232 case DIR_FOLDERICON:
233 case DIR_SELECTED:
234 case DIR_MAX:
235 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
236 break;
237 }
238 }
239 break;
240
241 case WM_BUTTON3DOWN:
242 case WM_BUTTON1DOWN:
243 case WM_BUTTON3UP:
244 case WM_BUTTON1UP:
245 {
246 USHORT id;
247
248 id = WinQueryWindowUShort(hwnd, QWS_ID);
249 switch (id) {
250 case DIR_FILTER:
251 case DIR_VIEW:
252 case DIR_SORT:
253 case DIR_SELECTED:
254 case DIR_FOLDERICON:
255 case DIR_MAX:
256 return CommonTextButton(hwnd, msg, mp1, mp2);
257 }
258 }
259 break;
260
261 case WM_BUTTON1DBLCLK:
262 {
263 NOTIFYRECORDENTER nr;
264
265 memset(&nr, 0, sizeof(NOTIFYRECORDENTER));
266 nr.hwndCnr = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), DIR_CNR);
267 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
268 WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_ENTER), MPFROMP(&nr));
269 }
270 break;
271
272 case WM_MOUSEMOVE:
273 {
274 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
275 char *s = NULL;
276
277 if (fOtherHelp) {
278 if ((!hwndBubble ||
279 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
280 !WinQueryCapture(HWND_DESKTOP)) {
281 switch (id) {
282 case DIR_TOTALS:
283 s = GetPString(IDS_DIRCNRTOTALHELP);
284 break;
285 case DIR_SELECTED:
286 s = GetPString(IDS_DIRCNRSELECTEDHELP);
287 break;
288 case DIR_VIEW:
289 s = GetPString(IDS_DIRCNRVIEWHELP);
290 break;
291 case DIR_SORT:
292 s = GetPString(IDS_DIRCNRSORTHELP);
293 break;
294 case DIR_FILTER:
295 s = GetPString(IDS_DIRCNRFILTERHELP);
296 break;
297 case DIR_MAX:
298 s = GetPString(IDS_DIRCNRMAXHELP);
299 break;
300 case DIR_FOLDERICON:
301 s = GetPString(IDS_DIRCNRFOLDERHELP);
302 break;
303 default:
304 break;
305 }
306 if (s)
307 MakeBubble(hwnd, TRUE, s);
308 else if (hwndBubble)
309 WinDestroyWindow(hwndBubble);
310 }
311 }
312 switch (id) {
313 case DIR_MAX:
314 case DIR_FOLDERICON:
315 case DIR_FILTER:
316 case DIR_SORT:
317 case DIR_VIEW:
318 case DIR_SELECTED:
319 return CommonTextButton(hwnd, msg, mp1, mp2);
320 }
321 }
322 break;
323
324 case WM_CHORD:
325 case WM_BUTTON3CLICK:
326 case WM_BUTTON1CLICK:
327 case UM_CLICKED:
328 case UM_CLICKED3:
329 {
330 USHORT id, cmd = 0;
331
332 id = WinQueryWindowUShort(hwnd, QWS_ID);
333 if (msg == UM_CLICKED || msg == UM_CLICKED3) {
334 switch (id) {
335 case DIR_MAX:
336 cmd = IDM_MAXIMIZE;
337 break;
338 case DIR_VIEW:
339 case DIR_SELECTED:
340 case DIR_SORT:
341 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
342 break;
343 case DIR_FILTER:
344 cmd = IDM_FILTER;
345 break;
346 default:
347 break;
348 }
349 }
350 else if (id == DIR_FOLDERICON) {
351 if ((msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_CTRL)))
352 cmd = IDM_PREVIOUS;
353 else if (msg == WM_BUTTON3CLICK || msg == WM_CHORD)
354 cmd = IDM_RESCAN;
355 else if (msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_SHIFT))
356 cmd = IDM_WALKDIR;
357 else if (msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_ALT))
358 cmd = IDM_WINDOWDLG;
359 else
360 cmd = IDM_PARENT;
361 }
362 if (cmd)
363 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
364 DIR_CNR),
365 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
366 }
367 if (msg == UM_CLICKED || msg == UM_CLICKED3)
368 return 0;
369 break;
370
371 case DM_DROP:
372 case DM_DRAGOVER:
373 case DM_DRAGLEAVE:
374 case DM_DROPHELP:
375 case WM_BEGINDRAG:
376 if (msg == DM_DRAGOVER) {
377 if (!emphasized) {
378 emphasized = TRUE;
379 DrawTargetEmphasis(hwnd, emphasized);
380 }
381 }
382 else if (msg != WM_BEGINDRAG) {
383 if (emphasized) {
384 emphasized = FALSE;
385 DrawTargetEmphasis(hwnd, emphasized);
386 }
387 }
388 switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
389 case DIR_FOLDERICON:
390 switch (msg) {
391 case DM_DRAGOVER:
392 if (AcceptOneDrop(hwnd, mp1, mp2))
393 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
394 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
395 case DM_DROPHELP:
396 DropHelp(mp1, mp2, hwnd, GetPString(IDS_DIRCNRFOLDERDROPHELP));
397 return 0;
398 case DM_DROP:
399 {
400 char szFrom[CCHMAXPATH + 2];
401
402 if (emphasized) {
403 emphasized = FALSE;
404 DrawTargetEmphasis(hwnd, emphasized);
405 }
406 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom)))
407 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
408 DIR_CNR),
409 WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0),
410 MPFROMP(szFrom));
411 }
412 return 0;
413 default:
414 return PFNWPStatic(hwnd, msg, mp1, mp2);
415 }
416 case DIR_MAX:
417 if (msg == WM_BEGINDRAG)
418 return PFNWPStatic(hwnd, msg, mp1, mp2);
419 default:
420 {
421 CNRDRAGINFO cnd;
422 USHORT dcmd;
423
424 switch (msg) {
425 case DM_DROP:
426 dcmd = CN_DROP;
427 break;
428 case DM_DRAGOVER:
429 dcmd = CN_DRAGOVER;
430 break;
431 case DM_DRAGLEAVE:
432 dcmd = CN_DRAGLEAVE;
433 break;
434 case DM_DROPHELP:
435 dcmd = CN_DROPHELP;
436 break;
437 case WM_BEGINDRAG:
438 dcmd = CN_INITDRAG;
439 break;
440 }
441 memset(&cnd, 0, sizeof(cnd));
442 cnd.pDragInfo = (PDRAGINFO) mp1;
443 cnd.pRecord = NULL;
444 return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
445 WM_CONTROL,
446 MPFROM2SHORT(DIR_CNR, dcmd), MPFROMP(&cnd));
447 }
448 }
449 }
450 return PFNWPStatic(hwnd, msg, mp1, mp2);
451}
452
453MRESULT EXPENTRY DirClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
454 MPARAM mp2)
455{
456 switch (msg) {
457 case UM_CONTAINERDIR:
458 if (mp1) {
459
460 DIRCNRDATA *dcd;
461
462 *(CHAR *) mp1 = 0;
463 dcd = WinQueryWindowPtr(WinWindowFromID(hwnd, DIR_CNR), QWL_USER);
464 if (dcd)
465 strcpy((CHAR *) mp1, dcd->directory);
466 return MRFROMLONG(TRUE);
467 }
468 return 0;
469
470 case UM_CONTAINERHWND:
471 return MRFROMLONG(WinWindowFromID(hwnd, DIR_CNR));
472
473 case UM_VIEWSMENU:
474 return MRFROMLONG(CheckMenu(&DirCnrMenu, DIRCNR_POPUP));
475
476 case UM_DRIVECMD:
477 case WM_INITMENU:
478 case UM_FILTER:
479 case UM_INITMENU:
480 case MM_PORTHOLEINIT:
481 case UM_COMMAND:
482 case UM_FILESMENU:
483 case UM_UPDATERECORD:
484 case UM_UPDATERECORDLIST:
485 return WinSendMsg(WinWindowFromID(hwnd, DIR_CNR), msg, mp1, mp2);
486
487 case WM_PSETFOCUS:
488 case WM_SETFOCUS:
489 if (mp2)
490 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
491 break;
492
493 case UM_FOCUSME:
494 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, DIR_CNR));
495 break;
496
497 case WM_PAINT:
498 {
499 HPS hps;
500 RECTL rcl;
501
502 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
503 if (hps) {
504 WinQueryWindowRect(hwnd, &rcl);
505 WinFillRect(hps, &rcl, CLR_PALEGRAY);
506 CommonTextPaint(hwnd, hps);
507 WinEndPaint(hps);
508 }
509 }
510 break;
511
512 case UM_SIZE:
513 case WM_SIZE:
514 if (msg == UM_SIZE) {
515
516 SWP swp;
517
518 WinQueryWindowPos(hwnd, &swp);
519 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
520 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
521 }
522 {
523 USHORT cx, cy, bx;
524
525 cx = SHORT1FROMMP(mp2);
526 cy = SHORT2FROMMP(mp2);
527 WinSetWindowPos(WinWindowFromID(hwnd, DIR_CNR), HWND_TOP,
528 0, 0, cx, cy - 24, SWP_SHOW | SWP_MOVE | SWP_SIZE);
529 if (WinWindowFromID(hwnd, DIR_MAX) != (HWND) 0) {
530 WinSetWindowPos(WinWindowFromID(hwnd, DIR_MAX), HWND_TOP,
531 cx - 22,
532 cy - 22, 20, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
533 cx -= 24;
534 }
535 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FOLDERICON), HWND_TOP,
536 2, cy - 22, 24, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
537 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
538 29,
539 cy - 22,
540 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
541 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
542 29 + (cx / 3) + 2,
543 cy - 22,
544 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
545 bx = (cx - (29 + (((cx / 3) + 2) * 2))) / 3;
546 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
547 29 + (((cx / 3) + 2) * 2),
548 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
549 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
550 29 + (((cx / 3) + 2) * 2) + bx,
551 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
552 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
553 29 + (((cx / 3) + 2) * 2) + (bx * 2),
554 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
555 }
556 CommonTextPaint(hwnd, (HPS) 0);
557 if (msg == UM_SIZE) {
558 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
559 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
560 return 0;
561 }
562 break;
563
564 case WM_COMMAND:
565 case WM_CONTROL:
566 case WM_CLOSE:
567 return WinSendMsg(WinWindowFromID(hwnd, DIR_CNR), msg, mp1, mp2);
568 }
569 return WinDefWindowProc(hwnd, msg, mp1, mp2);
570}
571
572MRESULT EXPENTRY DirObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
573{
574 DIRCNRDATA *dcd;
575 DIRCNRDATA *dcdsrc;
576
577 switch (msg) {
578 case WM_CREATE:
579 break;
580
581 case DM_PRINTOBJECT:
582 return MRFROMLONG(DRR_TARGET);
583
584 case DM_DISCARDOBJECT:
585 dcd = INSTDATA(hwnd);
586 if (fFM2Deletes && dcd) {
587
588 LISTINFO *li;
589 CNRDRAGINFO cni;
590
591 cni.pRecord = NULL;
592 cni.pDragInfo = (PDRAGINFO) mp1;
593 DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
594 li =
595 DoFileDrop(dcd->hwndCnr, dcd->directory, FALSE, MPVOID,
596 MPFROMP(&cni));
597 CheckPmDrgLimit(cni.pDragInfo);
598 if (li) {
599 li->type = (fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE;
600 if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
601 FreeListInfo(li);
602 else
603 return MRFROMLONG(DRR_SOURCE);
604 }
605 }
606 return MRFROMLONG(DRR_TARGET);
607
608 case UM_UPDATERECORDLIST:
609 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
610 if (dcd && mp1) {
611
612 INT numentries = 0;
613 CHAR **list = (CHAR **) mp1;
614
615 while (list[numentries])
616 numentries++;
617 if (numentries)
618 UpdateCnrList(dcd->hwndCnr, list, numentries, TRUE, dcd);
619 }
620 return 0;
621
622 case UM_SETUP:
623 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
624 if (dcd) {
625 /* set unique id */
626 WinSetWindowUShort(hwnd, QWS_ID, DIROBJ_FRAME + (DIR_FRAME - dcd->id));
627 dcd->hwndObject = hwnd;
628 if (ParentIsDesktop(hwnd, dcd->hwndParent))
629 DosSleep(250L);
630 }
631 else
632 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
633 return 0;
634
635 case UM_RESCAN2:
636 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
637 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
638
639 FSALLOCATE fsa;
640 CHAR s[CCHMAXPATH * 2];
641 CHAR tf[64];
642 CHAR tb[64];
643 CHAR szFree[64];
644
645 DosError(FERR_DISABLEHARDERR);
646 if (!DosQueryFSInfo(toupper(*dcd->directory) - '@',
647 FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
648 CommaFmtULL(tb, sizeof(tb),
649 (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit *
650 fsa.cbSector), 'K');
651 sprintf(szFree, " {%s %s}", tb, GetPString(IDS_FREETEXT));
652 }
653 else
654 *szFree = 0;
655 commafmt(tf, sizeof(tf), dcd->totalfiles);
656 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
657 if (!fMoreButtons) {
658 sprintf(s, " [%s / %s]%s%s%s%s %s",
659 tf, tb, szFree,
660 (*dcd->mask.szMask || dcd->mask.antiattr ||
661 dcd->mask.attrFile != ALLATTRS) ? " (" : NullStr,
662 (*dcd->mask.szMask) ? dcd->mask.szMask :
663 (dcd->mask.antiattr ||
664 dcd->mask.attrFile != ALLATTRS) ?
665 GetPString(IDS_ALLTEXT) : NullStr,
666 (*dcd->mask.szMask || dcd->mask.antiattr ||
667 dcd->mask.attrFile != ALLATTRS) ? ")" : NullStr,
668 dcd->directory);
669 }
670 else {
671 sprintf(s, " [%s / %s]%s %s", tf, tb, szFree, dcd->directory);
672 }
673 if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
674 WinSetWindowText(hwndStatus, s);
675 }
676 return 0;
677
678 case UM_FLESH:
679 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
680 if (dcd) {
681
682 PCNRITEM pci, pciC;
683
684 pci = WinSendMsg(dcd->hwndCnr,
685 CM_QUERYRECORD,
686 MPVOID, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
687 while (pci && (INT) pci != -1) {
688 if (pci->attrFile & FILE_DIRECTORY) {
689 pciC = WinSendMsg(dcd->hwndCnr,
690 CM_QUERYRECORD,
691 MPFROMP(pci),
692 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
693 if (!pciC) {
694 Stubby(dcd->hwndCnr, pci);
695 DosSleep(0L);
696 }
697 }
698 pci = WinSendMsg(dcd->hwndCnr,
699 CM_QUERYRECORD,
700 MPFROMP(pci), MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
701 }
702 dcd->firsttree = TRUE;
703 }
704 return 0;
705
706 case UM_RESCAN:
707 /*
708 * populate container
709 */
710 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
711 if (dcd) {
712 DosEnterCritSec();
713 if (dcd->stopflag)
714 dcd->stopflag--;
715 if (dcd->stopflag) {
716 DosExitCritSec();
717 return 0;
718 }
719 DosExitCritSec();
720 if (mp1) {
721 strcpy(dcd->previous, dcd->directory);
722 strcpy(dcd->directory, (CHAR *) mp1);
723 }
724 MakeValidDir(dcd->directory);
725 {
726 CHAR s[CCHMAXPATH + 8];
727
728 sprintf(s,
729 "%s%s%s",
730 (ParentIsDesktop(dcd->hwndFrame, (HWND) 0)) ?
731 "VDir" :
732 NullStr,
733 (ParentIsDesktop(dcd->hwndFrame, (HWND) 0)) ?
734 (!dcd->dontclose) ?
735 " Master: " : ": " : NullStr, dcd->directory);
736 WinSetWindowText(dcd->hwndFrame, s);
737 WinSetWindowText(WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR), s);
738 }
739 WinSendMsg(dcd->hwndCnr,
740 CM_REMOVERECORD,
741 MPVOID,
742 MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE));
743 AdjustCnrColsForFSType(dcd->hwndCnr, dcd->directory, dcd);
744 dcd->ullTotalBytes = dcd->totalfiles =
745 dcd->selectedfiles = dcd->selectedbytes = 0;
746 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0 / 0k");
747 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
748 if (hwndStatus &&
749 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
750 WinSetWindowText(hwndStatus, GetPString(IDS_SCANNINGTEXT));
751 if (hwndMain)
752 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
753 }
754 if (fSwitchTree && hwndTree) {
755 if (hwndMain) {
756 if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame)
757 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID);
758 }
759 else
760 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID);
761 }
762 dcd->firsttree = FALSE;
763 // fixme to check errors
764 FillDirCnr(dcd->hwndCnr, dcd->directory, dcd, &dcd->ullTotalBytes);
765 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
766 if (mp2 && !fLeaveTree && (dcd->flWindowAttr & CV_TREE)) {
767
768 ULONG flWindowAttr = dcd->flWindowAttr;
769 CNRINFO cnri;
770
771 flWindowAttr &=
772 (~(CV_NAME | CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
773 if (dcd->lastattr) {
774 if (dcd->lastattr & CV_TEXT)
775 flWindowAttr |= CV_TEXT;
776 else if (dcd->lastattr & CV_DETAIL)
777 flWindowAttr |= CV_DETAIL;
778 else if (dcd->lastattr & CV_ICON)
779 flWindowAttr |= CV_ICON;
780 else
781 flWindowAttr |= CV_NAME;
782 }
783 else
784 flWindowAttr |= CV_NAME;
785 flWindowAttr |= CV_FLOW;
786 memset(&cnri, 0, sizeof(CNRINFO));
787 cnri.cb = sizeof(CNRINFO);
788 if (WinSendMsg(dcd->hwndCnr, CM_QUERYCNRINFO, MPFROMP(&cnri),
789 MPFROMLONG(sizeof(CNRINFO)))) {
790 dcd->flWindowAttr = cnri.flWindowAttr = flWindowAttr;
791 WinSendMsg(dcd->hwndCnr, CM_SETCNRINFO,
792 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
793 SayView(WinWindowFromID(dcd->hwndClient,
794 DIR_VIEW), dcd->flWindowAttr);
795 }
796 }
797 if (dcd->flWindowAttr & CV_TREE)
798 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
799 if (*dcd->previous) {
800 if (strlen(dcd->previous) > strlen(dcd->directory) &&
801 !strnicmp(dcd->directory, dcd->previous,
802 strlen(dcd->directory))) {
803
804 PCNRITEM pci;
805
806 pci = FindCnrRecord(dcd->hwndCnr,
807 dcd->previous, NULL, TRUE, FALSE, TRUE);
808 if (pci && (INT) pci != -1) {
809 /* make found item current (cursored) item */
810 WinSendMsg(dcd->hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
811 MPFROM2SHORT(TRUE, CRA_CURSORED));
812 /* make sure that record shows in viewport */
813 ShowCnrRecord(dcd->hwndCnr, (PMINIRECORDCORE) pci);
814 }
815 }
816 }
817 }
818 return 0;
819
820 case UM_COMMAND:
821 if (mp1) {
822
823 LISTINFO *li = (LISTINFO *) mp1;
824
825 switch (li->type) {
826 case IDM_DOITYOURSELF:
827 case IDM_APPENDTOCLIP:
828 case IDM_SAVETOCLIP:
829 case IDM_ARCHIVE:
830 case IDM_ARCHIVEM:
831 case IDM_VIEWTEXT:
832 case IDM_VIEWBINARY:
833 case IDM_VIEWARCHIVE:
834 case IDM_VIEW:
835 case IDM_EDITTEXT:
836 case IDM_EDITBINARY:
837 case IDM_EDIT:
838 case IDM_OBJECT:
839 case IDM_SHADOW:
840 case IDM_SHADOW2:
841 case IDM_PRINT:
842 case IDM_ATTRS:
843 case IDM_DELETE:
844 case IDM_PERMDELETE:
845 case IDM_MCIPLAY:
846 case IDM_UPDATE:
847 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
848 return (MRESULT) TRUE;
849 break;
850 default:
851 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
852 return (MRESULT) TRUE;
853 }
854 }
855 return 0;
856
857 case UM_SELECT:
858 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
859 if (dcd) {
860 switch (SHORT1FROMMP(mp1)) {
861 case IDM_SELECTBOTH:
862 case IDM_SELECTONE:
863 case IDM_SELECTMORE:
864 case IDM_SELECTNEWER:
865 case IDM_SELECTOLDER:
866 case IDM_SELECTBIGGER:
867 case IDM_SELECTSMALLER:
868 case IDM_DESELECTBOTH:
869 case IDM_DESELECTONE:
870 case IDM_DESELECTMORE:
871 case IDM_DESELECTNEWER:
872 case IDM_DESELECTOLDER:
873 case IDM_DESELECTBIGGER:
874 case IDM_DESELECTSMALLER:
875 SpecialSelect2(dcd->hwndParent, SHORT1FROMMP(mp1));
876 break;
877 case IDM_SELECTLIST:
878 {
879 CHAR filename[CCHMAXPATH], *p, *pp;
880 ULONG size;
881
882 strcpy(filename, "*.LST");
883 size = CCHMAXPATH;
884 PrfQueryProfileData(fmprof, appname, "SaveToListName",
885 filename, &size);
886 pp = strrchr(filename, '\\');
887 if (!pp)
888 pp = filename;
889 p = strrchr(pp, '.');
890 if (p && *(p + 1) && p > pp + 1) {
891 if (pp > filename)
892 pp++;
893 *pp = '*';
894 pp++;
895 if (p > pp)
896 memmove(pp, p, strlen(p) + 1);
897 }
898 if (insert_filename(hwnd, filename, FALSE, FALSE))
899 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
900 NULL);
901 }
902 break;
903 case IDM_SELECTALL:
904 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
905 break;
906 case IDM_DESELECTALL:
907 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
908 break;
909 case IDM_SELECTALLFILES:
910 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
911 break;
912 case IDM_DESELECTALLFILES:
913 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
914 break;
915 case IDM_SELECTALLDIRS:
916 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
917 break;
918 case IDM_DESELECTALLDIRS:
919 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
920 break;
921 case IDM_DESELECTMASK:
922 case IDM_SELECTMASK:
923 {
924 MASK mask;
925 PCNRITEM pci = (PCNRITEM) mp2;
926
927 memset(&mask, 0, sizeof(MASK));
928 mask.fNoAttribs = TRUE;
929 mask.fNoDirs = TRUE;
930 mask.fText = TRUE;
931 strcpy(mask.prompt,
932 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
933 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
934 if (pci && (INT) pci != -1)
935 strcpy(mask.szMask, pci->szFileName);
936 if (WinDlgBox(HWND_DESKTOP,
937 dcd->hwndCnr,
938 PickMaskDlgProc,
939 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
940 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
941 SelectAll(dcd->hwndCnr,
942 TRUE, TRUE, mask.szMask, mask.szText, FALSE);
943 else
944 DeselectAll(dcd->hwndCnr,
945 TRUE, TRUE, mask.szMask, mask.szText, FALSE);
946 }
947 }
948 break;
949
950 case IDM_DESELECTCLIP:
951 case IDM_SELECTCLIP:
952 {
953 CHAR **list;
954
955 list = ListFromClipboard(hwnd);
956 if (list) {
957 SelectList(dcd->hwndCnr, TRUE, FALSE,
958 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
959 NULL, NULL, list);
960 FreeList(list);
961 }
962 }
963 break;
964
965 case IDM_INVERT:
966 InvertAll(dcd->hwndCnr);
967 break;
968 }
969 }
970 return 0;
971
972 case UM_MASSACTION:
973 if (mp1) {
974
975 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
976 if (dcd) {
977
978 WORKER *wk;
979
980 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
981 if (!wk)
982 FreeListInfo((LISTINFO *) mp1);
983 else {
984 wk->size = sizeof(WORKER);
985 wk->hwndCnr = dcd->hwndCnr;
986 wk->hwndParent = dcd->hwndParent;
987 wk->hwndFrame = dcd->hwndFrame;
988 wk->hwndClient = dcd->hwndClient;
989 wk->li = (LISTINFO *) mp1;
990 strcpy(wk->directory, dcd->directory);
991 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
992 Runtime_Error(pszSrcFile, __LINE__,
993 GetPString(IDS_COULDNTSTARTTHREADTEXT));
994 free(wk);
995 FreeListInfo((LISTINFO *) mp1);
996 }
997 }
998 }
999 }
1000 return 0;
1001
1002 case UM_ACTION:
1003 if (mp1) {
1004
1005 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1006 if (dcd) {
1007
1008 WORKER *wk;
1009
1010 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
1011 if (!wk)
1012 FreeListInfo((LISTINFO *) mp1);
1013 else {
1014 wk->size = sizeof(WORKER);
1015 wk->hwndCnr = dcd->hwndCnr;
1016 wk->hwndParent = dcd->hwndParent;
1017 wk->hwndFrame = dcd->hwndFrame;
1018 wk->hwndClient = dcd->hwndClient;
1019 wk->li = (LISTINFO *) mp1;
1020 strcpy(wk->directory, dcd->directory);
1021 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
1022 Runtime_Error(pszSrcFile, __LINE__,
1023 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1024 free(wk);
1025 FreeListInfo((LISTINFO *) mp1);
1026 }
1027 }
1028 }
1029 }
1030 return 0;
1031
1032 case WM_CLOSE:
1033 WinDestroyWindow(hwnd);
1034 break;
1035
1036 case WM_DESTROY:
1037 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1038 if (dcd) {
1039 if (dcd->hwndRestore)
1040 WinSetWindowPos(dcd->hwndRestore,
1041 HWND_TOP,
1042 0,
1043 0,
1044 0,
1045 0,
1046 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
1047 FreeList(dcd->lastselection);
1048 free(dcd);
1049 DosPostEventSem(CompactSem);
1050 }
1051 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1052 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1053 break;
1054 }
1055 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1056}
1057
1058MRESULT EXPENTRY DirCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1059{
1060 DIRCNRDATA *dcd = INSTDATA(hwnd);
1061 DIRCNRDATA *dcdsrc;
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];
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.