source: trunk/dll/dircnrs.c@ 1036

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

More fortify changes eliminated the leave scope wrapper except in mainwnd.c Wrapper only unlaods stuuff (archivers, commands, etc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 92.9 KB
Line 
1
2/***********************************************************************
3
4 $Id: dircnrs.c 1036 2008-07-01 22:53:51Z 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# ifdef FORTIFY
2499 Fortify_EnterScope();
2500# endif
2501 if (li->list) {
2502 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2503 if (!Collector) {
2504
2505 HWND hwndC;
2506 SWP swp;
2507
2508 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2509 !fAutoTile &&
2510 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2511 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2512 hwndC = StartCollector((fExternalCollector ||
2513 strcmp(realappname, FM3Str)) ?
2514 HWND_DESKTOP : dcd->hwndParent, 4);
2515 if (hwndC) {
2516 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2517 !fAutoTile && (!fExternalCollector &&
2518 !strcmp(realappname, FM3Str)))
2519 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2520 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2521 SWP_SHOW | SWP_ZORDER);
2522 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2523 fAutoTile && !strcmp(realappname, FM3Str))
2524 TileChildren(dcd->hwndParent, TRUE);
2525 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2526 SWP_ACTIVATE);
2527 DosSleep(100); //05 Aug 07 GKY 250
2528 }
2529 }
2530 else
2531 StartCollector(dcd->hwndParent, 4);
2532 }
2533 switch (SHORT1FROMMP(mp1)) {
2534 case IDM_APPENDTOCLIP:
2535 case IDM_SAVETOCLIP:
2536 case IDM_ARCHIVE:
2537 case IDM_ARCHIVEM:
2538 case IDM_DELETE:
2539 case IDM_PERMDELETE:
2540 case IDM_ATTRS:
2541 case IDM_PRINT:
2542 case IDM_SHADOW:
2543 case IDM_SHADOW2:
2544 case IDM_OBJECT:
2545 case IDM_VIEW:
2546 case IDM_VIEWTEXT:
2547 case IDM_VIEWBINARY:
2548 case IDM_EDIT:
2549 case IDM_EDITTEXT:
2550 case IDM_EDITBINARY:
2551 case IDM_MCIPLAY:
2552 case IDM_UPDATE:
2553 case IDM_DOITYOURSELF:
2554 case IDM_INFO:
2555 case IDM_EAS:
2556 action = UM_MASSACTION;
2557 break;
2558 }
2559 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2560 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2561 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2562 *li->targetpath = 0;
2563 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2564 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2565 FreeListInfo(li);
2566 }
2567 else if (fUnHilite)
2568 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2569 }
2570 else
2571 xfree(li, pszSrcFile, __LINE__);
2572# ifdef FORTIFY
2573 Fortify_LeaveScope();
2574# endif
2575 }
2576 }
2577 break;
2578
2579 case IDM_DRIVESMENU:
2580 if (!hwndMain)
2581 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2582 break;
2583
2584 default:
2585 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2586 return 0;
2587 else {
2588 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2589 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2590
2591 register INT x;
2592
2593 if (!cmdloaded)
2594 load_commands();
2595 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2596 if (x >= 0) {
2597 x++;
2598 RunCommand(hwnd, x);
2599 if (fUnHilite)
2600 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2601 }
2602 }
2603 }
2604 break;
2605 }
2606 }
2607 return 0;
2608
2609 case UM_FIXCNRMLE:
2610 case UM_FIXEDITNAME:
2611 return CommonCnrProc(hwnd, msg, mp1, mp2);
2612
2613 case UM_FILESMENU:
2614 {
2615 PCNRITEM pci;
2616 HWND menuHwnd = (HWND) 0;
2617
2618 pci = (PCNRITEM) CurrentRecord(hwnd);
2619 if (pci && (INT) pci != -1) {
2620 if (pci->attrFile & FILE_DIRECTORY) {
2621 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2622// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2623 }
2624 else
2625 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2626 }
2627 return MRFROMLONG(menuHwnd);
2628 }
2629
2630 case WM_CONTROL:
2631 DosError(FERR_DISABLEHARDERR);
2632 if (dcd) {
2633 switch (SHORT2FROMMP(mp1)) {
2634 case CN_COLLAPSETREE:
2635 case CN_EXPANDTREE:
2636 {
2637 PCNRITEM pci = (PCNRITEM) mp2;
2638
2639 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
2640 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
2641 struct
2642 {
2643 ULONG serial;
2644 CHAR volumelength;
2645 CHAR volumelabel[CCHMAXPATH];
2646 }
2647 volser;
2648 APIRET rc;
2649
2650 memset(&volser, 0, sizeof(volser));
2651 DosError(FERR_DISABLEHARDERR);
2652 // fixme?
2653 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2654 FSIL_VOLSER, &volser, sizeof(volser));
2655 if (rc) {
2656 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2657 GetPString(IDS_CANTFINDDIRTEXT),
2658 pci->pszFileName);
2659 DosBeep(250,100);
2660 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2661 UnFlesh(hwnd, pci);
2662 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2663 }
2664 else {
2665 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2666 !volser.serial ||
2667 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2668 volser.serial)
2669 UnFlesh(hwnd, pci);
2670 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2671 (!volser.serial ||
2672 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2673 volser.serial)) {
2674 if (Flesh(hwnd, pci) &&
2675 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2676 !dcd->suspendview && fTopDir)
2677 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2678 }
2679 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2680 }
2681 }
2682 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2683 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
2684 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2685 }
2686 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2687 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2688 }
2689 }
2690 break;
2691
2692/*
2693 case CN_PICKUP:
2694 return PickUp(hwnd,dcd->hwndObject,mp2);
2695*/
2696
2697 case CN_CONTEXTMENU:
2698 {
2699 PCNRITEM pci = (PCNRITEM) mp2;
2700
2701 if (pci) {
2702 WinSendMsg(hwnd,
2703 CM_SETRECORDEMPHASIS,
2704 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2705 MarkAll(hwnd, FALSE, FALSE, TRUE);
2706 if (pci->attrFile & FILE_DIRECTORY)
2707 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2708 else
2709 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2710 }
2711 else {
2712 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
2713 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2714 WinSendMsg(hwnd,
2715 CM_SETRECORDEMPHASIS,
2716 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2717 dcd->cnremphasized = TRUE;
2718 }
2719 }
2720 if (dcd->hwndLastMenu) {
2721 if (dcd->hwndLastMenu == DirCnrMenu) {
2722 if (dcd->flWindowAttr & CV_MINI)
2723 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2724 }
2725 if (dcd->hwndLastMenu == DirMenu)
2726 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2727 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2728 if (dcd->cnremphasized) {
2729 WinSendMsg(hwnd,
2730 CM_SETRECORDEMPHASIS,
2731 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2732 dcd->cnremphasized = TRUE;
2733 }
2734 MarkAll(hwnd, TRUE, FALSE, TRUE);
2735 }
2736 }
2737 }
2738 break;
2739
2740 case CN_DROPHELP:
2741 if (mp2) {
2742
2743 PDRAGINFO pDInfo;
2744 PCNRITEM pci;
2745 ULONG numitems;
2746 USHORT usOperation;
2747
2748 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2749 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2750 if (!DrgAccessDraginfo(pDInfo)) {
2751 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2752 GetPString(IDS_DROPERRORTEXT));
2753 }
2754 else {
2755 numitems = DrgQueryDragitemCount(pDInfo);
2756 usOperation = pDInfo->usOperation;
2757 FreeDragInfoData(hwnd, pDInfo);
2758 saymsg(MB_ENTER | MB_ICONASTERISK,
2759 hwnd,
2760 GetPString(IDS_DROPHELPHDRTEXT),
2761 GetPString(IDS_DROPHELPTEXT),
2762 numitems,
2763 &"s"[numitems == 1L],
2764 pci ? NullStr : GetPString(IDS_NOTEXT),
2765 pci ? NullStr : " ",
2766 pci ? pci->pszFileName : NullStr,
2767 pci ? " " : NullStr,
2768 GetPString((usOperation == DO_COPY) ?
2769 IDS_COPYTEXT :
2770 (usOperation == DO_LINK) ?
2771 IDS_LINKTEXT : IDS_MOVETEXT));
2772 }
2773 }
2774 return 0;
2775
2776 case CN_DRAGLEAVE:
2777 return 0;
2778
2779 case CN_DRAGAFTER:
2780 case CN_DRAGOVER:
2781 if (mp2) {
2782
2783 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2784 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2785 PCNRITEM pci;
2786 USHORT uso;
2787
2788 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2789 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2790 if (!DrgAccessDraginfo(pDInfo)) {
2791 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2792 "DrgAccessDraginfo");
2793 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2794 }
2795 if (*dcd->directory &&
2796 (driveflags[toupper(*dcd->directory) - 'A'] &
2797 DRIVE_NOTWRITEABLE)) {
2798 DrgFreeDraginfo(pDInfo);
2799 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
2800 DO_LINK); /* (compare) only */
2801 }
2802 if (pci) {
2803 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2804 DrgFreeDraginfo(pDInfo);
2805 return (MRFROM2SHORT(DOR_NODROP, 0));
2806 }
2807 uso = pDInfo->usOperation;
2808 if (uso == DO_DEFAULT)
2809 uso = fCopyDefault ? DO_COPY : DO_MOVE;
2810 if (!(pci->attrFile & FILE_DIRECTORY)) {
2811 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2812 DrgFreeDraginfo(pDInfo);
2813 return MRFROM2SHORT(DOR_NODROP, 0);
2814 }
2815 if (uso != DO_LINK &&
2816 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2817 DRIVE_NOTWRITEABLE)) {
2818
2819 ARC_TYPE *info = NULL;
2820
2821 if (!fQuickArcFind &&
2822 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2823 DRIVE_SLOW))
2824 info = find_type(pci->pszFileName, NULL);
2825 else
2826 info = quick_find_type(pci->pszFileName, NULL);
2827 if (!info || ((uso == DO_MOVE && !info->move) ||
2828 (uso == DO_COPY && !info->create))) {
2829 DrgFreeDraginfo(pDInfo);
2830 return MRFROM2SHORT(DOR_NODROP, 0);
2831 }
2832 }
2833 }
2834 }
2835
2836 /* Access DRAGITEM index to DRAGITEM
2837 * Check valid rendering mechanisms and data
2838 */
2839 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
2840 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL) ||
2841 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
2842 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) {
2843 DrgFreeDraginfo(pDInfo);
2844 if (driveflags[toupper(*dcd->directory) - 'A'] &
2845 DRIVE_NOTWRITEABLE)
2846 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2847 if (toupper(*dcd->directory) < 'C')
2848 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2849 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2850 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2851 }
2852 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2853 }
2854 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
2855
2856 case CN_INITDRAG:
2857 {
2858 BOOL wasemphasized = FALSE;
2859 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2860 PCNRITEM pci;
2861
2862 if (pcd) {
2863 pci = (PCNRITEM) pcd->pRecord;
2864 if (pci) {
2865 if ((INT) pci == -1)
2866 pci = NULL;
2867 else if (pci->rc.flRecordAttr & CRA_SELECTED)
2868 wasemphasized = TRUE;
2869 }
2870 else if (!*dcd->directory) {
2871 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2872 break;
2873 }
2874 else if (IsRoot(dcd->directory)) {
2875 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
2876 GetPString(IDS_CANTDRAGROOTDIR));
2877 break;
2878 }
2879 if (hwndStatus2) {
2880 if (pci)
2881 WinSetWindowText(hwndStatus2,
2882 GetPString(IDS_DRAGFILEOBJTEXT));
2883 else
2884 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGDIRTEXT));
2885 }
2886 if (DoFileDrag(hwnd,
2887 dcd->hwndObject,
2888 mp2,
2889 NULL,
2890 pci ? NULL : dcd->directory,
2891 pci ? TRUE : FALSE)) {
2892 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
2893 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2894 }
2895 }
2896 if (hwndStatus2) {
2897 WinSetFocus(HWND_DESKTOP, hwnd);
2898 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2899 }
2900 }
2901 }
2902 return 0;
2903
2904 case CN_DROP:
2905 if (mp2) {
2906
2907 LISTINFO *li;
2908 ULONG action = UM_ACTION;
2909
2910 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
2911 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2912 if (li) {
2913 if (li->list && li->list[0] && IsRoot(li->list[0]))
2914 li->type = DO_LINK;
2915 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2916
2917 CHECKLIST cl;
2918
2919 memset(&cl, 0, sizeof(cl));
2920 cl.size = sizeof(cl);
2921 cl.flags = li->type;
2922 cl.list = li->list;
2923 cl.cmd = li->type;
2924 cl.prompt = li->targetpath;
2925 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2926 DropListProc, FM3ModHandle,
2927 DND_FRAME, MPFROMP(&cl));
2928 if (li->type == DID_ERROR)
2929 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2930 "Drag & Drop Dialog");
2931 if (!li->type) {
2932 FreeListInfo(li);
2933 return 0;
2934 }
2935 li->list = cl.list;
2936 if (!li->list || !li->list[0]) {
2937 FreeListInfo(li);
2938 return 0;
2939 }
2940 }
2941 switch (li->type) {
2942 case DND_LAUNCH:
2943 strcat(li->targetpath, " %a");
2944 ExecOnList(dcd->hwndParent, li->targetpath,
2945 PROMPT | WINDOWED, NULL, li->list, NULL,
2946 pszSrcFile, __LINE__);
2947 FreeList(li->list);
2948 li->list = NULL;
2949 break;
2950 case DO_LINK:
2951 if (fLinkSetsIcon) {
2952 li->type = IDM_SETICON;
2953 action = UM_MASSACTION;
2954 }
2955 else
2956 li->type = IDM_COMPARE;
2957 break;
2958 case DND_EXTRACT:
2959 if (*li->targetpath && !IsFile(li->targetpath))
2960 li->type = IDM_EXTRACT;
2961 break;
2962 case DND_MOVE:
2963 li->type = IDM_MOVE;
2964 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2965 action = UM_MASSACTION;
2966 li->type = IDM_ARCHIVEM;
2967 }
2968 break;
2969 case DND_WILDMOVE:
2970 li->type = IDM_WILDMOVE;
2971 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2972 action = UM_MASSACTION;
2973 li->type = IDM_ARCHIVEM;
2974 }
2975 break;
2976 case DND_OBJECT:
2977 li->type = IDM_OBJECT;
2978 action = UM_MASSACTION;
2979 break;
2980 case DND_SHADOW:
2981 li->type = IDM_SHADOW;
2982 action = UM_MASSACTION;
2983 break;
2984 case DND_COMPARE:
2985 li->type = IDM_COMPARE;
2986 break;
2987 case DND_SETICON:
2988 action = UM_MASSACTION;
2989 li->type = IDM_SETICON;
2990 break;
2991 case DND_COPY:
2992 li->type = IDM_COPY;
2993 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2994 action = UM_MASSACTION;
2995 li->type = IDM_ARCHIVE;
2996 }
2997 break;
2998 case DND_WILDCOPY:
2999 li->type = IDM_WILDCOPY;
3000 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3001 action = UM_MASSACTION;
3002 li->type = IDM_ARCHIVE;
3003 }
3004 break;
3005 default:
3006 if (*li->arcname && li->info) {
3007 action = UM_MASSACTION;
3008 li->type =
3009 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
3010 }
3011 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
3012 action = UM_MASSACTION;
3013 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
3014 }
3015 else
3016 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
3017 break;
3018 }
3019 if (!li->list || !li->list[0])
3020 FreeListInfo(li);
3021 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
3022 FreeListInfo(li);
3023 else {
3024
3025 USHORT usop = 0;
3026
3027 switch (li->type) {
3028 case IDM_COPY:
3029 case IDM_WILDCOPY:
3030 usop = DO_COPY;
3031 break;
3032 case IDM_MOVE:
3033 case IDM_WILDMOVE:
3034 case IDM_ARCHIVEM:
3035 usop = DO_MOVE;
3036 break;
3037 }
3038 if (usop)
3039 return MRFROM2SHORT(DOR_DROP, usop);
3040 }
3041 }
3042 }
3043 return 0;
3044
3045 case CN_ENDEDIT:
3046 case CN_BEGINEDIT:
3047 {
3048 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3049 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3050
3051 if (pfi || pci) {
3052
3053 MRESULT mre;
3054
3055 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3056 if (mre != (MRESULT) - 1)
3057 return mre;
3058 }
3059 else if (!pfi && !pci)
3060 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3061 }
3062 return 0;
3063
3064 case CN_REALLOCPSZ:
3065 {
3066 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3067 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3068 HWND hwndMLE;
3069 static CHAR szData[CCHMAXPATH];
3070 CHAR testname[CCHMAXPATH];
3071
3072 if (!pci && !pfi) {
3073 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3074 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
3075 chop_at_crnl(szData);
3076 bstrip(szData);
3077 if (*szData) {
3078 if (!DosQueryPathInfo(szData,
3079 FIL_QUERYFULLNAME,
3080 testname, sizeof(testname))) {
3081 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3082 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3083 }
3084 }
3085 }
3086 }
3087 else {
3088
3089 MRESULT mre;
3090
3091 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3092 if (mre != (MRESULT) - 1)
3093 return mre;
3094 }
3095 }
3096 return 0;
3097
3098 case CN_EMPHASIS:
3099 if (!mp2)
3100 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3101 else {
3102 PNOTIFYRECORDEMPHASIS pre = mp2;
3103 PCNRITEM pci;
3104 CHAR s[CCHMAXPATHCOMP + 91], tb[81], tf[81];
3105
3106 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
3107 if (!pci) {
3108 if (hwndStatus2)
3109 WinSetWindowText(hwndStatus2, NullStr);
3110 if (fMoreButtons) {
3111 WinSetWindowText(hwndName, NullStr);
3112 WinSetWindowText(hwndDate, NullStr);
3113 WinSetWindowText(hwndAttr, NullStr);
3114 }
3115 if (hwndMain)
3116 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3117 break;
3118 }
3119 if (pre->fEmphasisMask & CRA_SELECTED) {
3120 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3121 dcd->selectedbytes += (pci->cbFile + pci->easize);
3122 dcd->selectedfiles++;
3123 }
3124 else if (dcd->selectedfiles) {
3125 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3126 dcd->selectedfiles--;
3127 }
3128 if (!dcd->suspendview) {
3129 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3130 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3131 sprintf(s, "%s / %s", tf, tb);
3132 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3133 }
3134 }
3135 if (!dcd->suspendview && hwndMain &&
3136 (pre->fEmphasisMask & CRA_CURSORED) &&
3137 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3138 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3139 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
3140 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3141 else
3142 WinSendMsg(hwndMain,
3143 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
3144 }
3145 if (!dcd->suspendview &&
3146 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3147 if (pre->fEmphasisMask & CRA_CURSORED) {
3148 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3149 if (fSplitStatus && hwndStatus2) {
3150 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3151 if (!fMoreButtons) {
3152 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
3153 tb, pci->date.year,
3154 pci->date.month, pci->date.day, pci->time.hours,
3155 pci->time.minutes, pci->time.seconds,
3156 pci->pszDispAttr, pci->pszFileName);
3157 }
3158 else {
3159 *tf = 0;
3160 if (pci->cbFile + pci->easize > 1024) {
3161 CommaFmtULL(tf, sizeof(tf),
3162 pci->cbFile + pci->easize, 'K');
3163 }
3164 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3165 tb,
3166 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3167 }
3168 WinSetWindowText(hwndStatus2, s);
3169 }
3170 if (fMoreButtons) {
3171 WinSetWindowText(hwndName, pci->pszFileName);
3172 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
3173 pci->date.year, pci->date.month,
3174 pci->date.day, pci->time.hours, pci->time.minutes,
3175 pci->time.seconds);
3176 WinSetWindowText(hwndDate, s);
3177 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3178 }
3179 }
3180 }
3181 }
3182 }
3183 break;
3184
3185 case CN_ENTER:
3186 if (mp2) {
3187
3188 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3189 FILEFINDBUF3 ffb;
3190 HDIR hDir = HDIR_CREATE;
3191 ULONG nm = 1;
3192 APIRET status = 0;
3193
3194 SetShiftState();
3195 if (pci) {
3196 if (pci->rc.flRecordAttr & CRA_INUSE)
3197 break;
3198 DosError(FERR_DISABLEHARDERR);
3199 status = DosFindFirst(pci->pszFileName,
3200 &hDir,
3201 FILE_NORMAL | FILE_DIRECTORY |
3202 FILE_ARCHIVED | FILE_READONLY |
3203 FILE_HIDDEN | FILE_SYSTEM,
3204 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
3205 priority_bumped();
3206 if (!status) {
3207 DosFindClose(hDir);
3208 if (ffb.attrFile & FILE_DIRECTORY) {
3209 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3210 PostMsg(hwnd,
3211 WM_COMMAND,
3212 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3213 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3214 (KC_CTRL | KC_SHIFT))
3215 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
3216 else if (shiftstate & KC_CTRL)
3217 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
3218 else if (shiftstate & KC_SHIFT) {
3219
3220 HWND hwndDir;
3221
3222 hwndDir = OpenDirCnr((HWND) 0,
3223 dcd->hwndParent,
3224 dcd->hwndFrame,
3225 FALSE, pci->pszFileName);
3226 if (hwndDir) {
3227 if (fMinOnOpen)
3228 WinSetWindowPos(dcd->hwndFrame,
3229 HWND_BOTTOM,
3230 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3231 if (fAutoTile)
3232 TileChildren(dcd->hwndParent, TRUE);
3233 WinSetWindowPos(hwndDir,
3234 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3235 }
3236 }
3237 else {
3238 strcpy(dcd->previous, dcd->directory);
3239 strcpy(dcd->directory, pci->pszFileName);
3240 DosEnterCritSec();
3241 dcd->stopflag++;
3242 DosExitCritSec();
3243 if (!PostMsg(dcd->hwndObject,
3244 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
3245 DosEnterCritSec();
3246 dcd->stopflag--;
3247 DosExitCritSec();
3248 }
3249 else if (*dcd->directory) {
3250 if (hwndMain)
3251 WinSendMsg(hwndMain,
3252 UM_SETUSERLISTNAME,
3253 MPFROMP(dcd->directory), MPVOID);
3254 else
3255 add_udir(FALSE, dcd->directory);
3256 }
3257 }
3258 }
3259 else {
3260
3261 SWP swp;
3262
3263 WinQueryWindowPos(dcd->hwndFrame, &swp);
3264 WinSendMsg(hwnd,
3265 CM_SETRECORDEMPHASIS,
3266 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3267 DefaultViewKeys(hwnd,
3268 dcd->hwndFrame,
3269 dcd->hwndParent, &swp, pci->pszFileName);
3270 WinSendMsg(hwnd,
3271 CM_SETRECORDEMPHASIS,
3272 MPFROMP(pci),
3273 MPFROM2SHORT(FALSE,
3274 CRA_INUSE |
3275 ((fUnHilite) ? CRA_SELECTED : 0)));
3276 }
3277 }
3278 else {
3279 if (!*dcd->directory || IsValidDir(dcd->directory)) {
3280 NotifyError(pci->pszFileName, status);
3281 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
3282 if (hwndStatus)
3283 WinSetWindowText(hwndStatus,
3284 GetPString(IDS_RESCANSUGGESTEDTEXT));
3285 }
3286 else {
3287 DosEnterCritSec();
3288 dcd->stopflag++;
3289 DosExitCritSec();
3290 if (!PostMsg(dcd->hwndObject,
3291 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3292 DosEnterCritSec();
3293 dcd->stopflag--;
3294 DosExitCritSec();
3295 }
3296 else if (*dcd->directory) {
3297 if (hwndMain)
3298 WinSendMsg(hwndMain,
3299 UM_SETUSERLISTNAME,
3300 MPFROMP(dcd->directory), MPVOID);
3301 else
3302 add_udir(FALSE, dcd->directory);
3303 }
3304 }
3305 }
3306 }
3307 else if (*dcd->directory)
3308 OpenObject(dcd->directory, Default, hwnd);
3309 } // CN_ENTER
3310 break;
3311 } // switch mp1
3312 break;
3313 } // if dcd
3314 return 0;
3315
3316 case UM_LOADFILE:
3317 if (dcd && mp2) {
3318
3319 HWND ret = StartMLEEditor(dcd->hwndParent,
3320 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
3321 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
3322# ifdef FORTIFY
3323 Fortify_LeaveScope();
3324# endif
3325 return MRFROMLONG(ret);
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.