source: trunk/dll/dircnrs.c@ 1038

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

More fortify cleanup

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