source: trunk/dll/dircnrs.c@ 1113

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

Use pszDisplayName for display in dirsize.c change free code to free it; fix memory leak in dirsize. (Ticket 269)

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