source: trunk/dll/dircnrs.c@ 1018

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

Additional fortify scopes mostly for "lists"

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 92.9 KB
Line 
1
2/***********************************************************************
3
4 $Id: dircnrs.c 1018 2008-05-26 19:34:56Z 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 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1514 DIR_FILTER), &dcd->mask, FALSE);
1515 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1516 DIR_SORT), dcd->sortFlags, FALSE);
1517 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1518 DIR_VIEW), dcd->flWindowAttr);
1519 }
1520 else {
1521 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1522 return 0;
1523 }
1524 return 0;
1525
1526 case UM_SETUP2:
1527 if (dcd) {
1528 AdjustCnrColsForPref(hwnd, NULL, dcd, FALSE);
1529 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1530 DIR_FILTER), &dcd->mask, FALSE);
1531 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1532 DIR_SORT), dcd->sortFlags, FALSE);
1533 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1534 DIR_VIEW), dcd->flWindowAttr);
1535 } else
1536 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1537 return 0;
1538
1539 case WM_MENUEND:
1540 if (dcd) {
1541
1542 HWND hwndMenu = (HWND) mp2;
1543
1544 if (hwndMenu == DirCnrMenu ||
1545 hwndMenu == FileMenu ||
1546 hwndMenu == DirMenu) {
1547 MarkAll(hwnd, TRUE, FALSE, TRUE);
1548 if (dcd->cnremphasized) {
1549 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1550 MPFROM2SHORT(FALSE, CRA_SOURCE));
1551 dcd->cnremphasized = FALSE;
1552 }
1553 }
1554 }
1555 break;
1556
1557 case UM_OPENWINDOWFORME:
1558 if (dcd) {
1559 if (mp1 && !IsFile((CHAR *)mp1)) {
1560 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
1561 }
1562 else if (mp1 && IsFile(mp1) == 1) {
1563 StartArcCnr(HWND_DESKTOP,
1564 dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
1565 }
1566 }
1567 return 0;
1568
1569 case MM_PORTHOLEINIT:
1570 if (dcd) {
1571 switch (SHORT1FROMMP(mp1)) {
1572 case 0:
1573 case 1:
1574 {
1575 ULONG wmsg;
1576
1577 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1578 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
1579 wmsg, MPVOID, MPVOID), mp1, mp2);
1580 }
1581 break;
1582 }
1583 }
1584 break;
1585
1586 case UM_INITMENU:
1587 case WM_INITMENU:
1588 if (dcd) {
1589 switch (SHORT1FROMMP(mp1)) {
1590 case IDM_FILESMENU:
1591 CopyPresParams((HWND) mp2, hwndMainMenu);
1592 if (isalpha(*dcd->directory)) {
1593 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
1594 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, FALSE);
1595 WinEnableMenuItem((HWND) mp2, IDM_RENAME, FALSE);
1596 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1597 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, FALSE);
1598 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, FALSE);
1599 WinEnableMenuItem((HWND) mp2, IDM_DELETE, FALSE);
1600 WinEnableMenuItem((HWND) mp2, IDM_EDIT, FALSE);
1601 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, FALSE);
1602 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, FALSE);
1603 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, FALSE);
1604 }
1605 else {
1606 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, TRUE);
1607 WinEnableMenuItem((HWND) mp2, IDM_RENAME, TRUE);
1608 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1609 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, TRUE);
1610 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, TRUE);
1611 WinEnableMenuItem((HWND) mp2, IDM_DELETE, TRUE);
1612 WinEnableMenuItem((HWND) mp2, IDM_EDIT, TRUE);
1613 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, TRUE);
1614 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, TRUE);
1615 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
1616 }
1617 }
1618 break;
1619
1620 case IDM_VIEWSMENU:
1621 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1622 CopyPresParams((HWND) mp2, hwndMainMenu);
1623 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1624 (dcd->lastselection != NULL));
1625 if (isalpha(*dcd->directory)) {
1626 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE)
1627 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1628 else
1629 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1630 }
1631 WinEnableMenuItem((HWND) mp2,
1632 IDM_SELECTCOMPAREMENU,
1633 (CountDirCnrs(dcd->hwndParent) > 1));
1634 break;
1635
1636 case IDM_DETAILSSETUP:
1637 SetDetailsSwitches((HWND) mp2, dcd);
1638 break;
1639
1640 case IDM_COMMANDSMENU:
1641 SetupCommandMenu((HWND) mp2, hwnd);
1642 break;
1643
1644 case IDM_SORTSUBMENU:
1645 SetSortChecks((HWND) mp2, dcd->sortFlags);
1646 break;
1647
1648 case IDM_WINDOWSMENU:
1649 SetupWinList((HWND) mp2,
1650 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
1651 break;
1652 }
1653 dcd->hwndLastMenu = (HWND) mp2;
1654 }
1655 if (msg == WM_INITMENU)
1656 break;
1657 return 0;
1658
1659 case UM_FILTER:
1660 if (dcd) {
1661
1662 PCNRITEM pci;
1663
1664 if (mp1) {
1665 DosEnterCritSec();
1666 SetMask((CHAR *)mp1, &dcd->mask);
1667 DosExitCritSec();
1668 }
1669 dcd->suspendview = 1;
1670 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1671 dcd->suspendview = 0;
1672 if (fAutoView && hwndMain) {
1673 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1674 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1675 if (pci && (INT) pci != -1 &&
1676 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1677 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1678 else
1679 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1680 }
1681 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1682 }
1683 return 0;
1684
1685 case UM_COMMAND:
1686 if (mp1) {
1687 if (dcd) {
1688 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1689 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1690 FreeListInfo((LISTINFO *) mp1);
1691 }
1692 else
1693 return (MRESULT) TRUE;
1694 }
1695 else
1696 FreeListInfo((LISTINFO *) mp1);
1697 }
1698 return 0;
1699
1700 case UM_NOTIFY:
1701 if (mp2)
1702 Notify((CHAR *)mp2);
1703 return 0;
1704
1705 case UM_DRIVECMD:
1706 if (mp1)
1707 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0), mp1);
1708 return 0;
1709
1710 case WM_COMMAND:
1711 DosError(FERR_DISABLEHARDERR);
1712 if (dcd) {
1713 switch (SHORT1FROMMP(mp1)) {
1714 case IDM_SETTARGET:
1715 SetTargetDir(hwnd, FALSE);
1716 break;
1717
1718 case IDM_CREATE:
1719 {
1720 STRINGINPARMS sip;
1721 CHAR filename[CCHMAXPATHCOMP];
1722
1723 memset(&sip, 0, sizeof(sip));
1724 sip.help = GetPString(IDS_CREATETEXT);
1725 sip.prompt = GetPString(IDS_CREATEPROMPTTEXT);
1726 sip.inputlen = CCHMAXPATHCOMP - (strlen(dcd->directory) - 1);
1727 strcpy(filename, "NEWFILE.TXT");
1728 sip.ret = filename;
1729 sip.title = GetPString(IDS_CREATETITLETEXT);
1730 if (WinDlgBox(HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle,
1731 STR_FRAME, &sip)) {
1732 bstrip(sip.ret);
1733 if (*sip.ret) {
1734 CHAR newfile[CCHMAXPATH];
1735 FILE *fp;
1736 INT test;
1737 PCNRITEM pci;
1738
1739 strcpy(newfile, dcd->directory);
1740 if (newfile[strlen(newfile) - 1] != '\\')
1741 strcat(newfile, "\\");
1742 strcat(newfile, sip.ret);
1743 test = IsFile(newfile);
1744 if (test != 1)
1745 fp = fopen(newfile, "w");
1746 if (test != 1 && !fp) {
1747 saymsg(MB_ENTER,
1748 hwnd,
1749 GetPString(IDS_ERRORTEXT),
1750 GetPString(IDS_CREATEERRORTEXT), newfile);
1751 }
1752 else {
1753 if (fp) {
1754 WinSendMsg(hwnd, UM_UPDATERECORD, MPFROMP(newfile), MPVOID);
1755 fclose(fp);
1756 }
1757 if (*editor) {
1758
1759 CHAR *dummy[2];
1760
1761 dummy[0] = newfile;
1762 dummy[1] = NULL;
1763 ExecOnList(hwnd,
1764 editor, WINDOWED | SEPARATE, NULL, dummy, NULL,
1765 pszSrcFile, __LINE__);
1766 }
1767 else
1768 StartMLEEditor(dcd->hwndParent, 4, newfile, dcd->hwndFrame);
1769 pci = FindCnrRecord(hwnd, newfile, NULL, TRUE, FALSE, TRUE);
1770 if (pci && (INT) pci != -1)
1771 /* make sure that record shows in viewport */
1772 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1773 }
1774 }
1775 }
1776 }
1777 break;
1778
1779 case IDM_CONTEXTMENU:
1780 {
1781 PCNRITEM pci;
1782
1783 pci = (PCNRITEM) CurrentRecord(hwnd);
1784 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
1785 MPFROMP(pci));
1786 }
1787 break;
1788
1789 case IDM_MAXIMIZE:
1790 PostMsg(hwndMain, UM_MAXIMIZE, MPFROMLONG(dcd->hwndFrame), MPVOID);
1791 break;
1792
1793 case IDM_SHOWALLFILESCNR:
1794 StartSeeAll(HWND_DESKTOP, FALSE, dcd->directory);
1795 break;
1796
1797 case IDM_SHOWALLFILES:
1798 {
1799 PCNRITEM pci;
1800
1801 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1802 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1803 if (pci && (INT) pci != -1) {
1804
1805 static CHAR dirname[CCHMAXPATH];
1806
1807 strcpy(dirname, pci->pszFileName);
1808 MakeValidDir(dirname);
1809 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1810 }
1811 }
1812 break;
1813
1814 case IDM_FINDINTREE:
1815 if (hwndTree)
1816 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory),
1817 MPFROMLONG(1L));
1818 break;
1819
1820 case IDM_BEGINEDIT:
1821 OpenEdit(hwnd);
1822 break;
1823
1824 case IDM_ENDEDIT:
1825 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1826 break;
1827
1828 case IDM_SHOWSELECT:
1829 QuickPopup(hwnd,
1830 dcd,
1831 CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP), IDM_SELECTSUBMENU);
1832 break;
1833
1834 case IDM_SHOWSORT:
1835 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP),
1836 IDM_SORTSUBMENU);
1837 break;
1838
1839 case IDM_VIEWORARC:
1840 {
1841 SWP swp;
1842 PCNRITEM pci;
1843
1844 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1845 MPFROMLONG(CMA_FIRST),
1846 MPFROMSHORT(CRA_CURSORED));
1847 if (pci && (INT) pci != -1) {
1848 WinQueryWindowPos(dcd->hwndFrame, &swp);
1849 DefaultViewKeys(hwnd,
1850 dcd->hwndFrame,
1851 dcd->hwndParent, &swp, pci->pszFileName);
1852 }
1853 }
1854 break;
1855
1856 case IDM_DIRCNRSETTINGS:
1857 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1858 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_DIRCNRSETTINGS), mp2);
1859 else {
1860 WinDlgBox(HWND_DESKTOP,
1861 hwnd,
1862 CfgDlgProc,
1863 FM3ModHandle,
1864 CFG_FRAME,
1865 MPFROMLONG(IDM_DIRCNRSETTINGS));
1866 }
1867 break;
1868
1869 case IDM_QTREE:
1870 case IDM_TREE:
1871 {
1872 CHAR newpath[CCHMAXPATH];
1873 APIRET rc;
1874 PCNRITEM pci;
1875
1876 if (SHORT1FROMMP(mp1) == IDM_TREE) {
1877 pci = (PCNRITEM) CurrentRecord(hwnd);
1878 if (pci && (INT) pci != -1)
1879 strcpy(newpath, pci->pszFileName);
1880 else
1881 strcpy(newpath, dcd->directory);
1882 }
1883 else
1884 strcpy(newpath, dcd->directory);
1885 MakeValidDir(newpath);
1886 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ObjCnrDlgProc,
1887 FM3ModHandle, QTREE_FRAME, MPFROMP(newpath));
1888 if (rc)
1889 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(newpath), MPVOID);
1890 }
1891 break;
1892
1893 case IDM_RESELECT:
1894 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1895 break;
1896
1897 case IDM_HELP:
1898 if (hwndHelp) {
1899 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1900 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
1901 else
1902 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
1903 }
1904 break;
1905
1906 case IDM_WINDOWDLG:
1907 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1908 PostMsg(dcd->hwndParent, UM_COMMAND,
1909 MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
1910 break;
1911
1912 case IDM_SORTSMARTNAME:
1913 case IDM_SORTNAME:
1914 case IDM_SORTFILENAME:
1915 case IDM_SORTSIZE:
1916 case IDM_SORTEASIZE:
1917 case IDM_SORTFIRST:
1918 case IDM_SORTLAST:
1919 case IDM_SORTLWDATE:
1920 case IDM_SORTLADATE:
1921 case IDM_SORTCRDATE:
1922 case IDM_SORTSUBJECT:
1923 dcd->sortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1924 case IDM_SORTDIRSFIRST:
1925 case IDM_SORTDIRSLAST:
1926 case IDM_SORTREVERSE:
1927 switch (SHORT1FROMMP(mp1)) {
1928 case IDM_SORTSUBJECT:
1929 dcd->sortFlags |= SORT_SUBJECT;
1930 break;
1931 case IDM_SORTSMARTNAME:
1932 case IDM_SORTFILENAME:
1933 dcd->sortFlags |= SORT_FILENAME;
1934 break;
1935 case IDM_SORTSIZE:
1936 dcd->sortFlags |= SORT_SIZE;
1937 break;
1938 case IDM_SORTEASIZE:
1939 dcd->sortFlags |= SORT_EASIZE;
1940 break;
1941 case IDM_SORTFIRST:
1942 dcd->sortFlags |= SORT_FIRSTEXTENSION;
1943 break;
1944 case IDM_SORTLAST:
1945 dcd->sortFlags |= SORT_LASTEXTENSION;
1946 break;
1947 case IDM_SORTLWDATE:
1948 dcd->sortFlags |= SORT_LWDATE;
1949 break;
1950 case IDM_SORTLADATE:
1951 dcd->sortFlags |= SORT_LADATE;
1952 break;
1953 case IDM_SORTCRDATE:
1954 dcd->sortFlags |= SORT_CRDATE;
1955 break;
1956 case IDM_SORTDIRSFIRST:
1957 if (dcd->sortFlags & SORT_DIRSFIRST)
1958 dcd->sortFlags &= (~SORT_DIRSFIRST);
1959 else {
1960 dcd->sortFlags |= SORT_DIRSFIRST;
1961 dcd->sortFlags &= (~SORT_DIRSLAST);
1962 }
1963 break;
1964 case IDM_SORTDIRSLAST:
1965 if (dcd->sortFlags & SORT_DIRSLAST)
1966 dcd->sortFlags &= (~SORT_DIRSLAST);
1967 else {
1968 dcd->sortFlags |= SORT_DIRSLAST;
1969 dcd->sortFlags &= (~SORT_DIRSFIRST);
1970 }
1971 break;
1972 case IDM_SORTREVERSE:
1973 if (dcd->sortFlags & SORT_REVERSE)
1974 dcd->sortFlags &= (~SORT_REVERSE);
1975 else
1976 dcd->sortFlags |= SORT_REVERSE;
1977 break;
1978 }
1979 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortDirCnr),
1980 MPFROMLONG(dcd->sortFlags));
1981 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1982 DIR_SORT), dcd->sortFlags, FALSE);
1983 break;
1984
1985 case IDM_COLLECT:
1986 if (!Collector) {
1987
1988 HWND hwndC;
1989 SWP swp;
1990
1991 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
1992 (!fExternalCollector && !strcmp(realappname, FM3Str)))
1993 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
1994 hwndC = StartCollector((fExternalCollector ||
1995 strcmp(realappname, FM3Str)) ?
1996 HWND_DESKTOP : dcd->hwndParent, 4);
1997 if (hwndC) {
1998 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
1999 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2000 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2001 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2002 SWP_SHOW | SWP_ZORDER);
2003 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) && fAutoTile &&
2004 !strcmp(realappname, FM3Str))
2005 TileChildren(dcd->hwndParent, TRUE);
2006 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
2007 DosSleep(100); //05 Aug 07 GKY 250
2008 }
2009 }
2010 else
2011 StartCollector(dcd->hwndParent, 4);
2012 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2013 break;
2014
2015 case IDM_COLLECTOR:
2016 DosSleep(32); //05 Aug 07 GKY 64
2017 {
2018 CHAR **list;
2019
2020 list = BuildList(hwnd);
2021 if (list) {
2022 if (Collector) {
2023 if (!PostMsg(Collector,
2024 WM_COMMAND,
2025 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2026 FreeList(list);
2027 else if (fUnHilite)
2028 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2029 }
2030 else
2031 FreeList(list);
2032 }
2033 }
2034 break;
2035
2036 case IDM_UNDELETE:
2037 {
2038 PCNRITEM pci;
2039 CHAR path[CCHMAXPATH];
2040
2041 pci = (PCNRITEM) CurrentRecord(hwnd);
2042 if (pci && (INT) pci != -1) {
2043 strcpy(path, pci->pszFileName);
2044 MakeValidDir(path);
2045 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2046 UNDEL_FRAME, MPFROMP(path));
2047 }
2048 }
2049 break;
2050
2051 case IDM_UNDELETESPEC:
2052 WinDlgBox(HWND_DESKTOP,
2053 hwnd,
2054 UndeleteDlgProc,
2055 FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
2056 break;
2057
2058 case IDM_RESORT:
2059// WinSendMsg(hwnd,
2060// CM_SORTRECORD,
2061// MPFROMP(SortDirCnr),
2062// MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
2063 WinSendMsg(hwnd,
2064 CM_SORTRECORD,
2065 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
2066 break;
2067
2068 case IDM_FILTER:
2069 {
2070 BOOL empty = FALSE;
2071 PCNRITEM pci;
2072 CHAR *p;
2073
2074 if (!*dcd->mask.szMask) {
2075 empty = TRUE;
2076 pci = (PCNRITEM) CurrentRecord(hwnd);
2077 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
2078 p = strrchr(pci->pszFileName, '\\');
2079 if (p) {
2080 p++;
2081 strcpy(dcd->mask.szMask, p);
2082 }
2083 }
2084 }
2085 *(dcd->mask.prompt) = 0;
2086
2087 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2088 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2089 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2090 else if (empty)
2091 *dcd->mask.szMask = 0;
2092 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2093 DIR_FILTER), &dcd->mask, FALSE);
2094 }
2095 break;
2096
2097 case IDM_UNHIDEALL:
2098 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2099 break;
2100
2101 case IDM_HIDEALL:
2102 if (fAutoView && hwndMain)
2103 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2104 dcd->suspendview = 1;
2105 HideAll(hwnd);
2106 dcd->suspendview = 0;
2107 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2108 break;
2109
2110 case IDM_SELECTBOTH:
2111 case IDM_SELECTONE:
2112 case IDM_SELECTMORE:
2113 case IDM_SELECTNEWER:
2114 case IDM_SELECTOLDER:
2115 case IDM_SELECTBIGGER:
2116 case IDM_SELECTSMALLER:
2117 case IDM_DESELECTBOTH:
2118 case IDM_DESELECTONE:
2119 case IDM_DESELECTMORE:
2120 case IDM_DESELECTNEWER:
2121 case IDM_DESELECTOLDER:
2122 case IDM_DESELECTBIGGER:
2123 case IDM_DESELECTSMALLER:
2124 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2125 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2126 break;
2127 }
2128 case IDM_SELECTLIST:
2129 case IDM_SELECTALL:
2130 case IDM_DESELECTALL:
2131 case IDM_SELECTALLFILES:
2132 case IDM_DESELECTALLFILES:
2133 case IDM_SELECTALLDIRS:
2134 case IDM_DESELECTALLDIRS:
2135 case IDM_SELECTMASK:
2136 case IDM_DESELECTMASK:
2137 case IDM_INVERT:
2138 case IDM_SELECTCLIP:
2139 case IDM_DESELECTCLIP:
2140 {
2141 PCNRITEM pci;
2142
2143 pci = (PCNRITEM) CurrentRecord(hwnd);
2144 if ((INT) pci == -1)
2145 pci = NULL;
2146 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2147 if (pci) {
2148 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2149 pci->rc.flRecordAttr |= CRA_FILTERED;
2150 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2151 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2152 break;
2153 }
2154 }
2155 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2156 }
2157 break;
2158
2159 case IDM_RESCAN:
2160 DosEnterCritSec();
2161 dcd->stopflag++;
2162 DosExitCritSec();
2163 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2164 DosEnterCritSec();
2165 dcd->stopflag--;
2166 DosExitCritSec();
2167 }
2168 break;
2169
2170 case IDM_SHOWLNAMES:
2171 case IDM_SHOWSUBJECT:
2172 case IDM_SHOWEAS:
2173 case IDM_SHOWSIZE:
2174 case IDM_SHOWICON:
2175 case IDM_SHOWLWDATE:
2176 case IDM_SHOWLWTIME:
2177 case IDM_SHOWLADATE:
2178 case IDM_SHOWLATIME:
2179 case IDM_SHOWCRDATE:
2180 case IDM_SHOWCRTIME:
2181 case IDM_SHOWATTR:
2182 AdjustDetailsSwitches(hwnd,
2183 dcd->hwndLastMenu,
2184 SHORT1FROMMP(mp1),
2185 dcd->directory, NULL, dcd, FALSE);
2186 break;
2187
2188 case IDM_TREEVIEW:
2189 case IDM_ICON:
2190 case IDM_TEXT:
2191 case IDM_DETAILS:
2192 case IDM_NAME:
2193 case IDM_MINIICONS:
2194 case IDM_DETAILSTITLES:
2195 {
2196 CNRINFO cnri;
2197
2198 memset(&cnri, 0, sizeof(CNRINFO));
2199 cnri.cb = sizeof(CNRINFO);
2200 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2201 MPFROMLONG(sizeof(CNRINFO)));
2202 switch (SHORT1FROMMP(mp1)) {
2203 case IDM_TREEVIEW:
2204 if (!(cnri.flWindowAttr & CV_TREE))
2205 dcd->lastattr = cnri.flWindowAttr;
2206 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2207 CV_DETAIL | CV_NAME | CA_TREELINE));
2208 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2209 if (!dcd->firsttree)
2210 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2211 break;
2212 case IDM_ICON:
2213 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2214 CV_DETAIL | CV_NAME | CA_TREELINE));
2215 cnri.flWindowAttr |= CV_ICON;
2216 break;
2217 case IDM_NAME:
2218 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2219 CV_DETAIL | CV_NAME | CA_TREELINE));
2220 cnri.flWindowAttr |= CV_NAME;
2221 break;
2222 case IDM_TEXT:
2223 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2224 CV_DETAIL | CV_NAME | CA_TREELINE));
2225 cnri.flWindowAttr |= CV_TEXT;
2226 break;
2227 case IDM_DETAILS:
2228 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2229 CV_DETAIL | CV_NAME | CA_TREELINE));
2230 cnri.flWindowAttr |= CV_DETAIL;
2231 break;
2232 case IDM_MINIICONS:
2233 if (cnri.flWindowAttr & CV_MINI)
2234 cnri.flWindowAttr &= (~CV_MINI);
2235 else
2236 cnri.flWindowAttr |= CV_MINI;
2237 break;
2238 case IDM_DETAILSTITLES:
2239 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2240 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2241 else
2242 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2243 break;
2244 }
2245 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2246 cnri.flWindowAttr |= CV_FLOW;
2247 dcd->flWindowAttr = cnri.flWindowAttr;
2248 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2249 MPFROMLONG(CMA_FLWINDOWATTR));
2250 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2251 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2252 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2253 DIR_VIEW), dcd->flWindowAttr);
2254 }
2255 break;
2256
2257 case IDM_SAVETOLIST:
2258 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2259 SAV_FRAME, MPFROMP(&hwnd));
2260 break;
2261
2262 case IDM_SIZES:
2263 {
2264 PCNRITEM pci;
2265 CHAR path[CCHMAXPATH];
2266
2267 pci = (PCNRITEM) CurrentRecord(hwnd);
2268 if (pci && (INT) pci != -1)
2269 strcpy(path, pci->pszFileName);
2270 else
2271 strcpy(path, dcd->directory);
2272 MakeValidDir(path);
2273 WinDlgBox(HWND_DESKTOP,
2274 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2275 }
2276 break;
2277
2278 case IDM_MKDIR:
2279 {
2280 PCNRITEM pci;
2281 BOOL saved;
2282
2283 saved = fSelectedAlways;
2284 fSelectedAlways = FALSE;
2285 pci = (PCNRITEM)CurrentRecord(hwnd);
2286 // 01 Oct 07 SHL Make below selected directory or in current directory
2287 PMMkDir(dcd->hwndParent,
2288 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2289 FALSE);
2290 fSelectedAlways = saved;
2291 }
2292 break;
2293
2294 case IDM_SWITCH:
2295 if (mp2) {
2296 strcpy(dcd->previous, dcd->directory);
2297 strcpy(dcd->directory, (CHAR *)mp2);
2298 DosEnterCritSec();
2299 dcd->stopflag++;
2300 DosExitCritSec();
2301 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2302 strcpy(dcd->directory, dcd->previous);
2303 DosEnterCritSec();
2304 dcd->stopflag--;
2305 DosExitCritSec();
2306 }
2307 else if (*dcd->directory) {
2308 if (hwndMain)
2309 WinSendMsg(hwndMain,
2310 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2311 else
2312 add_udir(FALSE, dcd->directory);
2313 }
2314 }
2315 break;
2316
2317 case IDM_PARENT:
2318 {
2319 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
2320
2321 strcpy(tempname1, dcd->directory);
2322 if (tempname1[strlen(tempname1) - 1] != '\\')
2323 strcat(tempname1, "\\");
2324 strcat(tempname1, "..");
2325 DosError(FERR_DISABLEHARDERR);
2326 if (!DosQueryPathInfo(tempname1,
2327 FIL_QUERYFULLNAME,
2328 tempname2, sizeof(tempname2))) {
2329 if (stricmp(dcd->directory, tempname2)) {
2330 strcpy(dcd->previous, dcd->directory);
2331 strcpy(dcd->directory, tempname2);
2332 DosEnterCritSec();
2333 dcd->stopflag++;
2334 DosExitCritSec();
2335 if (!PostMsg(dcd->hwndObject,
2336 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2337 strcpy(dcd->directory, dcd->previous);
2338 DosEnterCritSec();
2339 dcd->stopflag--;
2340 DosExitCritSec();
2341 }
2342 else if (*dcd->directory) {
2343 if (hwndMain)
2344 WinSendMsg(hwndMain,
2345 UM_SETUSERLISTNAME,
2346 MPFROMP(dcd->directory), MPVOID);
2347 else
2348 add_udir(FALSE, dcd->directory);
2349 }
2350 }
2351 }
2352 }
2353 break;
2354
2355 case IDM_PREVIOUS:
2356 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
2357
2358 CHAR tempname[CCHMAXPATH];
2359
2360 if (IsValidDir(dcd->previous)) {
2361 strcpy(tempname, dcd->directory);
2362 strcpy(dcd->directory, dcd->previous);
2363 strcpy(dcd->previous, tempname);
2364 DosEnterCritSec();
2365 dcd->stopflag++;
2366 DosExitCritSec();
2367 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2368 strcpy(dcd->directory, dcd->previous);
2369 DosEnterCritSec();
2370 dcd->stopflag--;
2371 DosExitCritSec();
2372 }
2373 else if (*dcd->directory) {
2374 if (hwndMain)
2375 WinSendMsg(hwndMain,
2376 UM_SETUSERLISTNAME,
2377 MPFROMP(dcd->directory), MPVOID);
2378 else
2379 add_udir(FALSE, dcd->directory);
2380 }
2381 }
2382 else
2383 *dcd->previous = 0;
2384 }
2385 break;
2386
2387 case IDM_WALKDIR:
2388 {
2389 CHAR newdir[CCHMAXPATH];
2390
2391 strcpy(newdir, dcd->directory);
2392 if (!WinDlgBox(HWND_DESKTOP,
2393 dcd->hwndParent,
2394 WalkAllDlgProc,
2395 FM3ModHandle,
2396 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2397 break;
2398 if (stricmp(newdir, dcd->directory)) {
2399 strcpy(dcd->previous, dcd->directory);
2400 strcpy(dcd->directory, newdir);
2401 DosEnterCritSec();
2402 dcd->stopflag++;
2403 DosExitCritSec();
2404 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2405 strcpy(dcd->directory, dcd->previous);
2406 DosEnterCritSec();
2407 dcd->stopflag--;
2408 DosExitCritSec();
2409 }
2410 else if (*dcd->directory) {
2411 if (hwndMain)
2412 WinSendMsg(hwndMain,
2413 UM_SETUSERLISTNAME,
2414 MPFROMP(dcd->directory), MPVOID);
2415 else
2416 add_udir(FALSE, dcd->directory);
2417 }
2418 }
2419 }
2420 break;
2421
2422 case IDM_OPENICONME:
2423 OpenObject(dcd->directory, "ICON", dcd->hwndFrame);
2424 break;
2425 case IDM_OPENDETAILSME:
2426 OpenObject(dcd->directory, "DETAILS", dcd->hwndFrame);
2427 break;
2428 case IDM_OPENTREEME:
2429 OpenObject(dcd->directory, "TREE", dcd->hwndFrame);
2430 break;
2431 case IDM_OPENSETTINGSME:
2432 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2433 break;
2434
2435 case IDM_DOITYOURSELF:
2436 case IDM_UPDATE:
2437 case IDM_OPENWINDOW:
2438 case IDM_OPENSETTINGS:
2439 case IDM_OPENDEFAULT:
2440 case IDM_OPENICON:
2441 case IDM_OPENDETAILS:
2442 case IDM_OPENTREE:
2443 case IDM_OBJECT:
2444 case IDM_SHADOW:
2445 case IDM_SHADOW2:
2446 case IDM_DELETE:
2447 case IDM_PERMDELETE:
2448 case IDM_PRINT:
2449 case IDM_ATTRS:
2450 case IDM_INFO:
2451 case IDM_COPY:
2452 case IDM_MOVE:
2453 case IDM_WPSMOVE:
2454 case IDM_WPSCOPY:
2455 case IDM_WILDCOPY:
2456 case IDM_WILDMOVE:
2457 case IDM_RENAME:
2458 case IDM_COMPARE:
2459 case IDM_EAS:
2460 case IDM_SUBJECT:
2461 case IDM_VIEW:
2462 case IDM_VIEWTEXT:
2463 case IDM_VIEWBINARY:
2464 case IDM_VIEWARCHIVE:
2465 case IDM_EDIT:
2466 case IDM_EDITTEXT:
2467 case IDM_EDITBINARY:
2468 case IDM_SAVETOCLIP:
2469 case IDM_APPENDTOCLIP:
2470 case IDM_ARCHIVE:
2471 case IDM_ARCHIVEM:
2472 case IDM_EXTRACT:
2473 case IDM_MCIPLAY:
2474 case IDM_COLLECTFROMFILE:
2475 case IDM_UUDECODE:
2476 case IDM_MERGE:
2477 {
2478 LISTINFO *li;
2479 ULONG action = UM_ACTION;
2480# ifdef FORTIFY
2481 Fortify_EnterScope();
2482# endif
2483 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2484 if (li) {
2485 li->type = SHORT1FROMMP(mp1);
2486 li->hwnd = hwnd;
2487 li->list = BuildList(hwnd);
2488 switch (SHORT1FROMMP(mp1)) {
2489 case IDM_WILDMOVE:
2490 case IDM_WILDCOPY:
2491 case IDM_MOVE:
2492 case IDM_COPY:
2493 case IDM_WPSMOVE:
2494 case IDM_WPSCOPY:
2495 break;
2496 default:
2497 strcpy(li->targetpath, dcd->directory);
2498 break;
2499 }
2500 if (li->list) {
2501 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2502 if (!Collector) {
2503
2504 HWND hwndC;
2505 SWP swp;
2506
2507 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2508 !fAutoTile &&
2509 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2510 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2511 hwndC = StartCollector((fExternalCollector ||
2512 strcmp(realappname, FM3Str)) ?
2513 HWND_DESKTOP : dcd->hwndParent, 4);
2514 if (hwndC) {
2515 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2516 !fAutoTile && (!fExternalCollector &&
2517 !strcmp(realappname, FM3Str)))
2518 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2519 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2520 SWP_SHOW | SWP_ZORDER);
2521 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2522 fAutoTile && !strcmp(realappname, FM3Str))
2523 TileChildren(dcd->hwndParent, TRUE);
2524 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2525 SWP_ACTIVATE);
2526 DosSleep(100); //05 Aug 07 GKY 250
2527 }
2528 }
2529 else
2530 StartCollector(dcd->hwndParent, 4);
2531 }
2532 switch (SHORT1FROMMP(mp1)) {
2533 case IDM_APPENDTOCLIP:
2534 case IDM_SAVETOCLIP:
2535 case IDM_ARCHIVE:
2536 case IDM_ARCHIVEM:
2537 case IDM_DELETE:
2538 case IDM_PERMDELETE:
2539 case IDM_ATTRS:
2540 case IDM_PRINT:
2541 case IDM_SHADOW:
2542 case IDM_SHADOW2:
2543 case IDM_OBJECT:
2544 case IDM_VIEW:
2545 case IDM_VIEWTEXT:
2546 case IDM_VIEWBINARY:
2547 case IDM_EDIT:
2548 case IDM_EDITTEXT:
2549 case IDM_EDITBINARY:
2550 case IDM_MCIPLAY:
2551 case IDM_UPDATE:
2552 case IDM_DOITYOURSELF:
2553 case IDM_INFO:
2554 case IDM_EAS:
2555 action = UM_MASSACTION;
2556 break;
2557 }
2558 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2559 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2560 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2561 *li->targetpath = 0;
2562 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2563 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2564 FreeListInfo(li);
2565 }
2566 else if (fUnHilite)
2567 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2568 }
2569 else
2570 xfree(li, pszSrcFile, __LINE__);
2571# ifdef FORTIFY
2572 Fortify_LeaveScope();
2573# endif
2574 }
2575 }
2576 break;
2577
2578 case IDM_DRIVESMENU:
2579 if (!hwndMain)
2580 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2581 break;
2582
2583 default:
2584 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2585 return 0;
2586 else {
2587 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2588 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2589
2590 register INT x;
2591
2592 if (!cmdloaded)
2593 load_commands();
2594 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2595 if (x >= 0) {
2596 x++;
2597 RunCommand(hwnd, x);
2598 if (fUnHilite)
2599 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2600 }
2601 }
2602 }
2603 break;
2604 }
2605 }
2606 return 0;
2607
2608 case UM_FIXCNRMLE:
2609 case UM_FIXEDITNAME:
2610 return CommonCnrProc(hwnd, msg, mp1, mp2);
2611
2612 case UM_FILESMENU:
2613 {
2614 PCNRITEM pci;
2615 HWND menuHwnd = (HWND) 0;
2616
2617 pci = (PCNRITEM) CurrentRecord(hwnd);
2618 if (pci && (INT) pci != -1) {
2619 if (pci->attrFile & FILE_DIRECTORY) {
2620 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2621// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2622 }
2623 else
2624 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2625 }
2626 return MRFROMLONG(menuHwnd);
2627 }
2628
2629 case WM_CONTROL:
2630 DosError(FERR_DISABLEHARDERR);
2631 if (dcd) {
2632 switch (SHORT2FROMMP(mp1)) {
2633 case CN_COLLAPSETREE:
2634 case CN_EXPANDTREE:
2635 {
2636 PCNRITEM pci = (PCNRITEM) mp2;
2637
2638 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
2639 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
2640 struct
2641 {
2642 ULONG serial;
2643 CHAR volumelength;
2644 CHAR volumelabel[CCHMAXPATH];
2645 }
2646 volser;
2647 APIRET rc;
2648
2649 memset(&volser, 0, sizeof(volser));
2650 DosError(FERR_DISABLEHARDERR);
2651 // fixme?
2652 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2653 FSIL_VOLSER, &volser, sizeof(volser));
2654 if (rc) {
2655 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2656 GetPString(IDS_CANTFINDDIRTEXT),
2657 pci->pszFileName);
2658 DosBeep(250,100);
2659 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2660 UnFlesh(hwnd, pci);
2661 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2662 }
2663 else {
2664 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2665 !volser.serial ||
2666 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2667 volser.serial)
2668 UnFlesh(hwnd, pci);
2669 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2670 (!volser.serial ||
2671 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2672 volser.serial)) {
2673 if (Flesh(hwnd, pci) &&
2674 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2675 !dcd->suspendview && fTopDir)
2676 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2677 }
2678 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2679 }
2680 }
2681 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2682 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
2683 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2684 }
2685 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2686 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2687 }
2688 }
2689 break;
2690
2691/*
2692 case CN_PICKUP:
2693 return PickUp(hwnd,dcd->hwndObject,mp2);
2694*/
2695
2696 case CN_CONTEXTMENU:
2697 {
2698 PCNRITEM pci = (PCNRITEM) mp2;
2699
2700 if (pci) {
2701 WinSendMsg(hwnd,
2702 CM_SETRECORDEMPHASIS,
2703 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2704 MarkAll(hwnd, FALSE, FALSE, TRUE);
2705 if (pci->attrFile & FILE_DIRECTORY)
2706 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2707 else
2708 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2709 }
2710 else {
2711 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
2712 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2713 WinSendMsg(hwnd,
2714 CM_SETRECORDEMPHASIS,
2715 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2716 dcd->cnremphasized = TRUE;
2717 }
2718 }
2719 if (dcd->hwndLastMenu) {
2720 if (dcd->hwndLastMenu == DirCnrMenu) {
2721 if (dcd->flWindowAttr & CV_MINI)
2722 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2723 }
2724 if (dcd->hwndLastMenu == DirMenu)
2725 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2726 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2727 if (dcd->cnremphasized) {
2728 WinSendMsg(hwnd,
2729 CM_SETRECORDEMPHASIS,
2730 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2731 dcd->cnremphasized = TRUE;
2732 }
2733 MarkAll(hwnd, TRUE, FALSE, TRUE);
2734 }
2735 }
2736 }
2737 break;
2738
2739 case CN_DROPHELP:
2740 if (mp2) {
2741
2742 PDRAGINFO pDInfo;
2743 PCNRITEM pci;
2744 ULONG numitems;
2745 USHORT usOperation;
2746
2747 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2748 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2749 if (!DrgAccessDraginfo(pDInfo)) {
2750 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2751 GetPString(IDS_DROPERRORTEXT));
2752 }
2753 else {
2754 numitems = DrgQueryDragitemCount(pDInfo);
2755 usOperation = pDInfo->usOperation;
2756 FreeDragInfoData(hwnd, pDInfo);
2757 saymsg(MB_ENTER | MB_ICONASTERISK,
2758 hwnd,
2759 GetPString(IDS_DROPHELPHDRTEXT),
2760 GetPString(IDS_DROPHELPTEXT),
2761 numitems,
2762 &"s"[numitems == 1L],
2763 pci ? NullStr : GetPString(IDS_NOTEXT),
2764 pci ? NullStr : " ",
2765 pci ? pci->pszFileName : NullStr,
2766 pci ? " " : NullStr,
2767 GetPString((usOperation == DO_COPY) ?
2768 IDS_COPYTEXT :
2769 (usOperation == DO_LINK) ?
2770 IDS_LINKTEXT : IDS_MOVETEXT));
2771 }
2772 }
2773 return 0;
2774
2775 case CN_DRAGLEAVE:
2776 return 0;
2777
2778 case CN_DRAGAFTER:
2779 case CN_DRAGOVER:
2780 if (mp2) {
2781
2782 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2783 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2784 PCNRITEM pci;
2785 USHORT uso;
2786
2787 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2788 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2789 if (!DrgAccessDraginfo(pDInfo)) {
2790 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2791 "DrgAccessDraginfo");
2792 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2793 }
2794 if (*dcd->directory &&
2795 (driveflags[toupper(*dcd->directory) - 'A'] &
2796 DRIVE_NOTWRITEABLE)) {
2797 DrgFreeDraginfo(pDInfo);
2798 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
2799 DO_LINK); /* (compare) only */
2800 }
2801 if (pci) {
2802 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2803 DrgFreeDraginfo(pDInfo);
2804 return (MRFROM2SHORT(DOR_NODROP, 0));
2805 }
2806 uso = pDInfo->usOperation;
2807 if (uso == DO_DEFAULT)
2808 uso = fCopyDefault ? DO_COPY : DO_MOVE;
2809 if (!(pci->attrFile & FILE_DIRECTORY)) {
2810 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2811 DrgFreeDraginfo(pDInfo);
2812 return MRFROM2SHORT(DOR_NODROP, 0);
2813 }
2814 if (uso != DO_LINK &&
2815 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2816 DRIVE_NOTWRITEABLE)) {
2817
2818 ARC_TYPE *info = NULL;
2819
2820 if (!fQuickArcFind &&
2821 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2822 DRIVE_SLOW))
2823 info = find_type(pci->pszFileName, NULL);
2824 else
2825 info = quick_find_type(pci->pszFileName, NULL);
2826 if (!info || ((uso == DO_MOVE && !info->move) ||
2827 (uso == DO_COPY && !info->create))) {
2828 DrgFreeDraginfo(pDInfo);
2829 return MRFROM2SHORT(DOR_NODROP, 0);
2830 }
2831 }
2832 }
2833 }
2834
2835 /* Access DRAGITEM index to DRAGITEM
2836 * Check valid rendering mechanisms and data
2837 */
2838 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
2839 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL) ||
2840 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
2841 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) {
2842 DrgFreeDraginfo(pDInfo);
2843 if (driveflags[toupper(*dcd->directory) - 'A'] &
2844 DRIVE_NOTWRITEABLE)
2845 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2846 if (toupper(*dcd->directory) < 'C')
2847 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2848 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2849 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2850 }
2851 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2852 }
2853 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
2854
2855 case CN_INITDRAG:
2856 {
2857 BOOL wasemphasized = FALSE;
2858 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2859 PCNRITEM pci;
2860
2861 if (pcd) {
2862 pci = (PCNRITEM) pcd->pRecord;
2863 if (pci) {
2864 if ((INT) pci == -1)
2865 pci = NULL;
2866 else if (pci->rc.flRecordAttr & CRA_SELECTED)
2867 wasemphasized = TRUE;
2868 }
2869 else if (!*dcd->directory) {
2870 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2871 break;
2872 }
2873 else if (IsRoot(dcd->directory)) {
2874 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
2875 GetPString(IDS_CANTDRAGROOTDIR));
2876 break;
2877 }
2878 if (hwndStatus2) {
2879 if (pci)
2880 WinSetWindowText(hwndStatus2,
2881 GetPString(IDS_DRAGFILEOBJTEXT));
2882 else
2883 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGDIRTEXT));
2884 }
2885 if (DoFileDrag(hwnd,
2886 dcd->hwndObject,
2887 mp2,
2888 NULL,
2889 pci ? NULL : dcd->directory,
2890 pci ? TRUE : FALSE)) {
2891 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
2892 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2893 }
2894 }
2895 if (hwndStatus2) {
2896 WinSetFocus(HWND_DESKTOP, hwnd);
2897 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2898 }
2899 }
2900 }
2901 return 0;
2902
2903 case CN_DROP:
2904 if (mp2) {
2905
2906 LISTINFO *li;
2907 ULONG action = UM_ACTION;
2908
2909 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
2910 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2911 if (li) {
2912 if (li->list && li->list[0] && IsRoot(li->list[0]))
2913 li->type = DO_LINK;
2914 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2915
2916 CHECKLIST cl;
2917
2918 memset(&cl, 0, sizeof(cl));
2919 cl.size = sizeof(cl);
2920 cl.flags = li->type;
2921 cl.list = li->list;
2922 cl.cmd = li->type;
2923 cl.prompt = li->targetpath;
2924 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2925 DropListProc, FM3ModHandle,
2926 DND_FRAME, MPFROMP(&cl));
2927 if (li->type == DID_ERROR)
2928 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2929 "Drag & Drop Dialog");
2930 if (!li->type) {
2931 FreeListInfo(li);
2932 return 0;
2933 }
2934 li->list = cl.list;
2935 if (!li->list || !li->list[0]) {
2936 FreeListInfo(li);
2937 return 0;
2938 }
2939 }
2940 switch (li->type) {
2941 case DND_LAUNCH:
2942 strcat(li->targetpath, " %a");
2943 ExecOnList(dcd->hwndParent, li->targetpath,
2944 PROMPT | WINDOWED, NULL, li->list, NULL,
2945 pszSrcFile, __LINE__);
2946 FreeList(li->list);
2947 li->list = NULL;
2948 break;
2949 case DO_LINK:
2950 if (fLinkSetsIcon) {
2951 li->type = IDM_SETICON;
2952 action = UM_MASSACTION;
2953 }
2954 else
2955 li->type = IDM_COMPARE;
2956 break;
2957 case DND_EXTRACT:
2958 if (*li->targetpath && !IsFile(li->targetpath))
2959 li->type = IDM_EXTRACT;
2960 break;
2961 case DND_MOVE:
2962 li->type = IDM_MOVE;
2963 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2964 action = UM_MASSACTION;
2965 li->type = IDM_ARCHIVEM;
2966 }
2967 break;
2968 case DND_WILDMOVE:
2969 li->type = IDM_WILDMOVE;
2970 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2971 action = UM_MASSACTION;
2972 li->type = IDM_ARCHIVEM;
2973 }
2974 break;
2975 case DND_OBJECT:
2976 li->type = IDM_OBJECT;
2977 action = UM_MASSACTION;
2978 break;
2979 case DND_SHADOW:
2980 li->type = IDM_SHADOW;
2981 action = UM_MASSACTION;
2982 break;
2983 case DND_COMPARE:
2984 li->type = IDM_COMPARE;
2985 break;
2986 case DND_SETICON:
2987 action = UM_MASSACTION;
2988 li->type = IDM_SETICON;
2989 break;
2990 case DND_COPY:
2991 li->type = IDM_COPY;
2992 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2993 action = UM_MASSACTION;
2994 li->type = IDM_ARCHIVE;
2995 }
2996 break;
2997 case DND_WILDCOPY:
2998 li->type = IDM_WILDCOPY;
2999 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3000 action = UM_MASSACTION;
3001 li->type = IDM_ARCHIVE;
3002 }
3003 break;
3004 default:
3005 if (*li->arcname && li->info) {
3006 action = UM_MASSACTION;
3007 li->type =
3008 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
3009 }
3010 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
3011 action = UM_MASSACTION;
3012 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
3013 }
3014 else
3015 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
3016 break;
3017 }
3018 if (!li->list || !li->list[0])
3019 FreeListInfo(li);
3020 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
3021 FreeListInfo(li);
3022 else {
3023
3024 USHORT usop = 0;
3025
3026 switch (li->type) {
3027 case IDM_COPY:
3028 case IDM_WILDCOPY:
3029 usop = DO_COPY;
3030 break;
3031 case IDM_MOVE:
3032 case IDM_WILDMOVE:
3033 case IDM_ARCHIVEM:
3034 usop = DO_MOVE;
3035 break;
3036 }
3037 if (usop)
3038 return MRFROM2SHORT(DOR_DROP, usop);
3039 }
3040 }
3041 }
3042 return 0;
3043
3044 case CN_ENDEDIT:
3045 case CN_BEGINEDIT:
3046 {
3047 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3048 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3049
3050 if (pfi || pci) {
3051
3052 MRESULT mre;
3053
3054 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3055 if (mre != (MRESULT) - 1)
3056 return mre;
3057 }
3058 else if (!pfi && !pci)
3059 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3060 }
3061 return 0;
3062
3063 case CN_REALLOCPSZ:
3064 {
3065 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3066 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3067 HWND hwndMLE;
3068 static CHAR szData[CCHMAXPATH];
3069 CHAR testname[CCHMAXPATH];
3070
3071 if (!pci && !pfi) {
3072 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3073 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
3074 chop_at_crnl(szData);
3075 bstrip(szData);
3076 if (*szData) {
3077 if (!DosQueryPathInfo(szData,
3078 FIL_QUERYFULLNAME,
3079 testname, sizeof(testname))) {
3080 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3081 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3082 }
3083 }
3084 }
3085 }
3086 else {
3087
3088 MRESULT mre;
3089
3090 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3091 if (mre != (MRESULT) - 1)
3092 return mre;
3093 }
3094 }
3095 return 0;
3096
3097 case CN_EMPHASIS:
3098 if (!mp2)
3099 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3100 else {
3101 PNOTIFYRECORDEMPHASIS pre = mp2;
3102 PCNRITEM pci;
3103 CHAR s[CCHMAXPATHCOMP + 91], tb[81], tf[81];
3104
3105 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
3106 if (!pci) {
3107 if (hwndStatus2)
3108 WinSetWindowText(hwndStatus2, NullStr);
3109 if (fMoreButtons) {
3110 WinSetWindowText(hwndName, NullStr);
3111 WinSetWindowText(hwndDate, NullStr);
3112 WinSetWindowText(hwndAttr, NullStr);
3113 }
3114 if (hwndMain)
3115 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3116 break;
3117 }
3118 if (pre->fEmphasisMask & CRA_SELECTED) {
3119 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3120 dcd->selectedbytes += (pci->cbFile + pci->easize);
3121 dcd->selectedfiles++;
3122 }
3123 else if (dcd->selectedfiles) {
3124 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3125 dcd->selectedfiles--;
3126 }
3127 if (!dcd->suspendview) {
3128 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3129 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3130 sprintf(s, "%s / %s", tf, tb);
3131 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3132 }
3133 }
3134 if (!dcd->suspendview && hwndMain &&
3135 (pre->fEmphasisMask & CRA_CURSORED) &&
3136 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3137 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3138 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
3139 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3140 else
3141 WinSendMsg(hwndMain,
3142 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
3143 }
3144 if (!dcd->suspendview &&
3145 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3146 if (pre->fEmphasisMask & CRA_CURSORED) {
3147 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3148 if (fSplitStatus && hwndStatus2) {
3149 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3150 if (!fMoreButtons) {
3151 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
3152 tb, pci->date.year,
3153 pci->date.month, pci->date.day, pci->time.hours,
3154 pci->time.minutes, pci->time.seconds,
3155 pci->pszDispAttr, pci->pszFileName);
3156 }
3157 else {
3158 *tf = 0;
3159 if (pci->cbFile + pci->easize > 1024) {
3160 CommaFmtULL(tf, sizeof(tf),
3161 pci->cbFile + pci->easize, 'K');
3162 }
3163 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3164 tb,
3165 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3166 }
3167 WinSetWindowText(hwndStatus2, s);
3168 }
3169 if (fMoreButtons) {
3170 WinSetWindowText(hwndName, pci->pszFileName);
3171 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
3172 pci->date.year, pci->date.month,
3173 pci->date.day, pci->time.hours, pci->time.minutes,
3174 pci->time.seconds);
3175 WinSetWindowText(hwndDate, s);
3176 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3177 }
3178 }
3179 }
3180 }
3181 }
3182 break;
3183
3184 case CN_ENTER:
3185 if (mp2) {
3186
3187 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3188 FILEFINDBUF3 ffb;
3189 HDIR hDir = HDIR_CREATE;
3190 ULONG nm = 1;
3191 APIRET status = 0;
3192
3193 SetShiftState();
3194 if (pci) {
3195 if (pci->rc.flRecordAttr & CRA_INUSE)
3196 break;
3197 DosError(FERR_DISABLEHARDERR);
3198 status = DosFindFirst(pci->pszFileName,
3199 &hDir,
3200 FILE_NORMAL | FILE_DIRECTORY |
3201 FILE_ARCHIVED | FILE_READONLY |
3202 FILE_HIDDEN | FILE_SYSTEM,
3203 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
3204 priority_bumped();
3205 if (!status) {
3206 DosFindClose(hDir);
3207 if (ffb.attrFile & FILE_DIRECTORY) {
3208 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3209 PostMsg(hwnd,
3210 WM_COMMAND,
3211 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3212 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3213 (KC_CTRL | KC_SHIFT))
3214 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
3215 else if (shiftstate & KC_CTRL)
3216 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
3217 else if (shiftstate & KC_SHIFT) {
3218
3219 HWND hwndDir;
3220
3221 hwndDir = OpenDirCnr((HWND) 0,
3222 dcd->hwndParent,
3223 dcd->hwndFrame,
3224 FALSE, pci->pszFileName);
3225 if (hwndDir) {
3226 if (fMinOnOpen)
3227 WinSetWindowPos(dcd->hwndFrame,
3228 HWND_BOTTOM,
3229 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3230 if (fAutoTile)
3231 TileChildren(dcd->hwndParent, TRUE);
3232 WinSetWindowPos(hwndDir,
3233 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3234 }
3235 }
3236 else {
3237 strcpy(dcd->previous, dcd->directory);
3238 strcpy(dcd->directory, pci->pszFileName);
3239 DosEnterCritSec();
3240 dcd->stopflag++;
3241 DosExitCritSec();
3242 if (!PostMsg(dcd->hwndObject,
3243 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
3244 DosEnterCritSec();
3245 dcd->stopflag--;
3246 DosExitCritSec();
3247 }
3248 else if (*dcd->directory) {
3249 if (hwndMain)
3250 WinSendMsg(hwndMain,
3251 UM_SETUSERLISTNAME,
3252 MPFROMP(dcd->directory), MPVOID);
3253 else
3254 add_udir(FALSE, dcd->directory);
3255 }
3256 }
3257 }
3258 else {
3259
3260 SWP swp;
3261
3262 WinQueryWindowPos(dcd->hwndFrame, &swp);
3263 WinSendMsg(hwnd,
3264 CM_SETRECORDEMPHASIS,
3265 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3266 DefaultViewKeys(hwnd,
3267 dcd->hwndFrame,
3268 dcd->hwndParent, &swp, pci->pszFileName);
3269 WinSendMsg(hwnd,
3270 CM_SETRECORDEMPHASIS,
3271 MPFROMP(pci),
3272 MPFROM2SHORT(FALSE,
3273 CRA_INUSE |
3274 ((fUnHilite) ? CRA_SELECTED : 0)));
3275 }
3276 }
3277 else {
3278 if (!*dcd->directory || IsValidDir(dcd->directory)) {
3279 NotifyError(pci->pszFileName, status);
3280 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
3281 if (hwndStatus)
3282 WinSetWindowText(hwndStatus,
3283 GetPString(IDS_RESCANSUGGESTEDTEXT));
3284 }
3285 else {
3286 DosEnterCritSec();
3287 dcd->stopflag++;
3288 DosExitCritSec();
3289 if (!PostMsg(dcd->hwndObject,
3290 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3291 DosEnterCritSec();
3292 dcd->stopflag--;
3293 DosExitCritSec();
3294 }
3295 else if (*dcd->directory) {
3296 if (hwndMain)
3297 WinSendMsg(hwndMain,
3298 UM_SETUSERLISTNAME,
3299 MPFROMP(dcd->directory), MPVOID);
3300 else
3301 add_udir(FALSE, dcd->directory);
3302 }
3303 }
3304 }
3305 }
3306 else if (*dcd->directory)
3307 OpenObject(dcd->directory, Default, hwnd);
3308 } // CN_ENTER
3309 break;
3310 } // switch mp1
3311 break;
3312 } // if dcd
3313 return 0;
3314
3315 case UM_LOADFILE:
3316 if (dcd && mp2) {
3317
3318 HWND ret = StartMLEEditor(dcd->hwndParent,
3319 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
3320 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
3321 return MRFROMLONG(ret);
3322 }
3323 return 0;
3324
3325 case WM_SAVEAPPLICATION:
3326 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3327
3328 SWP swp;
3329
3330 WinQueryWindowPos(dcd->hwndFrame, &swp);
3331 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3332 PrfWriteProfileData(fmprof,
3333 appname, "VDirSizePos", &swp, sizeof(swp));
3334 }
3335 break;
3336
3337 case WM_CLOSE:
3338 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3339 if (LastDir == hwnd)
3340 LastDir = (HWND) 0;
3341 if (dcd) {
3342 dcd->stopflag++;
3343 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3344 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3345 if (dcd->hwndObject) {
3346 // Ensure object window destroy does not attempt duplicate clean up
3347 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3348 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3349 Win_Error(dcd->hwndObject, hwnd, pszSrcFile, __LINE__, "hwndObject WinPostMsg failed");
3350 }
3351 if (dcd->hwndRestore)
3352 WinSetWindowPos(dcd->hwndRestore,
3353 HWND_TOP,
3354 0,
3355 0,
3356 0,
3357 0,
3358 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3359 FreeList(dcd->lastselection);
3360 xfree(dcd, pszSrcFile, __LINE__);
3361# ifdef FORTIFY
3362 Fortify_LeaveScope();
3363# endif
3364 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3365 DosPostEventSem(CompactSem);
3366 }
3367 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3368 QW_PARENT));
3369 return 0;
3370
3371 case WM_DESTROY:
3372 if (DirMenu)
3373 WinDestroyWindow(DirMenu);
3374 if (DirCnrMenu)
3375 WinDestroyWindow(DirCnrMenu);
3376 if (FileMenu)
3377 WinDestroyWindow(FileMenu);
3378 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3379 EmptyCnr(hwnd);
3380 break;
3381 } // switch
3382
3383 if (dcd && dcd->oldproc) {
3384 // 11 May 08 SHL fixme debug fortify
3385 if ((ULONG)dcd->oldproc == 0xa9a9a9a9)
3386 DbgMsg(pszSrcFile, __LINE__, "calling oldproc after dcd free msg %x mp1 %x mp2 %x", msg, mp1, mp2);
3387 return dcd->oldproc(hwnd, msg, mp1, mp2);
3388 }
3389 else
3390 return PFNWPCnr(hwnd, msg, mp1, mp2);
3391}
3392
3393HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3394 ULONG flags)
3395{
3396 /* bitmapped flags:
3397 * 0x00000001 = don't close app when window closes
3398 * 0x00000002 = no frame controls
3399 */
3400
3401 HWND hwndFrame = (HWND) 0, hwndClient;
3402 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3403 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3404 USHORT id;
3405 static USHORT idinc = 0;
3406 DIRCNRDATA *dcd;
3407 static BOOL first = FALSE;
3408
3409 if (flags & 2)
3410 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3411 FCF_MINMAX | FCF_ICON));
3412 if (!idinc)
3413 idinc = (rand() % 100);
3414 if (!hwndParent)
3415 hwndParent = HWND_DESKTOP;
3416 if (ParentIsDesktop(hwndParent, hwndParent))
3417 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3418 if (!hwndMain && !first) {
3419 if (DirCnrMenu) {
3420
3421 MENUITEM mi;
3422
3423 memset(&mi, 0, sizeof(mi));
3424 WinSendMsg(DirCnrMenu,
3425 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
3426 mi.iPosition = MIT_END;
3427 mi.afStyle = MIS_TEXT;
3428 mi.id = IDM_DRIVESMENU;
3429 WinSendMsg(DirCnrMenu,
3430 MM_INSERTITEM,
3431 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3432 }
3433 first = TRUE;
3434 }
3435 if (directory) {
3436 hwndFrame = WinCreateStdWindow(hwndParent,
3437 WS_VISIBLE,
3438 &FrameFlags,
3439 WC_DIRCONTAINER,
3440 NULL,
3441 WS_VISIBLE | fwsAnimate,
3442 FM3ModHandle, DIR_FRAME, &hwndClient);
3443 if (hwndFrame && hwndClient) {
3444 id = DIR_FRAME + idinc++;
3445 if (idinc > 99)
3446 idinc = 0;
3447 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3448# ifdef FORTIFY
3449 Fortify_EnterScope();
3450# endif
3451 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3452 if (!dcd) {
3453 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3454 hwndFrame = (HWND) 0;
3455 }
3456 else {
3457 dcd->size = sizeof(DIRCNRDATA);
3458 dcd->id = id;
3459 dcd->type = DIR_FRAME;
3460 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3461 dcd->hwndFrame = hwndFrame;
3462 dcd->hwndClient = hwndClient;
3463 dcd->hwndRestore = hwndRestore;
3464 dcd->dontclose = ((flags & 1) != 0);
3465 dcd->detailslongname = detailslongname;
3466 dcd->detailssubject = detailssubject;
3467 dcd->detailsea = detailsea;
3468 dcd->detailssize = detailssize;
3469 dcd->detailsicon = detailsicon;
3470 dcd->detailsattr = detailsattr;
3471 dcd->detailscrdate = detailscrdate;
3472 dcd->detailscrtime = detailscrtime;
3473 dcd->detailslwdate = detailslwdate;
3474 dcd->detailslwtime = detailslwtime;
3475 dcd->detailsladate = detailsladate;
3476 dcd->detailslatime = detailslatime;
3477 strcpy(dcd->directory, directory);
3478 add_udir(FALSE, directory);
3479 {
3480 PFNWP oldproc;
3481
3482 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3483 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3484 }
3485 dcd->hwndCnr = WinCreateWindow(hwndClient,
3486 WC_CONTAINER,
3487 NULL,
3488 CCS_AUTOPOSITION | CCS_MINIICONS |
3489 CCS_MINIRECORDCORE | ulCnrType |
3490 WS_VISIBLE,
3491 0,
3492 0,
3493 0,
3494 0,
3495 hwndClient,
3496 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3497 if (!dcd->hwndCnr) {
3498 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3499 IDS_WINCREATEWINDOW);
3500 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3501 xfree(dcd, pszSrcFile, __LINE__);
3502# ifdef FORTIFY
3503 Fortify_LeaveScope();
3504# endif
3505 hwndFrame = (HWND) 0;
3506 }
3507 else {
3508 RestorePresParams(dcd->hwndCnr, "DirCnr");
3509 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3510 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3511 (PFNWP) DirCnrWndProc);
3512 {
3513 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3514 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3515 };
3516
3517 if (!(flags & 2))
3518 ids[6] = 0;
3519 CommonCreateTextChildren(dcd->hwndClient,
3520 WC_DIRSTATUS, ids);
3521 }
3522 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3523 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3524 if (FrameFlags & FCF_TASKLIST) {
3525
3526 SWP swp, swpD;
3527 ULONG size = sizeof(swp);
3528 LONG cxScreen, cyScreen;
3529
3530 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3531 if (PrfQueryProfileData(fmprof,
3532 appname, "VDirSizePos", &swpD, &size)) {
3533 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3534 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3535 if (swp.x + swpD.cx > cxScreen)
3536 swp.x = cxScreen - swpD.cx;
3537 if (swp.y + swpD.cy > cyScreen)
3538 swp.y = cyScreen - swpD.cy;
3539 swp.cx = swpD.cx;
3540 swp.cy = swpD.cy;
3541 }
3542 WinSetWindowPos(hwndFrame,
3543 HWND_TOP,
3544 swp.x,
3545 swp.y,
3546 swp.cx,
3547 swp.cy,
3548 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3549 SWP_ACTIVATE);
3550 }
3551 }
3552 }
3553 }
3554 }
3555 return hwndFrame;
3556}
3557
3558#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3559#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3560#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.