source: trunk/dll/dircnrs.c@ 1016

Last change on this file since 1016 was 1016, checked in by Steven Levine, 17 years ago

Add stale dcd sanity checks

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