source: trunk/dll/dircnrs.c@ 1082

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

Changes so FM2 will use TMP/TEMP directory for all temp files; Replaced save_dir2 with global variable so BldFullPathName could easily replace code that performed the same function; Added #ifdef FORTIFY to free_ function that are only used when fortified.

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