source: trunk/dll/dircnrs.c@ 1017

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

fortify updates for threads dble free fix

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