source: trunk/dll/dircnrs.c@ 1028

Last change on this file since 1028 was 1028, checked in by Gregg Young, 17 years ago

Fix for bug 237 that is actually correct; code clean up

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