source: trunk/dll/dircnrs.c@ 1037

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

Newview is used used when view is selected from menus in dircnrs, collector, arccnrs etc (ticket 244); Removed Fortify_Leavescope wrapper other minor fortify changes.

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