source: trunk/dll/dircnrs.c@ 1084

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

Added ability to save/append either the full path name (already present) or just the filename to the clipboard. Changed the menu text to make these easier to find. Removed the final return/newline from the list. Ticket 137

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