source: trunk/dll/dircnrs.c@ 923

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

Updated for ticket 150: fixed/improved save and restore of the state
of directory containers when FM/2 is closed and re-opened.

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