source: trunk/dll/dircnrs.c@ 1120

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

Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if less than 10 KiB (It hangs and can't be closed) (Ticket 214) Also some cleanup of the error messages for CheckDriveSpaceAvail.

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