source: trunk/dll/dircnrs.c@ 981

Last change on this file since 981 was 981, checked in by John Small, 18 years ago

Changes to fix problems with default presparams introduced as part
of tickets 150 and 230.

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