source: trunk/dll/dircnrs.c@ 1020

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

Fix dircnr to follow "subject column" preference on open; match query & save profile key names for "details" settings.

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