source: trunk/dll/dircnrs.c@ 978

Last change on this file since 978 was 978, checked in by Gregg Young, 18 years ago

Fix ability to change default presparams in directory containers. Change free to xfree where approrate.

  • 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 978 2008-02-24 04:26:13Z gyoung $
5
6 Directory containers
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2008 Steven H. Levine
10
11 16 Oct 02 SHL Handle large partitions
12 01 Aug 04 SHL Rework lstrip/rstrip usage
13 23 May 05 SHL Use QWL_USER
14 24 May 05 SHL Rework Win_Error usage
15 25 May 05 SHL Use ULONGLONG and CommaFmtULL
16 26 May 05 SHL More large file formatting updates
17 05 Jun 05 SHL Use QWL_USER
18 10 Nov 05 SHL Comments
19 13 Jul 06 SHL Use Runtime_Error
20 26 Jul 06 SHL Use chop_at_crnl
21 15 Aug 06 SHL Rework warning message text
22 07 Jan 07 GKY Move error strings etc. to string file
23 30 Mar 07 GKY Remove GetPString for window class names
24 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
25 06 Apr 07 GKY Add some error checking in drag/drop
26 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checking.
27 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
28 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
29 02 Aug 07 SHL Sync with CNRITEM mods
30 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
31 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
32 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
33 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
34 10 Jan 08 SHL Sync with CfgDlgProc mods
35 19 Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen
36 15 Feb 08 SHL Sync with settings menu rework
37 22 Feb 08 JBS Ticket 230: Fix/improve various code related to state or presparam values in the INI file.
38
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 RestorePresParams(hwnd, "DirCnr");
1431 memset(&cnri, 0, sizeof(CNRINFO));
1432 cnri.cb = sizeof(CNRINFO);
1433 WinSendMsg(hwnd,
1434 CM_QUERYCNRINFO,
1435 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1436 cnri.cyLineSpacing = 0;
1437 cnri.cxTreeIndent = 12L;
1438
1439 cnri.flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1440 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES | CV_MINI |
1441 CV_FLOW);
1442 cnri.pSortRecord = (PVOID) SortDirCnr;
1443
1444 {
1445 ULONG size = sizeof(ULONG);
1446
1447 PrfQueryProfileData(fmprof,
1448 appname,
1449 "DirflWindowAttr",
1450 (PVOID) & cnri.flWindowAttr, &size);
1451 size = sizeof(MASK);
1452 if (!*dcd->mask.szMask &&
1453 !dcd->mask.attrFile && !dcd->mask.antiattr) {
1454 if (PrfQueryProfileSize(fmprof,
1455 appname, "DirFilter", &size) && size) {
1456 PrfQueryProfileData(fmprof,
1457 appname, "DirFilter", &dcd->mask, &size);
1458 SetMask(dcd->mask.szMask, &dcd->mask);
1459 }
1460 else
1461 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1462 FILE_ARCHIVED | FILE_DIRECTORY |
1463 FILE_HIDDEN | FILE_SYSTEM);
1464 }
1465 *(dcd->mask.prompt) = 0;
1466 }
1467 if (dcd->flWindowAttr)
1468 cnri.flWindowAttr = dcd->flWindowAttr;
1469 else
1470 dcd->flWindowAttr = cnri.flWindowAttr;
1471 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH |
1472 CA_TITLEREADONLY | CA_TITLESEPARATOR));
1473 cnri.flWindowAttr |= CV_FLOW;
1474 dcd->flWindowAttr |= CV_FLOW;
1475 if (WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR))
1476 cnri.flWindowAttr &= (~CA_CONTAINERTITLE);
1477 else
1478 cnri.flWindowAttr |= CA_CONTAINERTITLE;
1479 if (!dcd->sortFlags)
1480 dcd->sortFlags = sortFlags;
1481 WinSendMsg(hwnd,
1482 CM_SETCNRINFO,
1483 MPFROMP(&cnri),
1484 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1485 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1486 SetCnrCols(hwnd, FALSE);
1487 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) {
1488 Runtime_Error(pszSrcFile, __LINE__,
1489 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1490 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1491 return 0;
1492 }
1493 else
1494 DosSleep(32); //05 Aug 07 GKY 64
1495 WinEnableMenuItem(DirCnrMenu, IDM_FINDINTREE, (hwndTree != (HWND) 0));
1496 }
1497 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1498 DIR_FILTER), &dcd->mask, FALSE);
1499 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1500 DIR_SORT), dcd->sortFlags, FALSE);
1501 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1502 DIR_VIEW), dcd->flWindowAttr);
1503 }
1504 else {
1505 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1506 return 0;
1507 }
1508 return 0;
1509
1510 case UM_SETUP2:
1511 if (dcd)
1512 {
1513 AdjustCnrColsForPref(hwnd, NULL, dcd, FALSE);
1514 }
1515 else {
1516 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1517 return 0;
1518 }
1519 return 0;
1520
1521 case WM_MENUEND:
1522 if (dcd) {
1523
1524 HWND hwndMenu = (HWND) mp2;
1525
1526 if (hwndMenu == DirCnrMenu ||
1527 hwndMenu == FileMenu || hwndMenu == DirMenu) {
1528 MarkAll(hwnd, TRUE, FALSE, TRUE);
1529 if (dcd->cnremphasized) {
1530 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1531 MPFROM2SHORT(FALSE, CRA_SOURCE));
1532 dcd->cnremphasized = FALSE;
1533 }
1534 }
1535 }
1536 break;
1537
1538 case UM_OPENWINDOWFORME:
1539 if (dcd) {
1540 if (mp1 && !IsFile((CHAR *) mp1)) {
1541 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
1542 }
1543 else if (mp1 && IsFile(mp1) == 1) {
1544 StartArcCnr(HWND_DESKTOP,
1545 dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
1546 }
1547 }
1548 return 0;
1549
1550 case MM_PORTHOLEINIT:
1551 if (dcd) {
1552 switch (SHORT1FROMMP(mp1)) {
1553 case 0:
1554 case 1:
1555 {
1556 ULONG wmsg;
1557
1558 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1559 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
1560 wmsg, MPVOID, MPVOID), mp1, mp2);
1561 }
1562 break;
1563 }
1564 }
1565 break;
1566
1567 case UM_INITMENU:
1568 case WM_INITMENU:
1569 if (dcd) {
1570 switch (SHORT1FROMMP(mp1)) {
1571 case IDM_FILESMENU:
1572 CopyPresParams((HWND) mp2, hwndMainMenu);
1573 if (isalpha(*dcd->directory)) {
1574 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
1575 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, FALSE);
1576 WinEnableMenuItem((HWND) mp2, IDM_RENAME, FALSE);
1577 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1578 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, FALSE);
1579 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, FALSE);
1580 WinEnableMenuItem((HWND) mp2, IDM_DELETE, FALSE);
1581 WinEnableMenuItem((HWND) mp2, IDM_EDIT, FALSE);
1582 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, FALSE);
1583 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, FALSE);
1584 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, FALSE);
1585 }
1586 else {
1587 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, TRUE);
1588 WinEnableMenuItem((HWND) mp2, IDM_RENAME, TRUE);
1589 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1590 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, TRUE);
1591 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, TRUE);
1592 WinEnableMenuItem((HWND) mp2, IDM_DELETE, TRUE);
1593 WinEnableMenuItem((HWND) mp2, IDM_EDIT, TRUE);
1594 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, TRUE);
1595 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, TRUE);
1596 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
1597 }
1598 }
1599 break;
1600
1601 case IDM_VIEWSMENU:
1602 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1603 CopyPresParams((HWND) mp2, hwndMainMenu);
1604 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1605 (dcd->lastselection != NULL));
1606 if (isalpha(*dcd->directory)) {
1607 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE)
1608 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1609 else
1610 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1611 }
1612 WinEnableMenuItem((HWND) mp2,
1613 IDM_SELECTCOMPAREMENU,
1614 (CountDirCnrs(dcd->hwndParent) > 1));
1615 break;
1616
1617 case IDM_DETAILSSETUP:
1618 SetDetailsSwitches((HWND) mp2, dcd);
1619 break;
1620
1621 case IDM_COMMANDSMENU:
1622 SetupCommandMenu((HWND) mp2, hwnd);
1623 break;
1624
1625 case IDM_SORTSUBMENU:
1626 SetSortChecks((HWND) mp2, dcd->sortFlags);
1627 break;
1628
1629 case IDM_WINDOWSMENU:
1630 SetupWinList((HWND) mp2,
1631 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
1632 break;
1633 }
1634 dcd->hwndLastMenu = (HWND) mp2;
1635 }
1636 if (msg == WM_INITMENU)
1637 break;
1638 return 0;
1639
1640 case UM_FILTER:
1641 if (dcd) {
1642
1643 PCNRITEM pci;
1644
1645 if (mp1) {
1646 DosEnterCritSec();
1647 SetMask((CHAR *) mp1, &dcd->mask);
1648 DosExitCritSec();
1649 }
1650 dcd->suspendview = 1;
1651 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1652 dcd->suspendview = 0;
1653 if (fAutoView && hwndMain) {
1654 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1655 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1656 if (pci && (INT) pci != -1 &&
1657 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1658 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1659 else
1660 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1661 }
1662 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1663 }
1664 return 0;
1665
1666 case UM_COMMAND:
1667 if (mp1) {
1668 if (dcd) {
1669 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1670 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1671 FreeListInfo((LISTINFO *) mp1);
1672 }
1673 else
1674 return (MRESULT) TRUE;
1675 }
1676 else
1677 FreeListInfo((LISTINFO *) mp1);
1678 }
1679 return 0;
1680
1681 case UM_NOTIFY:
1682 if (mp2)
1683 Notify((CHAR *) mp2);
1684 return 0;
1685
1686 case UM_DRIVECMD:
1687 if (mp1)
1688 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0), mp1);
1689 return 0;
1690
1691 case WM_COMMAND:
1692 DosError(FERR_DISABLEHARDERR);
1693 if (dcd) {
1694 switch (SHORT1FROMMP(mp1)) {
1695 case IDM_SETTARGET:
1696 SetTargetDir(hwnd, FALSE);
1697 break;
1698
1699 case IDM_CREATE:
1700 {
1701 STRINGINPARMS sip;
1702 CHAR filename[CCHMAXPATHCOMP];
1703
1704 memset(&sip, 0, sizeof(sip));
1705 sip.help = GetPString(IDS_CREATETEXT);
1706 sip.prompt = GetPString(IDS_CREATEPROMPTTEXT);
1707 sip.inputlen = CCHMAXPATHCOMP - (strlen(dcd->directory) - 1);
1708 strcpy(filename, "NEWFILE.TXT");
1709 sip.ret = filename;
1710 sip.title = GetPString(IDS_CREATETITLETEXT);
1711 if (WinDlgBox(HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle,
1712 STR_FRAME, &sip)) {
1713 bstrip(sip.ret);
1714 if (*sip.ret) {
1715 CHAR newfile[CCHMAXPATH];
1716 FILE *fp;
1717 INT test;
1718 PCNRITEM pci;
1719
1720 strcpy(newfile, dcd->directory);
1721 if (newfile[strlen(newfile) - 1] != '\\')
1722 strcat(newfile, "\\");
1723 strcat(newfile, sip.ret);
1724 test = IsFile(newfile);
1725 if (test != 1)
1726 fp = fopen(newfile, "w");
1727 if (test != 1 && !fp) {
1728 saymsg(MB_ENTER,
1729 hwnd,
1730 GetPString(IDS_ERRORTEXT),
1731 GetPString(IDS_CREATEERRORTEXT), newfile);
1732 }
1733 else {
1734 if (fp) {
1735 WinSendMsg(hwnd, UM_UPDATERECORD, MPFROMP(newfile), MPVOID);
1736 fclose(fp);
1737 }
1738 if (*editor) {
1739
1740 CHAR *dummy[2];
1741
1742 dummy[0] = newfile;
1743 dummy[1] = NULL;
1744 ExecOnList(hwnd,
1745 editor, WINDOWED | SEPARATE, NULL, dummy, NULL,
1746 pszSrcFile, __LINE__);
1747 }
1748 else
1749 StartMLEEditor(dcd->hwndParent, 4, newfile, dcd->hwndFrame);
1750 pci = FindCnrRecord(hwnd, newfile, NULL, TRUE, FALSE, TRUE);
1751 if (pci && (INT) pci != -1)
1752 /* make sure that record shows in viewport */
1753 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1754 }
1755 }
1756 }
1757 }
1758 break;
1759
1760 case IDM_CONTEXTMENU:
1761 {
1762 PCNRITEM pci;
1763
1764 pci = (PCNRITEM) CurrentRecord(hwnd);
1765 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
1766 MPFROMP(pci));
1767 }
1768 break;
1769
1770 case IDM_MAXIMIZE:
1771 PostMsg(hwndMain, UM_MAXIMIZE, MPFROMLONG(dcd->hwndFrame), MPVOID);
1772 break;
1773
1774 case IDM_SHOWALLFILESCNR:
1775 StartSeeAll(HWND_DESKTOP, FALSE, dcd->directory);
1776 break;
1777
1778 case IDM_SHOWALLFILES:
1779 {
1780 PCNRITEM pci;
1781
1782 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1783 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1784 if (pci && (INT) pci != -1) {
1785
1786 static CHAR dirname[CCHMAXPATH];
1787
1788 strcpy(dirname, pci->pszFileName);
1789 MakeValidDir(dirname);
1790 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1791 }
1792 }
1793 break;
1794
1795 case IDM_FINDINTREE:
1796 if (hwndTree)
1797 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory),
1798 MPFROMLONG(1L));
1799 break;
1800
1801 case IDM_BEGINEDIT:
1802 OpenEdit(hwnd);
1803 break;
1804
1805 case IDM_ENDEDIT:
1806 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1807 break;
1808
1809 case IDM_SHOWSELECT:
1810 QuickPopup(hwnd,
1811 dcd,
1812 CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP), IDM_SELECTSUBMENU);
1813 break;
1814
1815 case IDM_SHOWSORT:
1816 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP),
1817 IDM_SORTSUBMENU);
1818 break;
1819
1820 case IDM_VIEWORARC:
1821 {
1822 SWP swp;
1823 PCNRITEM pci;
1824
1825 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1826 MPFROMLONG(CMA_FIRST),
1827 MPFROMSHORT(CRA_CURSORED));
1828 if (pci && (INT) pci != -1) {
1829 WinQueryWindowPos(dcd->hwndFrame, &swp);
1830 DefaultViewKeys(hwnd,
1831 dcd->hwndFrame,
1832 dcd->hwndParent, &swp, pci->pszFileName);
1833 }
1834 }
1835 break;
1836
1837 case IDM_DIRCNRSETTINGS:
1838 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1839 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_DIRCNRSETTINGS), mp2);
1840 else {
1841 WinDlgBox(HWND_DESKTOP,
1842 hwnd,
1843 CfgDlgProc,
1844 FM3ModHandle,
1845 CFG_FRAME,
1846 MPFROMLONG(IDM_DIRCNRSETTINGS));
1847 }
1848 break;
1849
1850 case IDM_QTREE:
1851 case IDM_TREE:
1852 {
1853 CHAR newpath[CCHMAXPATH];
1854 APIRET rc;
1855 PCNRITEM pci;
1856
1857 if (SHORT1FROMMP(mp1) == IDM_TREE) {
1858 pci = (PCNRITEM) CurrentRecord(hwnd);
1859 if (pci && (INT) pci != -1)
1860 strcpy(newpath, pci->pszFileName);
1861 else
1862 strcpy(newpath, dcd->directory);
1863 }
1864 else
1865 strcpy(newpath, dcd->directory);
1866 MakeValidDir(newpath);
1867 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ObjCnrDlgProc,
1868 FM3ModHandle, QTREE_FRAME, MPFROMP(newpath));
1869 if (rc)
1870 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(newpath), MPVOID);
1871 }
1872 break;
1873
1874 case IDM_RESELECT:
1875 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1876 break;
1877
1878 case IDM_HELP:
1879 if (hwndHelp) {
1880 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1881 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
1882 else
1883 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
1884 }
1885 break;
1886
1887 case IDM_WINDOWDLG:
1888 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1889 PostMsg(dcd->hwndParent, UM_COMMAND,
1890 MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
1891 break;
1892
1893 case IDM_SORTSMARTNAME:
1894 case IDM_SORTNAME:
1895 case IDM_SORTFILENAME:
1896 case IDM_SORTSIZE:
1897 case IDM_SORTEASIZE:
1898 case IDM_SORTFIRST:
1899 case IDM_SORTLAST:
1900 case IDM_SORTLWDATE:
1901 case IDM_SORTLADATE:
1902 case IDM_SORTCRDATE:
1903 case IDM_SORTSUBJECT:
1904 dcd->sortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1905 case IDM_SORTDIRSFIRST:
1906 case IDM_SORTDIRSLAST:
1907 case IDM_SORTREVERSE:
1908 switch (SHORT1FROMMP(mp1)) {
1909 case IDM_SORTSUBJECT:
1910 dcd->sortFlags |= SORT_SUBJECT;
1911 break;
1912 case IDM_SORTSMARTNAME:
1913 case IDM_SORTFILENAME:
1914 dcd->sortFlags |= SORT_FILENAME;
1915 break;
1916 case IDM_SORTSIZE:
1917 dcd->sortFlags |= SORT_SIZE;
1918 break;
1919 case IDM_SORTEASIZE:
1920 dcd->sortFlags |= SORT_EASIZE;
1921 break;
1922 case IDM_SORTFIRST:
1923 dcd->sortFlags |= SORT_FIRSTEXTENSION;
1924 break;
1925 case IDM_SORTLAST:
1926 dcd->sortFlags |= SORT_LASTEXTENSION;
1927 break;
1928 case IDM_SORTLWDATE:
1929 dcd->sortFlags |= SORT_LWDATE;
1930 break;
1931 case IDM_SORTLADATE:
1932 dcd->sortFlags |= SORT_LADATE;
1933 break;
1934 case IDM_SORTCRDATE:
1935 dcd->sortFlags |= SORT_CRDATE;
1936 break;
1937 case IDM_SORTDIRSFIRST:
1938 if (dcd->sortFlags & SORT_DIRSFIRST)
1939 dcd->sortFlags &= (~SORT_DIRSFIRST);
1940 else {
1941 dcd->sortFlags |= SORT_DIRSFIRST;
1942 dcd->sortFlags &= (~SORT_DIRSLAST);
1943 }
1944 break;
1945 case IDM_SORTDIRSLAST:
1946 if (dcd->sortFlags & SORT_DIRSLAST)
1947 dcd->sortFlags &= (~SORT_DIRSLAST);
1948 else {
1949 dcd->sortFlags |= SORT_DIRSLAST;
1950 dcd->sortFlags &= (~SORT_DIRSFIRST);
1951 }
1952 break;
1953 case IDM_SORTREVERSE:
1954 if (dcd->sortFlags & SORT_REVERSE)
1955 dcd->sortFlags &= (~SORT_REVERSE);
1956 else
1957 dcd->sortFlags |= SORT_REVERSE;
1958 break;
1959 }
1960 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortDirCnr),
1961 MPFROMLONG(dcd->sortFlags));
1962 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1963 DIR_SORT), dcd->sortFlags, FALSE);
1964 break;
1965
1966 case IDM_COLLECT:
1967 if (!Collector) {
1968
1969 HWND hwndC;
1970 SWP swp;
1971
1972 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
1973 (!fExternalCollector && !strcmp(realappname, FM3Str)))
1974 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
1975 hwndC = StartCollector((fExternalCollector ||
1976 strcmp(realappname, FM3Str)) ?
1977 HWND_DESKTOP : dcd->hwndParent, 4);
1978 if (hwndC) {
1979 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
1980 (!fExternalCollector && !strcmp(realappname, FM3Str)))
1981 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
1982 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
1983 SWP_SHOW | SWP_ZORDER);
1984 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) && fAutoTile &&
1985 !strcmp(realappname, FM3Str))
1986 TileChildren(dcd->hwndParent, TRUE);
1987 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
1988 DosSleep(100); //05 Aug 07 GKY 250
1989 }
1990 }
1991 else
1992 StartCollector(dcd->hwndParent, 4);
1993 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
1994 break;
1995
1996 case IDM_COLLECTOR:
1997 DosSleep(32); //05 Aug 07 GKY 64
1998 {
1999 CHAR **list;
2000
2001 list = BuildList(hwnd);
2002 if (list) {
2003 if (Collector) {
2004 if (!PostMsg(Collector,
2005 WM_COMMAND,
2006 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2007 FreeList(list);
2008 else if (fUnHilite)
2009 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2010 }
2011 else
2012 FreeList(list);
2013 }
2014 }
2015 break;
2016
2017 case IDM_UNDELETE:
2018 {
2019 PCNRITEM pci;
2020 CHAR path[CCHMAXPATH];
2021
2022 pci = (PCNRITEM) CurrentRecord(hwnd);
2023 if (pci && (INT) pci != -1) {
2024 strcpy(path, pci->pszFileName);
2025 MakeValidDir(path);
2026 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2027 UNDEL_FRAME, MPFROMP(path));
2028 }
2029 }
2030 break;
2031
2032 case IDM_UNDELETESPEC:
2033 WinDlgBox(HWND_DESKTOP,
2034 hwnd,
2035 UndeleteDlgProc,
2036 FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
2037 break;
2038
2039 case IDM_RESORT:
2040// WinSendMsg(hwnd,
2041// CM_SORTRECORD,
2042// MPFROMP(SortDirCnr),
2043// MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
2044 WinSendMsg(hwnd,
2045 CM_SORTRECORD,
2046 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
2047 break;
2048
2049 case IDM_FILTER:
2050 {
2051 BOOL empty = FALSE;
2052 PCNRITEM pci;
2053 CHAR *p;
2054
2055 if (!*dcd->mask.szMask) {
2056 empty = TRUE;
2057 pci = (PCNRITEM) CurrentRecord(hwnd);
2058 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
2059 p = strrchr(pci->pszFileName, '\\');
2060 if (p) {
2061 p++;
2062 strcpy(dcd->mask.szMask, p);
2063 }
2064 }
2065 }
2066 *(dcd->mask.prompt) = 0;
2067
2068 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2069 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2070 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2071 else if (empty)
2072 *dcd->mask.szMask = 0;
2073 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2074 DIR_FILTER), &dcd->mask, FALSE);
2075 }
2076 break;
2077
2078 case IDM_UNHIDEALL:
2079 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2080 break;
2081
2082 case IDM_HIDEALL:
2083 if (fAutoView && hwndMain)
2084 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2085 dcd->suspendview = 1;
2086 HideAll(hwnd);
2087 dcd->suspendview = 0;
2088 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2089 break;
2090
2091 case IDM_SELECTBOTH:
2092 case IDM_SELECTONE:
2093 case IDM_SELECTMORE:
2094 case IDM_SELECTNEWER:
2095 case IDM_SELECTOLDER:
2096 case IDM_SELECTBIGGER:
2097 case IDM_SELECTSMALLER:
2098 case IDM_DESELECTBOTH:
2099 case IDM_DESELECTONE:
2100 case IDM_DESELECTMORE:
2101 case IDM_DESELECTNEWER:
2102 case IDM_DESELECTOLDER:
2103 case IDM_DESELECTBIGGER:
2104 case IDM_DESELECTSMALLER:
2105 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2106 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2107 break;
2108 }
2109 case IDM_SELECTLIST:
2110 case IDM_SELECTALL:
2111 case IDM_DESELECTALL:
2112 case IDM_SELECTALLFILES:
2113 case IDM_DESELECTALLFILES:
2114 case IDM_SELECTALLDIRS:
2115 case IDM_DESELECTALLDIRS:
2116 case IDM_SELECTMASK:
2117 case IDM_DESELECTMASK:
2118 case IDM_INVERT:
2119 case IDM_SELECTCLIP:
2120 case IDM_DESELECTCLIP:
2121 {
2122 PCNRITEM pci;
2123
2124 pci = (PCNRITEM) CurrentRecord(hwnd);
2125 if ((INT) pci == -1)
2126 pci = NULL;
2127 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2128 if (pci) {
2129 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2130 pci->rc.flRecordAttr |= CRA_FILTERED;
2131 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2132 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2133 break;
2134 }
2135 }
2136 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2137 }
2138 break;
2139
2140 case IDM_RESCAN:
2141 DosEnterCritSec();
2142 dcd->stopflag++;
2143 DosExitCritSec();
2144 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2145 DosEnterCritSec();
2146 dcd->stopflag--;
2147 DosExitCritSec();
2148 }
2149 break;
2150
2151 case IDM_SHOWLNAMES:
2152 case IDM_SHOWSUBJECT:
2153 case IDM_SHOWEAS:
2154 case IDM_SHOWSIZE:
2155 case IDM_SHOWICON:
2156 case IDM_SHOWLWDATE:
2157 case IDM_SHOWLWTIME:
2158 case IDM_SHOWLADATE:
2159 case IDM_SHOWLATIME:
2160 case IDM_SHOWCRDATE:
2161 case IDM_SHOWCRTIME:
2162 case IDM_SHOWATTR:
2163 AdjustDetailsSwitches(hwnd,
2164 dcd->hwndLastMenu,
2165 SHORT1FROMMP(mp1),
2166 dcd->directory, NULL, dcd, FALSE);
2167 break;
2168
2169 case IDM_TREEVIEW:
2170 case IDM_ICON:
2171 case IDM_TEXT:
2172 case IDM_DETAILS:
2173 case IDM_NAME:
2174 case IDM_MINIICONS:
2175 case IDM_DETAILSTITLES:
2176 {
2177 CNRINFO cnri;
2178
2179 memset(&cnri, 0, sizeof(CNRINFO));
2180 cnri.cb = sizeof(CNRINFO);
2181 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2182 MPFROMLONG(sizeof(CNRINFO)));
2183 switch (SHORT1FROMMP(mp1)) {
2184 case IDM_TREEVIEW:
2185 if (!(cnri.flWindowAttr & CV_TREE))
2186 dcd->lastattr = cnri.flWindowAttr;
2187 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2188 CV_DETAIL | CV_NAME | CA_TREELINE));
2189 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2190 if (!dcd->firsttree)
2191 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2192 break;
2193 case IDM_ICON:
2194 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2195 CV_DETAIL | CV_NAME | CA_TREELINE));
2196 cnri.flWindowAttr |= CV_ICON;
2197 break;
2198 case IDM_NAME:
2199 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2200 CV_DETAIL | CV_NAME | CA_TREELINE));
2201 cnri.flWindowAttr |= CV_NAME;
2202 break;
2203 case IDM_TEXT:
2204 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2205 CV_DETAIL | CV_NAME | CA_TREELINE));
2206 cnri.flWindowAttr |= CV_TEXT;
2207 break;
2208 case IDM_DETAILS:
2209 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2210 CV_DETAIL | CV_NAME | CA_TREELINE));
2211 cnri.flWindowAttr |= CV_DETAIL;
2212 break;
2213 case IDM_MINIICONS:
2214 if (cnri.flWindowAttr & CV_MINI)
2215 cnri.flWindowAttr &= (~CV_MINI);
2216 else
2217 cnri.flWindowAttr |= CV_MINI;
2218 break;
2219 case IDM_DETAILSTITLES:
2220 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2221 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2222 else
2223 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2224 break;
2225 }
2226 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2227 cnri.flWindowAttr |= CV_FLOW;
2228 dcd->flWindowAttr = cnri.flWindowAttr;
2229 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2230 MPFROMLONG(CMA_FLWINDOWATTR));
2231 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2232 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2233 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2234 DIR_VIEW), dcd->flWindowAttr);
2235 }
2236 break;
2237
2238 case IDM_SAVETOLIST:
2239 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2240 SAV_FRAME, MPFROMP(&hwnd));
2241 break;
2242
2243 case IDM_SIZES:
2244 {
2245 PCNRITEM pci;
2246 CHAR path[CCHMAXPATH];
2247
2248 pci = (PCNRITEM) CurrentRecord(hwnd);
2249 if (pci && (INT) pci != -1)
2250 strcpy(path, pci->pszFileName);
2251 else
2252 strcpy(path, dcd->directory);
2253 MakeValidDir(path);
2254 WinDlgBox(HWND_DESKTOP,
2255 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2256 }
2257 break;
2258
2259 case IDM_MKDIR:
2260 {
2261 PCNRITEM pci;
2262 BOOL saved;
2263
2264 saved = fSelectedAlways;
2265 fSelectedAlways = FALSE;
2266 pci = (PCNRITEM)CurrentRecord(hwnd);
2267 // 01 Oct 07 SHL Make below selected directory or in current directory
2268 PMMkDir(dcd->hwndParent,
2269 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2270 FALSE);
2271 fSelectedAlways = saved;
2272 }
2273 break;
2274
2275 case IDM_SWITCH:
2276 if (mp2) {
2277 strcpy(dcd->previous, dcd->directory);
2278 strcpy(dcd->directory, (CHAR *) mp2);
2279 DosEnterCritSec();
2280 dcd->stopflag++;
2281 DosExitCritSec();
2282 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2283 strcpy(dcd->directory, dcd->previous);
2284 DosEnterCritSec();
2285 dcd->stopflag--;
2286 DosExitCritSec();
2287 }
2288 else if (*dcd->directory) {
2289 if (hwndMain)
2290 WinSendMsg(hwndMain,
2291 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2292 else
2293 add_udir(FALSE, dcd->directory);
2294 }
2295 }
2296 break;
2297
2298 case IDM_PARENT:
2299 {
2300 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
2301
2302 strcpy(tempname1, dcd->directory);
2303 if (tempname1[strlen(tempname1) - 1] != '\\')
2304 strcat(tempname1, "\\");
2305 strcat(tempname1, "..");
2306 DosError(FERR_DISABLEHARDERR);
2307 if (!DosQueryPathInfo(tempname1,
2308 FIL_QUERYFULLNAME,
2309 tempname2, sizeof(tempname2))) {
2310 if (stricmp(dcd->directory, tempname2)) {
2311 strcpy(dcd->previous, dcd->directory);
2312 strcpy(dcd->directory, tempname2);
2313 DosEnterCritSec();
2314 dcd->stopflag++;
2315 DosExitCritSec();
2316 if (!PostMsg(dcd->hwndObject,
2317 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2318 strcpy(dcd->directory, dcd->previous);
2319 DosEnterCritSec();
2320 dcd->stopflag--;
2321 DosExitCritSec();
2322 }
2323 else if (*dcd->directory) {
2324 if (hwndMain)
2325 WinSendMsg(hwndMain,
2326 UM_SETUSERLISTNAME,
2327 MPFROMP(dcd->directory), MPVOID);
2328 else
2329 add_udir(FALSE, dcd->directory);
2330 }
2331 }
2332 }
2333 }
2334 break;
2335
2336 case IDM_PREVIOUS:
2337 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
2338
2339 CHAR tempname[CCHMAXPATH];
2340
2341 if (IsValidDir(dcd->previous)) {
2342 strcpy(tempname, dcd->directory);
2343 strcpy(dcd->directory, dcd->previous);
2344 strcpy(dcd->previous, tempname);
2345 DosEnterCritSec();
2346 dcd->stopflag++;
2347 DosExitCritSec();
2348 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2349 strcpy(dcd->directory, dcd->previous);
2350 DosEnterCritSec();
2351 dcd->stopflag--;
2352 DosExitCritSec();
2353 }
2354 else if (*dcd->directory) {
2355 if (hwndMain)
2356 WinSendMsg(hwndMain,
2357 UM_SETUSERLISTNAME,
2358 MPFROMP(dcd->directory), MPVOID);
2359 else
2360 add_udir(FALSE, dcd->directory);
2361 }
2362 }
2363 else
2364 *dcd->previous = 0;
2365 }
2366 break;
2367
2368 case IDM_WALKDIR:
2369 {
2370 CHAR newdir[CCHMAXPATH];
2371
2372 strcpy(newdir, dcd->directory);
2373 if (!WinDlgBox(HWND_DESKTOP,
2374 dcd->hwndParent,
2375 WalkAllDlgProc,
2376 FM3ModHandle,
2377 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2378 break;
2379 if (stricmp(newdir, dcd->directory)) {
2380 strcpy(dcd->previous, dcd->directory);
2381 strcpy(dcd->directory, newdir);
2382 DosEnterCritSec();
2383 dcd->stopflag++;
2384 DosExitCritSec();
2385 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2386 strcpy(dcd->directory, dcd->previous);
2387 DosEnterCritSec();
2388 dcd->stopflag--;
2389 DosExitCritSec();
2390 }
2391 else if (*dcd->directory) {
2392 if (hwndMain)
2393 WinSendMsg(hwndMain,
2394 UM_SETUSERLISTNAME,
2395 MPFROMP(dcd->directory), MPVOID);
2396 else
2397 add_udir(FALSE, dcd->directory);
2398 }
2399 }
2400 }
2401 break;
2402
2403 case IDM_OPENICONME:
2404 OpenObject(dcd->directory, "ICON", dcd->hwndFrame);
2405 break;
2406 case IDM_OPENDETAILSME:
2407 OpenObject(dcd->directory, "DETAILS", dcd->hwndFrame);
2408 break;
2409 case IDM_OPENTREEME:
2410 OpenObject(dcd->directory, "TREE", dcd->hwndFrame);
2411 break;
2412 case IDM_OPENSETTINGSME:
2413 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2414 break;
2415
2416 case IDM_DOITYOURSELF:
2417 case IDM_UPDATE:
2418 case IDM_OPENWINDOW:
2419 case IDM_OPENSETTINGS:
2420 case IDM_OPENDEFAULT:
2421 case IDM_OPENICON:
2422 case IDM_OPENDETAILS:
2423 case IDM_OPENTREE:
2424 case IDM_OBJECT:
2425 case IDM_SHADOW:
2426 case IDM_SHADOW2:
2427 case IDM_DELETE:
2428 case IDM_PERMDELETE:
2429 case IDM_PRINT:
2430 case IDM_ATTRS:
2431 case IDM_INFO:
2432 case IDM_COPY:
2433 case IDM_MOVE:
2434 case IDM_WPSMOVE:
2435 case IDM_WPSCOPY:
2436 case IDM_WILDCOPY:
2437 case IDM_WILDMOVE:
2438 case IDM_RENAME:
2439 case IDM_COMPARE:
2440 case IDM_EAS:
2441 case IDM_SUBJECT:
2442 case IDM_VIEW:
2443 case IDM_VIEWTEXT:
2444 case IDM_VIEWBINARY:
2445 case IDM_VIEWARCHIVE:
2446 case IDM_EDIT:
2447 case IDM_EDITTEXT:
2448 case IDM_EDITBINARY:
2449 case IDM_SAVETOCLIP:
2450 case IDM_APPENDTOCLIP:
2451 case IDM_ARCHIVE:
2452 case IDM_ARCHIVEM:
2453 case IDM_EXTRACT:
2454 case IDM_MCIPLAY:
2455 case IDM_COLLECTFROMFILE:
2456 case IDM_UUDECODE:
2457 case IDM_MERGE:
2458 {
2459 LISTINFO *li;
2460 ULONG action = UM_ACTION;
2461
2462 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2463 if (li) {
2464 li->type = SHORT1FROMMP(mp1);
2465 li->hwnd = hwnd;
2466 li->list = BuildList(hwnd);
2467 switch (SHORT1FROMMP(mp1)) {
2468 case IDM_WILDMOVE:
2469 case IDM_WILDCOPY:
2470 case IDM_MOVE:
2471 case IDM_COPY:
2472 case IDM_WPSMOVE:
2473 case IDM_WPSCOPY:
2474 break;
2475 default:
2476 strcpy(li->targetpath, dcd->directory);
2477 break;
2478 }
2479 if (li->list) {
2480 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2481 if (!Collector) {
2482
2483 HWND hwndC;
2484 SWP swp;
2485
2486 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2487 !fAutoTile &&
2488 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2489 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2490 hwndC = StartCollector((fExternalCollector ||
2491 strcmp(realappname, FM3Str)) ?
2492 HWND_DESKTOP : dcd->hwndParent, 4);
2493 if (hwndC) {
2494 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2495 !fAutoTile && (!fExternalCollector &&
2496 !strcmp(realappname, FM3Str)))
2497 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2498 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2499 SWP_SHOW | SWP_ZORDER);
2500 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2501 fAutoTile && !strcmp(realappname, FM3Str))
2502 TileChildren(dcd->hwndParent, TRUE);
2503 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2504 SWP_ACTIVATE);
2505 DosSleep(100); //05 Aug 07 GKY 250
2506 }
2507 }
2508 else
2509 StartCollector(dcd->hwndParent, 4);
2510 }
2511 switch (SHORT1FROMMP(mp1)) {
2512 case IDM_APPENDTOCLIP:
2513 case IDM_SAVETOCLIP:
2514 case IDM_ARCHIVE:
2515 case IDM_ARCHIVEM:
2516 case IDM_DELETE:
2517 case IDM_PERMDELETE:
2518 case IDM_ATTRS:
2519 case IDM_PRINT:
2520 case IDM_SHADOW:
2521 case IDM_SHADOW2:
2522 case IDM_OBJECT:
2523 case IDM_VIEW:
2524 case IDM_VIEWTEXT:
2525 case IDM_VIEWBINARY:
2526 case IDM_EDIT:
2527 case IDM_EDITTEXT:
2528 case IDM_EDITBINARY:
2529 case IDM_MCIPLAY:
2530 case IDM_UPDATE:
2531 case IDM_DOITYOURSELF:
2532 case IDM_INFO:
2533 case IDM_EAS:
2534 action = UM_MASSACTION;
2535 break;
2536 }
2537 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2538 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2539 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2540 *li->targetpath = 0;
2541 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2542 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2543 FreeListInfo(li);
2544 }
2545 else if (fUnHilite)
2546 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2547 }
2548 else
2549 xfree(li);
2550 }
2551 }
2552 break;
2553
2554 case IDM_DRIVESMENU:
2555 if (!hwndMain)
2556 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2557 break;
2558
2559 default:
2560 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2561 return 0;
2562 else {
2563 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2564 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2565
2566 register INT x;
2567
2568 if (!cmdloaded)
2569 load_commands();
2570 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2571 if (x >= 0) {
2572 x++;
2573 RunCommand(hwnd, x);
2574 if (fUnHilite)
2575 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2576 }
2577 }
2578 }
2579 break;
2580 }
2581 }
2582 return 0;
2583
2584 case UM_FIXCNRMLE:
2585 case UM_FIXEDITNAME:
2586 return CommonCnrProc(hwnd, msg, mp1, mp2);
2587
2588 case UM_FILESMENU:
2589 {
2590 PCNRITEM pci;
2591 HWND menuHwnd = (HWND) 0;
2592
2593 pci = (PCNRITEM) CurrentRecord(hwnd);
2594 if (pci && (INT) pci != -1) {
2595 if (pci->attrFile & FILE_DIRECTORY) {
2596 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2597// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2598 }
2599 else
2600 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2601 }
2602 return MRFROMLONG(menuHwnd);
2603 }
2604
2605 case WM_CONTROL:
2606 DosError(FERR_DISABLEHARDERR);
2607 if (dcd) {
2608 switch (SHORT2FROMMP(mp1)) {
2609 case CN_COLLAPSETREE:
2610 case CN_EXPANDTREE:
2611 {
2612 PCNRITEM pci = (PCNRITEM) mp2;
2613
2614 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
2615 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
2616 struct
2617 {
2618 ULONG serial;
2619 CHAR volumelength;
2620 CHAR volumelabel[CCHMAXPATH];
2621 }
2622 volser;
2623 APIRET rc;
2624
2625 memset(&volser, 0, sizeof(volser));
2626 DosError(FERR_DISABLEHARDERR);
2627 // fixme?
2628 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2629 FSIL_VOLSER, &volser, sizeof(volser));
2630 if (rc) {
2631 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2632 GetPString(IDS_CANTFINDDIRTEXT),
2633 pci->pszFileName);
2634 DosBeep(250,100);
2635 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2636 UnFlesh(hwnd, pci);
2637 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2638 }
2639 else {
2640 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2641 !volser.serial ||
2642 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2643 volser.serial)
2644 UnFlesh(hwnd, pci);
2645 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2646 (!volser.serial ||
2647 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2648 volser.serial)) {
2649 if (Flesh(hwnd, pci) &&
2650 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2651 !dcd->suspendview && fTopDir)
2652 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2653 }
2654 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2655 }
2656 }
2657 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2658 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
2659 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2660 }
2661 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2662 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2663 }
2664 }
2665 break;
2666
2667/*
2668 case CN_PICKUP:
2669 return PickUp(hwnd,dcd->hwndObject,mp2);
2670*/
2671
2672 case CN_CONTEXTMENU:
2673 {
2674 PCNRITEM pci = (PCNRITEM) mp2;
2675
2676 if (pci) {
2677 WinSendMsg(hwnd,
2678 CM_SETRECORDEMPHASIS,
2679 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2680 MarkAll(hwnd, FALSE, FALSE, TRUE);
2681 if (pci->attrFile & FILE_DIRECTORY)
2682 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2683 else
2684 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2685 }
2686 else {
2687 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
2688 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2689 WinSendMsg(hwnd,
2690 CM_SETRECORDEMPHASIS,
2691 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2692 dcd->cnremphasized = TRUE;
2693 }
2694 }
2695 if (dcd->hwndLastMenu) {
2696 if (dcd->hwndLastMenu == DirCnrMenu) {
2697 if (dcd->flWindowAttr & CV_MINI)
2698 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2699 }
2700 if (dcd->hwndLastMenu == DirMenu)
2701 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2702 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2703 if (dcd->cnremphasized) {
2704 WinSendMsg(hwnd,
2705 CM_SETRECORDEMPHASIS,
2706 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2707 dcd->cnremphasized = TRUE;
2708 }
2709 MarkAll(hwnd, TRUE, FALSE, TRUE);
2710 }
2711 }
2712 }
2713 break;
2714
2715 case CN_DROPHELP:
2716 if (mp2) {
2717
2718 PDRAGINFO pDInfo;
2719 PCNRITEM pci;
2720 ULONG numitems;
2721 USHORT usOperation;
2722
2723 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2724 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2725 if (!DrgAccessDraginfo(pDInfo)) {
2726 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2727 GetPString(IDS_DROPERRORTEXT));
2728 }
2729 else {
2730 numitems = DrgQueryDragitemCount(pDInfo);
2731 usOperation = pDInfo->usOperation;
2732 FreeDragInfoData(hwnd, pDInfo);
2733 saymsg(MB_ENTER | MB_ICONASTERISK,
2734 hwnd,
2735 GetPString(IDS_DROPHELPHDRTEXT),
2736 GetPString(IDS_DROPHELPTEXT),
2737 numitems,
2738 &"s"[numitems == 1L],
2739 pci ? NullStr : GetPString(IDS_NOTEXT),
2740 pci ? NullStr : " ",
2741 pci ? pci->pszFileName : NullStr,
2742 pci ? " " : NullStr,
2743 GetPString((usOperation == DO_COPY) ?
2744 IDS_COPYTEXT :
2745 (usOperation == DO_LINK) ?
2746 IDS_LINKTEXT : IDS_MOVETEXT));
2747 }
2748 }
2749 return 0;
2750
2751 case CN_DRAGLEAVE:
2752 return 0;
2753
2754 case CN_DRAGAFTER:
2755 case CN_DRAGOVER:
2756 if (mp2) {
2757
2758 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2759 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2760 PCNRITEM pci;
2761 USHORT uso;
2762
2763 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2764 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2765 if (!DrgAccessDraginfo(pDInfo)) {
2766 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2767 "DrgAccessDraginfo");
2768 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2769 }
2770 if (*dcd->directory &&
2771 (driveflags[toupper(*dcd->directory) - 'A'] &
2772 DRIVE_NOTWRITEABLE)) {
2773 DrgFreeDraginfo(pDInfo);
2774 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
2775 DO_LINK); /* (compare) only */
2776 }
2777 if (pci) {
2778 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2779 DrgFreeDraginfo(pDInfo);
2780 return (MRFROM2SHORT(DOR_NODROP, 0));
2781 }
2782 uso = pDInfo->usOperation;
2783 if (uso == DO_DEFAULT)
2784 uso = fCopyDefault ? DO_COPY : DO_MOVE;
2785 if (!(pci->attrFile & FILE_DIRECTORY)) {
2786 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2787 DrgFreeDraginfo(pDInfo);
2788 return MRFROM2SHORT(DOR_NODROP, 0);
2789 }
2790 if (uso != DO_LINK &&
2791 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2792 DRIVE_NOTWRITEABLE)) {
2793
2794 ARC_TYPE *info = NULL;
2795
2796 if (!fQuickArcFind &&
2797 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2798 DRIVE_SLOW))
2799 info = find_type(pci->pszFileName, NULL);
2800 else
2801 info = quick_find_type(pci->pszFileName, NULL);
2802 if (!info || ((uso == DO_MOVE && !info->move) ||
2803 (uso == DO_COPY && !info->create))) {
2804 DrgFreeDraginfo(pDInfo);
2805 return MRFROM2SHORT(DOR_NODROP, 0);
2806 }
2807 }
2808 }
2809 }
2810
2811 /* Access DRAGITEM index to DRAGITEM
2812 * Check valid rendering mechanisms and data
2813 */
2814 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
2815 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL) ||
2816 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
2817 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) {
2818 DrgFreeDraginfo(pDInfo);
2819 if (driveflags[toupper(*dcd->directory) - 'A'] &
2820 DRIVE_NOTWRITEABLE)
2821 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2822 if (toupper(*dcd->directory) < 'C')
2823 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2824 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2825 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2826 }
2827 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2828 }
2829 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
2830
2831 case CN_INITDRAG:
2832 {
2833 BOOL wasemphasized = FALSE;
2834 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2835 PCNRITEM pci;
2836
2837 if (pcd) {
2838 pci = (PCNRITEM) pcd->pRecord;
2839 if (pci) {
2840 if ((INT) pci == -1)
2841 pci = NULL;
2842 else if (pci->rc.flRecordAttr & CRA_SELECTED)
2843 wasemphasized = TRUE;
2844 }
2845 else if (!*dcd->directory) {
2846 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2847 break;
2848 }
2849 else if (IsRoot(dcd->directory)) {
2850 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
2851 GetPString(IDS_CANTDRAGROOTDIR));
2852 break;
2853 }
2854 if (hwndStatus2) {
2855 if (pci)
2856 WinSetWindowText(hwndStatus2,
2857 GetPString(IDS_DRAGFILEOBJTEXT));
2858 else
2859 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGDIRTEXT));
2860 }
2861 if (DoFileDrag(hwnd,
2862 dcd->hwndObject,
2863 mp2,
2864 NULL,
2865 pci ? NULL : dcd->directory,
2866 pci ? TRUE : FALSE)) {
2867 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
2868 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2869 }
2870 }
2871 if (hwndStatus2) {
2872 WinSetFocus(HWND_DESKTOP, hwnd);
2873 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2874 }
2875 }
2876 }
2877 return 0;
2878
2879 case CN_DROP:
2880 if (mp2) {
2881
2882 LISTINFO *li;
2883 ULONG action = UM_ACTION;
2884
2885 // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
2886 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
2887 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2888 if (li) {
2889 if (li->list && li->list[0] && IsRoot(li->list[0]))
2890 li->type = DO_LINK;
2891 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2892
2893 CHECKLIST cl;
2894
2895 memset(&cl, 0, sizeof(cl));
2896 cl.size = sizeof(cl);
2897 cl.flags = li->type;
2898 cl.list = li->list;
2899 cl.cmd = li->type;
2900 cl.prompt = li->targetpath;
2901 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2902 DropListProc, FM3ModHandle,
2903 DND_FRAME, MPFROMP(&cl));
2904 if (li->type == DID_ERROR)
2905 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2906 "Drag & Drop Dialog");
2907 if (!li->type) {
2908 FreeListInfo(li);
2909 return 0;
2910 }
2911 li->list = cl.list;
2912 if (!li->list || !li->list[0]) {
2913 FreeListInfo(li);
2914 return 0;
2915 }
2916 }
2917 switch (li->type) {
2918 case DND_LAUNCH:
2919 strcat(li->targetpath, " %a");
2920 ExecOnList(dcd->hwndParent, li->targetpath,
2921 PROMPT | WINDOWED, NULL, li->list, NULL,
2922 pszSrcFile, __LINE__);
2923 FreeList(li->list);
2924 li->list = NULL;
2925 break;
2926 case DO_LINK:
2927 if (fLinkSetsIcon) {
2928 li->type = IDM_SETICON;
2929 action = UM_MASSACTION;
2930 }
2931 else
2932 li->type = IDM_COMPARE;
2933 break;
2934 case DND_EXTRACT:
2935 if (*li->targetpath && !IsFile(li->targetpath))
2936 li->type = IDM_EXTRACT;
2937 break;
2938 case DND_MOVE:
2939 li->type = IDM_MOVE;
2940 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2941 action = UM_MASSACTION;
2942 li->type = IDM_ARCHIVEM;
2943 }
2944 break;
2945 case DND_WILDMOVE:
2946 li->type = IDM_WILDMOVE;
2947 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2948 action = UM_MASSACTION;
2949 li->type = IDM_ARCHIVEM;
2950 }
2951 break;
2952 case DND_OBJECT:
2953 li->type = IDM_OBJECT;
2954 action = UM_MASSACTION;
2955 break;
2956 case DND_SHADOW:
2957 li->type = IDM_SHADOW;
2958 action = UM_MASSACTION;
2959 break;
2960 case DND_COMPARE:
2961 li->type = IDM_COMPARE;
2962 break;
2963 case DND_SETICON:
2964 action = UM_MASSACTION;
2965 li->type = IDM_SETICON;
2966 break;
2967 case DND_COPY:
2968 li->type = IDM_COPY;
2969 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2970 action = UM_MASSACTION;
2971 li->type = IDM_ARCHIVE;
2972 }
2973 break;
2974 case DND_WILDCOPY:
2975 li->type = IDM_WILDCOPY;
2976 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2977 action = UM_MASSACTION;
2978 li->type = IDM_ARCHIVE;
2979 }
2980 break;
2981 default:
2982 if (*li->arcname && li->info) {
2983 action = UM_MASSACTION;
2984 li->type =
2985 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2986 }
2987 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2988 action = UM_MASSACTION;
2989 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2990 }
2991 else
2992 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2993 break;
2994 }
2995 if (!li->list || !li->list[0])
2996 FreeListInfo(li);
2997 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2998 FreeListInfo(li);
2999 else {
3000
3001 USHORT usop = 0;
3002
3003 switch (li->type) {
3004 case IDM_COPY:
3005 case IDM_WILDCOPY:
3006 usop = DO_COPY;
3007 break;
3008 case IDM_MOVE:
3009 case IDM_WILDMOVE:
3010 case IDM_ARCHIVEM:
3011 usop = DO_MOVE;
3012 break;
3013 }
3014 if (usop)
3015 return MRFROM2SHORT(DOR_DROP, usop);
3016 }
3017 }
3018 }
3019 return 0;
3020
3021 case CN_ENDEDIT:
3022 case CN_BEGINEDIT:
3023 {
3024 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3025 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3026
3027 if (pfi || pci) {
3028
3029 MRESULT mre;
3030
3031 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3032 if (mre != (MRESULT) - 1)
3033 return mre;
3034 }
3035 else if (!pfi && !pci)
3036 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3037 }
3038 return 0;
3039
3040 case CN_REALLOCPSZ:
3041 {
3042 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3043 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3044 HWND hwndMLE;
3045 static CHAR szData[CCHMAXPATH];
3046 CHAR testname[CCHMAXPATH];
3047
3048 if (!pci && !pfi) {
3049 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3050 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
3051 chop_at_crnl(szData);
3052 bstrip(szData);
3053 if (*szData) {
3054 if (!DosQueryPathInfo(szData,
3055 FIL_QUERYFULLNAME,
3056 testname, sizeof(testname))) {
3057 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3058 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3059 }
3060 }
3061 }
3062 }
3063 else {
3064
3065 MRESULT mre;
3066
3067 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3068 if (mre != (MRESULT) - 1)
3069 return mre;
3070 }
3071 }
3072 return 0;
3073
3074 case CN_EMPHASIS:
3075 if (!mp2)
3076 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3077 else {
3078 PNOTIFYRECORDEMPHASIS pre = mp2;
3079 PCNRITEM pci;
3080 CHAR s[CCHMAXPATHCOMP + 91], tb[81], tf[81];
3081
3082 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
3083 if (!pci) {
3084 if (hwndStatus2)
3085 WinSetWindowText(hwndStatus2, NullStr);
3086 if (fMoreButtons) {
3087 WinSetWindowText(hwndName, NullStr);
3088 WinSetWindowText(hwndDate, NullStr);
3089 WinSetWindowText(hwndAttr, NullStr);
3090 }
3091 if (hwndMain)
3092 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3093 break;
3094 }
3095 if (pre->fEmphasisMask & CRA_SELECTED) {
3096 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3097 dcd->selectedbytes += (pci->cbFile + pci->easize);
3098 dcd->selectedfiles++;
3099 }
3100 else if (dcd->selectedfiles) {
3101 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3102 dcd->selectedfiles--;
3103 }
3104 if (!dcd->suspendview) {
3105 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3106 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3107 sprintf(s, "%s / %s", tf, tb);
3108 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3109 }
3110 }
3111 if (!dcd->suspendview && hwndMain &&
3112 (pre->fEmphasisMask & CRA_CURSORED) &&
3113 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3114 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3115 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
3116 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3117 else
3118 WinSendMsg(hwndMain,
3119 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
3120 }
3121 if (!dcd->suspendview &&
3122 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3123 if (pre->fEmphasisMask & CRA_CURSORED) {
3124 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3125 if (fSplitStatus && hwndStatus2) {
3126 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3127 if (!fMoreButtons) {
3128 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
3129 tb, pci->date.year,
3130 pci->date.month, pci->date.day, pci->time.hours,
3131 pci->time.minutes, pci->time.seconds,
3132 pci->pszDispAttr, pci->pszFileName);
3133 }
3134 else {
3135 *tf = 0;
3136 if (pci->cbFile + pci->easize > 1024) {
3137 CommaFmtULL(tf, sizeof(tf),
3138 pci->cbFile + pci->easize, 'K');
3139 }
3140 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3141 tb,
3142 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3143 }
3144 WinSetWindowText(hwndStatus2, s);
3145 }
3146 if (fMoreButtons) {
3147 WinSetWindowText(hwndName, pci->pszFileName);
3148 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
3149 pci->date.year, pci->date.month,
3150 pci->date.day, pci->time.hours, pci->time.minutes,
3151 pci->time.seconds);
3152 WinSetWindowText(hwndDate, s);
3153 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3154 }
3155 }
3156 }
3157 }
3158 }
3159 break;
3160
3161 case CN_ENTER:
3162 if (mp2) {
3163
3164 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3165 FILEFINDBUF3 ffb;
3166 HDIR hDir = HDIR_CREATE;
3167 ULONG nm = 1;
3168 APIRET status = 0;
3169
3170 SetShiftState();
3171 if (pci) {
3172 if (pci->rc.flRecordAttr & CRA_INUSE)
3173 break;
3174 DosError(FERR_DISABLEHARDERR);
3175 status = DosFindFirst(pci->pszFileName,
3176 &hDir,
3177 FILE_NORMAL | FILE_DIRECTORY |
3178 FILE_ARCHIVED | FILE_READONLY |
3179 FILE_HIDDEN | FILE_SYSTEM,
3180 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
3181 priority_bumped();
3182 if (!status) {
3183 DosFindClose(hDir);
3184 if (ffb.attrFile & FILE_DIRECTORY) {
3185 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3186 PostMsg(hwnd,
3187 WM_COMMAND,
3188 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3189 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3190 (KC_CTRL | KC_SHIFT))
3191 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
3192 else if (shiftstate & KC_CTRL)
3193 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
3194 else if (shiftstate & KC_SHIFT) {
3195
3196 HWND hwndDir;
3197
3198 hwndDir = OpenDirCnr((HWND) 0,
3199 dcd->hwndParent,
3200 dcd->hwndFrame,
3201 FALSE, pci->pszFileName);
3202 if (hwndDir) {
3203 if (fMinOnOpen)
3204 WinSetWindowPos(dcd->hwndFrame,
3205 HWND_BOTTOM,
3206 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3207 if (fAutoTile)
3208 TileChildren(dcd->hwndParent, TRUE);
3209 WinSetWindowPos(hwndDir,
3210 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3211 }
3212 }
3213 else {
3214 strcpy(dcd->previous, dcd->directory);
3215 strcpy(dcd->directory, pci->pszFileName);
3216 DosEnterCritSec();
3217 dcd->stopflag++;
3218 DosExitCritSec();
3219 if (!PostMsg(dcd->hwndObject,
3220 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
3221 DosEnterCritSec();
3222 dcd->stopflag--;
3223 DosExitCritSec();
3224 }
3225 else if (*dcd->directory) {
3226 if (hwndMain)
3227 WinSendMsg(hwndMain,
3228 UM_SETUSERLISTNAME,
3229 MPFROMP(dcd->directory), MPVOID);
3230 else
3231 add_udir(FALSE, dcd->directory);
3232 }
3233 }
3234 }
3235 else {
3236
3237 SWP swp;
3238
3239 WinQueryWindowPos(dcd->hwndFrame, &swp);
3240 WinSendMsg(hwnd,
3241 CM_SETRECORDEMPHASIS,
3242 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3243 DefaultViewKeys(hwnd,
3244 dcd->hwndFrame,
3245 dcd->hwndParent, &swp, pci->pszFileName);
3246 WinSendMsg(hwnd,
3247 CM_SETRECORDEMPHASIS,
3248 MPFROMP(pci),
3249 MPFROM2SHORT(FALSE,
3250 CRA_INUSE |
3251 ((fUnHilite) ? CRA_SELECTED : 0)));
3252 }
3253 }
3254 else {
3255 if (!*dcd->directory || IsValidDir(dcd->directory)) {
3256 NotifyError(pci->pszFileName, status);
3257 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
3258 if (hwndStatus)
3259 WinSetWindowText(hwndStatus,
3260 GetPString(IDS_RESCANSUGGESTEDTEXT));
3261 }
3262 else {
3263 DosEnterCritSec();
3264 dcd->stopflag++;
3265 DosExitCritSec();
3266 if (!PostMsg(dcd->hwndObject,
3267 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3268 DosEnterCritSec();
3269 dcd->stopflag--;
3270 DosExitCritSec();
3271 }
3272 else if (*dcd->directory) {
3273 if (hwndMain)
3274 WinSendMsg(hwndMain,
3275 UM_SETUSERLISTNAME,
3276 MPFROMP(dcd->directory), MPVOID);
3277 else
3278 add_udir(FALSE, dcd->directory);
3279 }
3280 }
3281 }
3282 }
3283 else if (*dcd->directory)
3284 OpenObject(dcd->directory, Default, hwnd);
3285 } // CN_ENTER
3286 break;
3287 } // switch mp1
3288 break;
3289 } // if dcd
3290 return 0;
3291
3292 case UM_LOADFILE:
3293 if (dcd && mp2) {
3294
3295 HWND ret = StartMLEEditor(dcd->hwndParent,
3296 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
3297 xfree((CHAR *)mp2);
3298 return MRFROMLONG(ret);
3299 }
3300 return 0;
3301
3302 case WM_SAVEAPPLICATION:
3303 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3304
3305 SWP swp;
3306
3307 WinQueryWindowPos(dcd->hwndFrame, &swp);
3308 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3309 PrfWriteProfileData(fmprof,
3310 appname, "VDirSizePos", &swp, sizeof(swp));
3311 }
3312 break;
3313
3314 case WM_CLOSE:
3315 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3316 if (LastDir == hwnd)
3317 LastDir = (HWND) 0;
3318 if (dcd) {
3319 dcd->stopflag++;
3320 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3321 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3322 if (!dcd->hwndObject ||
3323 !PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID)) {
3324 if (dcd->hwndObject)
3325 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3326 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3327 if (dcd->hwndRestore)
3328 WinSetWindowPos(dcd->hwndRestore,
3329 HWND_TOP,
3330 0,
3331 0,
3332 0,
3333 0,
3334 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3335 FreeList(dcd->lastselection);
3336 xfree(dcd);
3337 DosPostEventSem(CompactSem);
3338 }
3339 }
3340 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3341 QW_PARENT));
3342 return 0;
3343
3344 case WM_DESTROY:
3345 if (DirMenu)
3346 WinDestroyWindow(DirMenu);
3347 if (DirCnrMenu)
3348 WinDestroyWindow(DirCnrMenu);
3349 if (FileMenu)
3350 WinDestroyWindow(FileMenu);
3351 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3352 EmptyCnr(hwnd);
3353 break;
3354 }
3355 if (dcd && dcd->oldproc){
3356 return dcd->oldproc(hwnd, msg, mp1, mp2);
3357 }
3358 else
3359 return PFNWPCnr(hwnd, msg, mp1, mp2);
3360}
3361
3362HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3363 ULONG flags)
3364{
3365 /* bitmapped flags:
3366 * 0x00000001 = don't close app when window closes
3367 * 0x00000002 = no frame controls
3368 */
3369
3370 HWND hwndFrame = (HWND) 0, hwndClient;
3371 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3372 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3373 USHORT id;
3374 static USHORT idinc = 0;
3375 DIRCNRDATA *dcd;
3376 static BOOL first = FALSE;
3377
3378 if (flags & 2)
3379 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3380 FCF_MINMAX | FCF_ICON));
3381 if (!idinc)
3382 idinc = (rand() % 100);
3383 if (!hwndParent)
3384 hwndParent = HWND_DESKTOP;
3385 if (ParentIsDesktop(hwndParent, hwndParent))
3386 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3387 if (!hwndMain && !first) {
3388 if (DirCnrMenu) {
3389
3390 MENUITEM mi;
3391
3392 memset(&mi, 0, sizeof(mi));
3393 WinSendMsg(DirCnrMenu,
3394 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
3395 mi.iPosition = MIT_END;
3396 mi.afStyle = MIS_TEXT;
3397 mi.id = IDM_DRIVESMENU;
3398 WinSendMsg(DirCnrMenu,
3399 MM_INSERTITEM,
3400 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3401 }
3402 first = TRUE;
3403 }
3404 if (directory) {
3405 hwndFrame = WinCreateStdWindow(hwndParent,
3406 WS_VISIBLE,
3407 &FrameFlags,
3408 WC_DIRCONTAINER,
3409 NULL,
3410 WS_VISIBLE | fwsAnimate,
3411 FM3ModHandle, DIR_FRAME, &hwndClient);
3412 if (hwndFrame && hwndClient) {
3413 id = DIR_FRAME + idinc++;
3414 if (idinc > 99)
3415 idinc = 0;
3416 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3417 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3418 if (!dcd) {
3419 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3420 hwndFrame = (HWND) 0;
3421 }
3422 else {
3423 dcd->size = sizeof(DIRCNRDATA);
3424 dcd->id = id;
3425 dcd->type = DIR_FRAME;
3426 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3427 dcd->hwndFrame = hwndFrame;
3428 dcd->hwndClient = hwndClient;
3429 dcd->hwndRestore = hwndRestore;
3430 dcd->dontclose = ((flags & 1) != 0);
3431 dcd->detailslongname = detailslongname;
3432 dcd->detailssubject = detailssubject;
3433 dcd->detailsea = detailsea;
3434 dcd->detailssize = detailssize;
3435 dcd->detailsicon = detailsicon;
3436 dcd->detailsattr = detailsattr;
3437 dcd->detailscrdate = detailscrdate;
3438 dcd->detailscrtime = detailscrtime;
3439 dcd->detailslwdate = detailslwdate;
3440 dcd->detailslwtime = detailslwtime;
3441 dcd->detailsladate = detailsladate;
3442 dcd->detailslatime = detailslatime;
3443 strcpy(dcd->directory, directory);
3444 add_udir(FALSE, directory);
3445 {
3446 PFNWP oldproc;
3447
3448 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3449 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3450 }
3451 dcd->hwndCnr = WinCreateWindow(hwndClient,
3452 WC_CONTAINER,
3453 NULL,
3454 CCS_AUTOPOSITION | CCS_MINIICONS |
3455 CCS_MINIRECORDCORE | ulCnrType |
3456 WS_VISIBLE,
3457 0,
3458 0,
3459 0,
3460 0,
3461 hwndClient,
3462 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3463 if (!dcd->hwndCnr) {
3464 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3465 IDS_WINCREATEWINDOW);
3466 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3467 xfree(dcd);
3468 hwndFrame = (HWND) 0;
3469 }
3470 else {
3471 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3472 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3473 (PFNWP) DirCnrWndProc);
3474 {
3475 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3476 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3477 };
3478
3479 if (!(flags & 2))
3480 ids[6] = 0;
3481 CommonCreateTextChildren(dcd->hwndClient,
3482 WC_DIRSTATUS, ids);
3483 }
3484 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3485 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3486 if (FrameFlags & FCF_TASKLIST) {
3487
3488 SWP swp, swpD;
3489 ULONG size = sizeof(swp);
3490 LONG cxScreen, cyScreen;
3491
3492 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3493 if (PrfQueryProfileData(fmprof,
3494 appname, "VDirSizePos", &swpD, &size)) {
3495 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3496 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3497 if (swp.x + swpD.cx > cxScreen)
3498 swp.x = cxScreen - swpD.cx;
3499 if (swp.y + swpD.cy > cyScreen)
3500 swp.y = cyScreen - swpD.cy;
3501 swp.cx = swpD.cx;
3502 swp.cy = swpD.cy;
3503 }
3504 WinSetWindowPos(hwndFrame,
3505 HWND_TOP,
3506 swp.x,
3507 swp.y,
3508 swp.cx,
3509 swp.cy,
3510 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3511 SWP_ACTIVATE);
3512 }
3513 }
3514 }
3515 }
3516 }
3517 return hwndFrame;
3518}
3519
3520#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3521#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3522#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.