source: trunk/dll/dircnrs.c@ 958

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

Add Unhide menu option every place that has hide (Ticket 218). Use additional xfrees where appropriate.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 91.5 KB
Line 
1
2/***********************************************************************
3
4 $Id: dircnrs.c 958 2008-02-18 00:41:39Z gyoung $
5
6 Directory containers
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2008 Steven H. Levine
10
11 16 Oct 02 SHL Handle large partitions
12 01 Aug 04 SHL Rework lstrip/rstrip usage
13 23 May 05 SHL Use QWL_USER
14 24 May 05 SHL Rework Win_Error usage
15 25 May 05 SHL Use ULONGLONG and CommaFmtULL
16 26 May 05 SHL More large file formatting updates
17 05 Jun 05 SHL Use QWL_USER
18 10 Nov 05 SHL Comments
19 13 Jul 06 SHL Use Runtime_Error
20 26 Jul 06 SHL Use chop_at_crnl
21 15 Aug 06 SHL Rework warning message text
22 07 Jan 07 GKY Move error strings etc. to string file
23 30 Mar 07 GKY Remove GetPString for window class names
24 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
25 06 Apr 07 GKY Add some error checking in drag/drop
26 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checking.
27 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
28 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
29 02 Aug 07 SHL Sync with CNRITEM mods
30 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
31 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
32 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
33 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
34 10 Jan 08 SHL Sync with CfgDlgProc mods
35 xx Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen
36 15 Feb 08 SHL Sync with settings menu rework
37
38***********************************************************************/
39
40#include <stdlib.h>
41#include <string.h>
42#include <ctype.h>
43#include <limits.h>
44#include <process.h> // _beginthread
45
46#define INCL_DOS
47#define INCL_WIN
48#define INCL_DOSERRORS
49#define INCL_LONGLONG
50
51#include "fm3dlg.h"
52#include "fm3str.h"
53#include "mle.h"
54#include "arccnrs.h" // StartArcCnr
55#include "comp.h" // COMPARE
56#include "filldir.h" // EmptyCnr...
57#include "errutil.h" // Dos_Error...
58#include "strutil.h" // GetPString
59#include "notebook.h" // CfgDlgProc
60#include "fm3dll.h"
61
62#pragma data_seg(DATA1)
63
64static PSZ pszSrcFile = __FILE__;
65
66MRESULT EXPENTRY DirFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
67{
68 return CommonFrameWndProc(DIR_CNR, hwnd, msg, mp1, mp2);
69}
70
71MRESULT EXPENTRY DirTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
72{
73 static BOOL emphasized = FALSE;
74 static HWND hwndButtonPopup = (HWND) 0;
75 static USHORT lastid = 0;
76 static ULONG timestamp = ULONG_MAX;
77
78 switch (msg) {
79 case WM_CREATE:
80 return CommonTextProc(hwnd, msg, mp1, mp2);
81
82 case WM_COMMAND:
83 {
84 DIRCNRDATA *dcd;
85 MRESULT mr;
86
87 mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
88 QW_PARENT),
89 DIR_CNR), msg, mp1, mp2);
90 if (hwndButtonPopup &&
91 SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
92 SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
93 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
94 QW_PARENT),
95 DIR_CNR), QWL_USER);
96 if (dcd)
97 SetDetailsSwitches(hwndButtonPopup, dcd);
98 }
99 return mr;
100 }
101
102 case UM_CONTEXTMENU:
103 case WM_CONTEXTMENU:
104 {
105 USHORT id;
106
107 id = WinQueryWindowUShort(hwnd, QWS_ID);
108 switch (id) {
109 case DIR_FOLDERICON:
110 if (fNoFoldMenu) {
111 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
112 DIR_CNR),
113 WM_COMMAND, MPFROM2SHORT(IDM_PREVIOUS, 0), mp2);
114 break;
115 }
116 /* else intentional fallthru */
117 case DIR_SELECTED:
118 case DIR_VIEW:
119 case DIR_SORT:
120 {
121 POINTL ptl = { 0, 0 };
122 SWP swp;
123 DIRCNRDATA *dcd;
124
125 if (hwndButtonPopup)
126 WinDestroyWindow(hwndButtonPopup);
127 if (id == DIR_SELECTED && msg == WM_CONTEXTMENU)
128 id = DIR_MAX;
129 if (id == lastid) {
130
131 ULONG check;
132
133 DosQuerySysInfo(QSV_MS_COUNT,
134 QSV_MS_COUNT, &check, sizeof(check));
135 if (check < timestamp + 500) {
136 lastid = 0;
137 goto MenuAbort;
138 }
139 }
140 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
141 CopyPresParams(hwndButtonPopup, hwnd);
142 if (hwndButtonPopup) {
143 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
144 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
145 QW_PARENT),
146 DIR_CNR), QWL_USER);
147 if (id == DIR_SORT) { /* don't have sort pathname in dirs */
148 WinSendMsg(hwndButtonPopup,
149 MM_DELETEITEM,
150 MPFROM2SHORT(IDM_SORTNAME, FALSE), MPVOID);
151 WinSendMsg(hwndButtonPopup,
152 MM_DELETEITEM,
153 MPFROM2SHORT(IDM_SORTNONE, FALSE), MPVOID);
154 if (dcd)
155 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
156 }
157 else if (id == DIR_VIEW) {
158 if (dcd) {
159 SetViewMenu(hwndButtonPopup, dcd->flWindowAttr);
160 SetDetailsSwitches(hwndButtonPopup, dcd);
161 }
162 }
163 else if (id == DIR_MAX) {
164
165 int x;
166 BOOL enable;
167 USHORT ids[] = { IDM_SELECTBOTH,
168 IDM_SELECTMORE,
169 IDM_SELECTONE,
170 IDM_SELECTNEWER,
171 IDM_SELECTOLDER,
172 IDM_SELECTBIGGER,
173 IDM_SELECTSMALLER,
174 IDM_DESELECTBOTH,
175 IDM_DESELECTMORE,
176 IDM_DESELECTONE,
177 IDM_DESELECTNEWER,
178 IDM_DESELECTOLDER,
179 IDM_DESELECTBIGGER,
180 IDM_DESELECTSMALLER,
181 0
182 };
183
184 enable = (CountDirCnrs(dcd->hwndParent) > 1);
185 for (x = 0; ids[x]; x++)
186 WinEnableMenuItem(hwndButtonPopup, ids[x], enable);
187 }
188 else if (id == DIR_SELECTED) {
189 if (dcd)
190 WinEnableMenuItem(hwndButtonPopup,
191 IDM_RESELECT, (dcd->lastselection != NULL));
192 }
193 ptl.x = 0;
194 if (WinPopupMenu(HWND_OBJECT,
195 HWND_OBJECT,
196 hwndButtonPopup, -32767, -32767, 0, 0)) {
197 WinQueryWindowPos(hwndButtonPopup, &swp);
198 ptl.y = -(swp.cy + 2);
199 }
200 else {
201 WinQueryWindowPos(hwnd, &swp);
202 ptl.y = swp.cy + 2;
203 }
204 if (WinPopupMenu(hwnd,
205 hwnd,
206 hwndButtonPopup,
207 ptl.x,
208 ptl.y,
209 0,
210 PU_HCONSTRAIN | PU_VCONSTRAIN |
211 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
212 CenterOverWindow(hwndButtonPopup);
213 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
214 }
215 }
216 }
217 break;
218 default:
219 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), DIR_CNR),
220 WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU), MPVOID);
221 break;
222 }
223 } // case WM_CONTENT_MENU
224
225 MenuAbort:
226
227 if (msg == UM_CONTEXTMENU)
228 return 0;
229 break;
230
231 case WM_MENUEND:
232 if (hwndButtonPopup == (HWND) mp2) {
233 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
234 WinDestroyWindow(hwndButtonPopup);
235 hwndButtonPopup = (HWND) 0;
236 DosQuerySysInfo(QSV_MS_COUNT,
237 QSV_MS_COUNT, &timestamp, sizeof(timestamp));
238 switch (lastid) {
239 case DIR_VIEW:
240 case DIR_SORT:
241 case DIR_FOLDERICON:
242 case DIR_SELECTED:
243 case DIR_MAX:
244 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
245 break;
246 }
247 }
248 break;
249
250 case WM_BUTTON3DOWN:
251 case WM_BUTTON1DOWN:
252 case WM_BUTTON3UP:
253 case WM_BUTTON1UP:
254 {
255 USHORT id;
256
257 id = WinQueryWindowUShort(hwnd, QWS_ID);
258 switch (id) {
259 case DIR_FILTER:
260 case DIR_VIEW:
261 case DIR_SORT:
262 case DIR_SELECTED:
263 case DIR_FOLDERICON:
264 case DIR_MAX:
265 return CommonTextButton(hwnd, msg, mp1, mp2);
266 }
267 }
268 break;
269
270 case WM_BUTTON1DBLCLK:
271 {
272 NOTIFYRECORDENTER nr;
273
274 memset(&nr, 0, sizeof(NOTIFYRECORDENTER));
275 nr.hwndCnr = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), DIR_CNR);
276 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
277 WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_ENTER), MPFROMP(&nr));
278 }
279 break;
280
281 case WM_MOUSEMOVE:
282 {
283 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
284 char *s = NULL;
285
286 if (fOtherHelp) {
287 if ((!hwndBubble ||
288 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
289 !WinQueryCapture(HWND_DESKTOP)) {
290 switch (id) {
291 case DIR_TOTALS:
292 s = GetPString(IDS_DIRCNRTOTALHELP);
293 break;
294 case DIR_SELECTED:
295 s = GetPString(IDS_DIRCNRSELECTEDHELP);
296 break;
297 case DIR_VIEW:
298 s = GetPString(IDS_DIRCNRVIEWHELP);
299 break;
300 case DIR_SORT:
301 s = GetPString(IDS_DIRCNRSORTHELP);
302 break;
303 case DIR_FILTER:
304 s = GetPString(IDS_DIRCNRFILTERHELP);
305 break;
306 case DIR_MAX:
307 s = GetPString(IDS_DIRCNRMAXHELP);
308 break;
309 case DIR_FOLDERICON:
310 s = GetPString(IDS_DIRCNRFOLDERHELP);
311 break;
312 default:
313 break;
314 }
315 if (s)
316 MakeBubble(hwnd, TRUE, s);
317 else if (hwndBubble)
318 WinDestroyWindow(hwndBubble);
319 }
320 }
321 switch (id) {
322 case DIR_MAX:
323 case DIR_FOLDERICON:
324 case DIR_FILTER:
325 case DIR_SORT:
326 case DIR_VIEW:
327 case DIR_SELECTED:
328 return CommonTextButton(hwnd, msg, mp1, mp2);
329 }
330 }
331 break;
332
333 case WM_CHORD:
334 case WM_BUTTON3CLICK:
335 case WM_BUTTON1CLICK:
336 case UM_CLICKED:
337 case UM_CLICKED3:
338 {
339 USHORT id, cmd = 0;
340
341 id = WinQueryWindowUShort(hwnd, QWS_ID);
342 if (msg == UM_CLICKED || msg == UM_CLICKED3) {
343 switch (id) {
344 case DIR_MAX:
345 cmd = IDM_MAXIMIZE;
346 break;
347 case DIR_VIEW:
348 case DIR_SELECTED:
349 case DIR_SORT:
350 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
351 break;
352 case DIR_FILTER:
353 cmd = IDM_FILTER;
354 break;
355 default:
356 break;
357 }
358 }
359 else if (id == DIR_FOLDERICON) {
360 if ((msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_CTRL)))
361 cmd = IDM_PREVIOUS;
362 else if (msg == WM_BUTTON3CLICK || msg == WM_CHORD)
363 cmd = IDM_RESCAN;
364 else if (msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_SHIFT))
365 cmd = IDM_WALKDIR;
366 else if (msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_ALT))
367 cmd = IDM_WINDOWDLG;
368 else
369 cmd = IDM_PARENT;
370 }
371 if (cmd)
372 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
373 DIR_CNR),
374 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
375 }
376 if (msg == UM_CLICKED || msg == UM_CLICKED3)
377 return 0;
378 break;
379
380 case DM_DROP:
381 case DM_DRAGOVER:
382 case DM_DRAGLEAVE:
383 case DM_DROPHELP:
384 case WM_BEGINDRAG:
385 if (msg == DM_DRAGOVER) {
386 if (!emphasized) {
387 emphasized = TRUE;
388 DrawTargetEmphasis(hwnd, emphasized);
389 }
390 }
391 else if (msg != WM_BEGINDRAG) {
392 if (emphasized) {
393 emphasized = FALSE;
394 DrawTargetEmphasis(hwnd, emphasized);
395 }
396 }
397 switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
398 case DIR_FOLDERICON:
399 switch (msg) {
400 case DM_DRAGOVER:
401 if (AcceptOneDrop(hwnd, mp1, mp2))
402 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
403 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
404 case DM_DROPHELP:
405 DropHelp(mp1, mp2, hwnd, GetPString(IDS_DIRCNRFOLDERDROPHELP));
406 return 0;
407 case DM_DROP:
408 {
409 char szFrom[CCHMAXPATH + 2];
410
411 if (emphasized) {
412 emphasized = FALSE;
413 DrawTargetEmphasis(hwnd, emphasized);
414 }
415 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom)))
416 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
417 DIR_CNR),
418 WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0),
419 MPFROMP(szFrom));
420 }
421 return 0;
422 default:
423 return PFNWPStatic(hwnd, msg, mp1, mp2);
424 }
425 case DIR_MAX:
426 if (msg == WM_BEGINDRAG)
427 return PFNWPStatic(hwnd, msg, mp1, mp2);
428 default:
429 {
430 CNRDRAGINFO cnd;
431 USHORT dcmd;
432
433 switch (msg) {
434 case DM_DROP:
435 dcmd = CN_DROP;
436 break;
437 case DM_DRAGOVER:
438 dcmd = CN_DRAGOVER;
439 break;
440 case DM_DRAGLEAVE:
441 dcmd = CN_DRAGLEAVE;
442 break;
443 case DM_DROPHELP:
444 dcmd = CN_DROPHELP;
445 break;
446 case WM_BEGINDRAG:
447 dcmd = CN_INITDRAG;
448 break;
449 }
450 memset(&cnd, 0, sizeof(cnd));
451 cnd.pDragInfo = (PDRAGINFO) mp1;
452 cnd.pRecord = NULL;
453 return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
454 WM_CONTROL,
455 MPFROM2SHORT(DIR_CNR, dcmd), MPFROMP(&cnd));
456 }
457 }
458 }
459 return PFNWPStatic(hwnd, msg, mp1, mp2);
460}
461
462MRESULT EXPENTRY DirClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
463 MPARAM mp2)
464{
465 switch (msg) {
466 case UM_CONTAINERDIR:
467 if (mp1) {
468
469 DIRCNRDATA *dcd;
470
471 *(CHAR *) mp1 = 0;
472 dcd = WinQueryWindowPtr(WinWindowFromID(hwnd, DIR_CNR), QWL_USER);
473 if (dcd)
474 strcpy((CHAR *) mp1, dcd->directory);
475 return MRFROMLONG(TRUE);
476 }
477 return 0;
478
479 case UM_CONTAINERHWND:
480 return MRFROMLONG(WinWindowFromID(hwnd, DIR_CNR));
481
482 case UM_VIEWSMENU:
483 return MRFROMLONG(CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP));
484
485 case UM_DRIVECMD:
486 case WM_INITMENU:
487 case UM_FILTER:
488 case UM_INITMENU:
489 case MM_PORTHOLEINIT:
490 case UM_COMMAND:
491 case UM_FILESMENU:
492 case UM_UPDATERECORD:
493 case UM_UPDATERECORDLIST:
494 return WinSendMsg(WinWindowFromID(hwnd, DIR_CNR), msg, mp1, mp2);
495
496 case WM_PSETFOCUS:
497 case WM_SETFOCUS:
498 if (mp2)
499 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
500 break;
501
502 case UM_FOCUSME:
503 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, DIR_CNR));
504 break;
505
506 case WM_PAINT:
507 {
508 HPS hps;
509 RECTL rcl;
510
511 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
512 if (hps) {
513 WinQueryWindowRect(hwnd, &rcl);
514 WinFillRect(hps, &rcl, CLR_PALEGRAY);
515 CommonTextPaint(hwnd, hps);
516 WinEndPaint(hps);
517 }
518 }
519 break;
520
521 case UM_SIZE:
522 case WM_SIZE:
523 if (msg == UM_SIZE) {
524
525 SWP swp;
526
527 WinQueryWindowPos(hwnd, &swp);
528 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
529 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
530 }
531 {
532 USHORT cx, cy, bx;
533
534 cx = SHORT1FROMMP(mp2);
535 cy = SHORT2FROMMP(mp2);
536 WinSetWindowPos(WinWindowFromID(hwnd, DIR_CNR), HWND_TOP,
537 0, 0, cx, cy - 24, SWP_SHOW | SWP_MOVE | SWP_SIZE);
538 if (WinWindowFromID(hwnd, DIR_MAX) != (HWND) 0) {
539 WinSetWindowPos(WinWindowFromID(hwnd, DIR_MAX), HWND_TOP,
540 cx - 22,
541 cy - 22, 20, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
542 cx -= 24;
543 }
544 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FOLDERICON), HWND_TOP,
545 2, cy - 22, 24, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
546 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
547 29,
548 cy - 22,
549 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
550 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
551 29 + (cx / 3) + 2,
552 cy - 22,
553 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
554 bx = (cx - (29 + (((cx / 3) + 2) * 2))) / 3;
555 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
556 29 + (((cx / 3) + 2) * 2),
557 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
558 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
559 29 + (((cx / 3) + 2) * 2) + bx,
560 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
561 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
562 29 + (((cx / 3) + 2) * 2) + (bx * 2),
563 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
564 }
565 CommonTextPaint(hwnd, (HPS) 0);
566 if (msg == UM_SIZE) {
567 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
568 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
569 return 0;
570 }
571 break;
572
573 case WM_COMMAND:
574 case WM_CONTROL:
575 case WM_CLOSE:
576 return WinSendMsg(WinWindowFromID(hwnd, DIR_CNR), msg, mp1, mp2);
577 }
578 return WinDefWindowProc(hwnd, msg, mp1, mp2);
579}
580
581MRESULT EXPENTRY DirObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
582{
583 DIRCNRDATA *dcd;
584
585 switch (msg) {
586 case WM_CREATE:
587 break;
588
589 case DM_PRINTOBJECT:
590 return MRFROMLONG(DRR_TARGET);
591
592 case DM_DISCARDOBJECT:
593 dcd = INSTDATA(hwnd);
594 if (fFM2Deletes && dcd) {
595
596 LISTINFO *li;
597 CNRDRAGINFO cni;
598
599 cni.pRecord = NULL;
600 cni.pDragInfo = (PDRAGINFO) mp1;
601 // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
602 li =
603 DoFileDrop(dcd->hwndCnr, dcd->directory, FALSE, MPVOID,
604 MPFROMP(&cni));
605 CheckPmDrgLimit(cni.pDragInfo);
606 if (li) {
607 li->type = (fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE;
608 if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
609 FreeListInfo(li);
610 else
611 return MRFROMLONG(DRR_SOURCE);
612 }
613 }
614 return MRFROMLONG(DRR_TARGET);
615
616 case UM_UPDATERECORDLIST:
617 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
618 if (dcd && mp1) {
619
620 INT numentries = 0;
621 CHAR **list = (CHAR **) mp1;
622
623 while (list[numentries])
624 numentries++;
625 if (numentries)
626 UpdateCnrList(dcd->hwndCnr, list, numentries, TRUE, dcd);
627 }
628 return 0;
629
630 case UM_SETUP:
631 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
632 if (dcd) {
633 /* set unique id */
634 WinSetWindowUShort(hwnd, QWS_ID, DIROBJ_FRAME + (DIR_FRAME - dcd->id));
635 dcd->hwndObject = hwnd;
636 if (ParentIsDesktop(hwnd, dcd->hwndParent))
637 DosSleep(100); //05 Aug 07 GKY 250
638 }
639 else
640 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
641 return 0;
642
643 case UM_RESCAN2:
644 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
645 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
646
647 FSALLOCATE fsa;
648 CHAR s[CCHMAXPATH * 2];
649 CHAR tf[64];
650 CHAR tb[64];
651 CHAR szFree[64];
652
653 DosError(FERR_DISABLEHARDERR);
654 if (!DosQueryFSInfo(toupper(*dcd->directory) - '@',
655 FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
656 CommaFmtULL(tb, sizeof(tb),
657 (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit *
658 fsa.cbSector), 'K');
659 sprintf(szFree, " {%s %s}", tb, GetPString(IDS_FREETEXT));
660 }
661 else
662 *szFree = 0;
663 commafmt(tf, sizeof(tf), dcd->totalfiles);
664 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
665 if (!fMoreButtons) {
666 sprintf(s, " [%s / %s]%s%s%s%s %s",
667 tf, tb, szFree,
668 (*dcd->mask.szMask || dcd->mask.antiattr ||
669 dcd->mask.attrFile != ALLATTRS) ? " (" : NullStr,
670 (*dcd->mask.szMask) ? dcd->mask.szMask :
671 (dcd->mask.antiattr ||
672 dcd->mask.attrFile != ALLATTRS) ?
673 GetPString(IDS_ALLTEXT) : NullStr,
674 (*dcd->mask.szMask || dcd->mask.antiattr ||
675 dcd->mask.attrFile != ALLATTRS) ? ")" : NullStr,
676 dcd->directory);
677 }
678 else {
679 sprintf(s, " [%s / %s]%s %s", tf, tb, szFree, dcd->directory);
680 }
681 if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
682 WinSetWindowText(hwndStatus, s);
683 }
684 return 0;
685
686 case UM_FLESH:
687 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
688 if (dcd) {
689
690 PCNRITEM pci, pciC;
691
692 pci = WinSendMsg(dcd->hwndCnr,
693 CM_QUERYRECORD,
694 MPVOID, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
695 while (pci && (INT) pci != -1) {
696 if (pci->attrFile & FILE_DIRECTORY) {
697 pciC = WinSendMsg(dcd->hwndCnr,
698 CM_QUERYRECORD,
699 MPFROMP(pci),
700 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
701 if (!pciC) {
702 Stubby(dcd->hwndCnr, pci);
703 DosSleep(0); //26 Aug 07 GKY 1
704 }
705 }
706 pci = WinSendMsg(dcd->hwndCnr,
707 CM_QUERYRECORD,
708 MPFROMP(pci), MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
709 }
710 dcd->firsttree = TRUE;
711 }
712 return 0;
713
714 case UM_RESCAN:
715 /*
716 * populate container
717 */
718 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
719 if (dcd) {
720 DosEnterCritSec();
721 if (dcd->stopflag)
722 dcd->stopflag--;
723 if (dcd->stopflag) {
724 DosExitCritSec();
725 return 0;
726 }
727 DosExitCritSec();
728 if (mp1) {
729 strcpy(dcd->previous, dcd->directory);
730 strcpy(dcd->directory, (CHAR *) mp1);
731 }
732 MakeValidDir(dcd->directory);
733 {
734 CHAR s[CCHMAXPATH + 8];
735
736 sprintf(s,
737 "%s%s%s",
738 (ParentIsDesktop(dcd->hwndFrame, (HWND) 0)) ?
739 "VDir" :
740 NullStr,
741 (ParentIsDesktop(dcd->hwndFrame, (HWND) 0)) ?
742 (!dcd->dontclose) ?
743 " Master: " : ": " : NullStr, dcd->directory);
744 WinSetWindowText(dcd->hwndFrame, s);
745 WinSetWindowText(WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR), s);
746 }
747 RemoveCnrItems(dcd->hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
748 AdjustCnrColsForFSType(dcd->hwndCnr, dcd->directory, dcd);
749 dcd->ullTotalBytes = dcd->totalfiles =
750 dcd->selectedfiles = dcd->selectedbytes = 0;
751 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0 / 0k");
752 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
753 if (hwndStatus &&
754 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
755 WinSetWindowText(hwndStatus, GetPString(IDS_SCANNINGTEXT));
756 if (hwndMain)
757 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
758 }
759 if (fSwitchTree && hwndTree) {
760 if (hwndMain) {
761 if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame)
762 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID);
763 }
764 else
765 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID);
766 }
767 dcd->firsttree = FALSE;
768 // fixme to check errors
769 FillDirCnr(dcd->hwndCnr, dcd->directory, dcd, &dcd->ullTotalBytes);
770 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
771 if (mp2 && !fLeaveTree && (dcd->flWindowAttr & CV_TREE)) {
772
773 ULONG flWindowAttr = dcd->flWindowAttr;
774 CNRINFO cnri;
775
776 flWindowAttr &=
777 (~(CV_NAME | CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
778 if (dcd->lastattr) {
779 if (dcd->lastattr & CV_TEXT)
780 flWindowAttr |= CV_TEXT;
781 else if (dcd->lastattr & CV_DETAIL)
782 flWindowAttr |= CV_DETAIL;
783 else if (dcd->lastattr & CV_ICON)
784 flWindowAttr |= CV_ICON;
785 else
786 flWindowAttr |= CV_NAME;
787 }
788 else
789 flWindowAttr |= CV_NAME;
790 flWindowAttr |= CV_FLOW;
791 memset(&cnri, 0, sizeof(CNRINFO));
792 cnri.cb = sizeof(CNRINFO);
793 if (WinSendMsg(dcd->hwndCnr, CM_QUERYCNRINFO, MPFROMP(&cnri),
794 MPFROMLONG(sizeof(CNRINFO)))) {
795 dcd->flWindowAttr = cnri.flWindowAttr = flWindowAttr;
796 WinSendMsg(dcd->hwndCnr, CM_SETCNRINFO,
797 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
798 SayView(WinWindowFromID(dcd->hwndClient,
799 DIR_VIEW), dcd->flWindowAttr);
800 }
801 }
802 if (dcd->flWindowAttr & CV_TREE)
803 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
804 if (*dcd->previous) {
805 if (strlen(dcd->previous) > strlen(dcd->directory) &&
806 !strnicmp(dcd->directory, dcd->previous,
807 strlen(dcd->directory)))
808 {
809 PCNRITEM pci = FindCnrRecord(dcd->hwndCnr,
810 dcd->previous,
811 NULL, TRUE, FALSE, TRUE);
812 if (pci && (INT) pci != -1) {
813 // make found item current (cursored) item
814 WinSendMsg(dcd->hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
815 MPFROM2SHORT(TRUE, CRA_CURSORED));
816 /* make sure that record shows in viewport */
817 ShowCnrRecord(dcd->hwndCnr, (PMINIRECORDCORE) pci);
818 }
819 }
820 }
821 }
822 return 0;
823
824 case UM_COMMAND:
825 if (mp1) {
826
827 LISTINFO *li = (LISTINFO *) mp1;
828
829 switch (li->type) {
830 case IDM_DOITYOURSELF:
831 case IDM_APPENDTOCLIP:
832 case IDM_SAVETOCLIP:
833 case IDM_ARCHIVE:
834 case IDM_ARCHIVEM:
835 case IDM_VIEWTEXT:
836 case IDM_VIEWBINARY:
837 case IDM_VIEWARCHIVE:
838 case IDM_VIEW:
839 case IDM_EDITTEXT:
840 case IDM_EDITBINARY:
841 case IDM_EDIT:
842 case IDM_OBJECT:
843 case IDM_SHADOW:
844 case IDM_SHADOW2:
845 case IDM_PRINT:
846 case IDM_ATTRS:
847 case IDM_DELETE:
848 case IDM_PERMDELETE:
849 case IDM_MCIPLAY:
850 case IDM_UPDATE:
851 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
852 return (MRESULT) TRUE;
853 break;
854 default:
855 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
856 return (MRESULT) TRUE;
857 }
858 }
859 return 0;
860
861 case UM_SELECT:
862 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
863 if (dcd) {
864 switch (SHORT1FROMMP(mp1)) {
865 case IDM_SELECTBOTH:
866 case IDM_SELECTONE:
867 case IDM_SELECTMORE:
868 case IDM_SELECTNEWER:
869 case IDM_SELECTOLDER:
870 case IDM_SELECTBIGGER:
871 case IDM_SELECTSMALLER:
872 case IDM_DESELECTBOTH:
873 case IDM_DESELECTONE:
874 case IDM_DESELECTMORE:
875 case IDM_DESELECTNEWER:
876 case IDM_DESELECTOLDER:
877 case IDM_DESELECTBIGGER:
878 case IDM_DESELECTSMALLER:
879 SpecialSelect2(dcd->hwndParent, SHORT1FROMMP(mp1));
880 break;
881 case IDM_SELECTLIST:
882 {
883 CHAR filename[CCHMAXPATH], *p, *pp;
884 ULONG size;
885
886 strcpy(filename, "*.LST");
887 size = CCHMAXPATH;
888 PrfQueryProfileData(fmprof, appname, "SaveToListName",
889 filename, &size);
890 pp = strrchr(filename, '\\');
891 if (!pp)
892 pp = filename;
893 p = strrchr(pp, '.');
894 if (p && *(p + 1) && p > pp + 1) {
895 if (pp > filename)
896 pp++;
897 *pp = '*';
898 pp++;
899 if (p > pp)
900 memmove(pp, p, strlen(p) + 1);
901 }
902 if (insert_filename(hwnd, filename, FALSE, FALSE))
903 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
904 NULL);
905 }
906 break;
907 case IDM_SELECTALL:
908 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
909 break;
910 case IDM_DESELECTALL:
911 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
912 break;
913 case IDM_SELECTALLFILES:
914 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
915 break;
916 case IDM_DESELECTALLFILES:
917 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
918 break;
919 case IDM_SELECTALLDIRS:
920 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
921 break;
922 case IDM_DESELECTALLDIRS:
923 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
924 break;
925 case IDM_DESELECTMASK:
926 case IDM_SELECTMASK:
927 {
928 MASK mask;
929 PCNRITEM pci = (PCNRITEM) mp2;
930
931 memset(&mask, 0, sizeof(MASK));
932 mask.fNoAttribs = TRUE;
933 mask.fNoDirs = TRUE;
934 mask.fText = TRUE;
935 strcpy(mask.prompt,
936 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
937 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
938 if (pci && (INT) pci != -1)
939 strcpy(mask.szMask, pci->pszFileName);
940 if (WinDlgBox(HWND_DESKTOP,
941 dcd->hwndCnr,
942 PickMaskDlgProc,
943 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
944 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
945 SelectAll(dcd->hwndCnr,
946 TRUE, TRUE, mask.szMask, mask.szText, FALSE);
947 else
948 DeselectAll(dcd->hwndCnr,
949 TRUE, TRUE, mask.szMask, mask.szText, FALSE);
950 }
951 }
952 break;
953
954 case IDM_DESELECTCLIP:
955 case IDM_SELECTCLIP:
956 {
957 CHAR **list;
958
959 list = ListFromClipboard(hwnd);
960 if (list) {
961 SelectList(dcd->hwndCnr, TRUE, FALSE,
962 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
963 NULL, NULL, list);
964 FreeList(list);
965 }
966 }
967 break;
968
969 case IDM_INVERT:
970 InvertAll(dcd->hwndCnr);
971 break;
972 }
973 }
974 return 0;
975
976 case UM_MASSACTION:
977 if (mp1) {
978
979 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
980 if (dcd) {
981
982 WORKER *wk;
983
984 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
985 if (!wk)
986 FreeListInfo((LISTINFO *) mp1);
987 else {
988 wk->size = sizeof(WORKER);
989 wk->hwndCnr = dcd->hwndCnr;
990 wk->hwndParent = dcd->hwndParent;
991 wk->hwndFrame = dcd->hwndFrame;
992 wk->hwndClient = dcd->hwndClient;
993 wk->li = (LISTINFO *) mp1;
994 strcpy(wk->directory, dcd->directory);
995 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
996 Runtime_Error(pszSrcFile, __LINE__,
997 GetPString(IDS_COULDNTSTARTTHREADTEXT));
998 free(wk);
999 FreeListInfo((LISTINFO *) mp1);
1000 }
1001 }
1002 }
1003 }
1004 return 0;
1005
1006 case UM_ACTION:
1007 if (mp1) {
1008
1009 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1010 if (dcd) {
1011
1012 WORKER *wk;
1013
1014 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
1015 if (!wk)
1016 FreeListInfo((LISTINFO *) mp1);
1017 else {
1018 wk->size = sizeof(WORKER);
1019 wk->hwndCnr = dcd->hwndCnr;
1020 wk->hwndParent = dcd->hwndParent;
1021 wk->hwndFrame = dcd->hwndFrame;
1022 wk->hwndClient = dcd->hwndClient;
1023 wk->li = (LISTINFO *) mp1;
1024 strcpy(wk->directory, dcd->directory);
1025 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
1026 Runtime_Error(pszSrcFile, __LINE__,
1027 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1028 free(wk);
1029 FreeListInfo((LISTINFO *) mp1);
1030 }
1031 }
1032 }
1033 }
1034 return 0;
1035
1036 case WM_CLOSE:
1037 WinDestroyWindow(hwnd);
1038 break;
1039
1040 case WM_DESTROY:
1041 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1042 if (dcd) {
1043 if (dcd->hwndRestore)
1044 WinSetWindowPos(dcd->hwndRestore,
1045 HWND_TOP,
1046 0,
1047 0,
1048 0,
1049 0,
1050 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
1051 FreeList(dcd->lastselection);
1052 free(dcd);
1053 DosPostEventSem(CompactSem);
1054 }
1055 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1056 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1057 break;
1058 }
1059 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1060}
1061
1062MRESULT EXPENTRY DirCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1063{
1064 DIRCNRDATA *dcd = INSTDATA(hwnd);
1065
1066 switch (msg) {
1067 case DM_PRINTOBJECT:
1068 return MRFROMLONG(DRR_TARGET);
1069
1070 case DM_DISCARDOBJECT:
1071 if (dcd)
1072 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1073 else
1074 return MRFROMLONG(DRR_TARGET);
1075
1076 case WM_CHAR:
1077 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1078 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1079 return (MRESULT) TRUE;
1080 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1081 switch (SHORT2FROMMP(mp2)) {
1082 case VK_INSERT:
1083 if ((shiftstate & KC_CTRL) == KC_CTRL)
1084 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
1085 else if ((shiftstate & KC_ALT) == KC_ALT)
1086 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_CREATE, 0), MPVOID);
1087 break;
1088 case VK_PAGEUP:
1089 if ((shiftstate & KC_CTRL) == KC_CTRL)
1090 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PARENT, 0), MPVOID);
1091 break;
1092 case VK_PAGEDOWN:
1093 if ((shiftstate & KC_CTRL) == KC_CTRL)
1094 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PREVIOUS, 0), MPVOID);
1095 break;
1096 case VK_HOME:
1097 if ((shiftstate & KC_CTRL) == KC_CTRL && dcd) {
1098
1099 CHAR s[CCHMAXPATH], *p;
1100
1101 strcpy(s, dcd->directory);
1102 p = strchr(s, '\\');
1103 if (p) {
1104 p++;
1105 *p = 0;
1106 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(s), MPVOID);
1107 }
1108 }
1109 break;
1110 case VK_DELETE:
1111 if ((shiftstate & KC_CTRL) == KC_CTRL)
1112 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1113 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1114 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1115 else
1116 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1117 break;
1118 }
1119 }
1120 if (shiftstate || fNoSearch)
1121 break;
1122 if (SHORT1FROMMP(mp1) & KC_CHAR) {
1123
1124 ULONG thistime, len;
1125 SEARCHSTRING srch;
1126 PCNRITEM pci;
1127
1128 if (!dcd)
1129 break;
1130 switch (SHORT1FROMMP(mp2)) {
1131 case '\x1b':
1132 case '\r':
1133 case '\n':
1134 dcd->lasttime = 0;
1135 *dcd->szCommonName = 0;
1136 break;
1137 default:
1138 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1139 if (thistime > dcd->lasttime + 1250)
1140 *dcd->szCommonName = 0;
1141 dcd->lasttime = thistime;
1142 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
1143 break;
1144 KbdRetry:
1145 len = strlen(dcd->szCommonName);
1146 if (len >= CCHMAXPATH - 1) {
1147 *dcd->szCommonName = 0;
1148 len = 0;
1149 }
1150 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1151 dcd->szCommonName[len + 1] = 0;
1152 memset(&srch, 0, sizeof(SEARCHSTRING));
1153 srch.cb = (ULONG) sizeof(SEARCHSTRING);
1154 srch.pszSearch = (PSZ) dcd->szCommonName;
1155 srch.fsPrefix = TRUE;
1156 srch.fsCaseSensitive = FALSE;
1157 srch.usView = CV_ICON;
1158 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
1159 MPFROMLONG(CMA_FIRST));
1160 if (pci && (INT) pci != -1) {
1161
1162 USHORT attrib = CRA_CURSORED;
1163
1164 /* make found item current item */
1165 if (!stricmp(pci->pszFileName, dcd->szCommonName))
1166 attrib |= CRA_SELECTED;
1167 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1168 MPFROM2SHORT(TRUE, attrib));
1169 /* make sure that record shows in viewport */
1170 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1171 return (MRESULT) TRUE;
1172 }
1173 else {
1174 if (SHORT1FROMMP(mp2) == ' ') {
1175 dcd->szCommonName[len] = 0;
1176 break;
1177 }
1178 *dcd->szCommonName = 0;
1179 dcd->lasttime = 0;
1180 if (len) // retry as first letter if no match
1181 goto KbdRetry;
1182 }
1183 break;
1184 }
1185 }
1186 break;
1187
1188 case WM_MOUSEMOVE:
1189 case WM_BUTTON1UP:
1190 case WM_BUTTON2UP:
1191 case WM_BUTTON3UP:
1192 case WM_CHORD:
1193 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1194 break;
1195
1196 case WM_BUTTON1MOTIONEND:
1197 {
1198 CNRINFO cnri;
1199
1200 memset(&cnri, 0, sizeof(CNRINFO));
1201 cnri.cb = sizeof(CNRINFO);
1202 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1203 MPFROMLONG(sizeof(CNRINFO)))) {
1204 if (cnri.flWindowAttr & CV_DETAIL)
1205 PrfWriteProfileData(fmprof, appname, "CnrSplitBar",
1206 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
1207 }
1208 }
1209 break;
1210
1211 case UM_COMPARE:
1212 if (dcd && mp1 && mp2) {
1213
1214 COMPARE *cmp;
1215 CHAR *leftdir = (CHAR *) mp1, *rightdir = (CHAR *) mp2;
1216
1217 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1218 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1219 if (cmp) {
1220 cmp->size = sizeof(COMPARE);
1221 strcpy(cmp->leftdir, leftdir);
1222 strcpy(cmp->rightdir, rightdir);
1223 cmp->hwndParent = dcd->hwndParent;
1224 cmp->dcd.hwndParent = dcd->hwndParent;
1225 WinDlgBox(HWND_DESKTOP,
1226 HWND_DESKTOP,
1227 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1228 }
1229 }
1230 }
1231 return 0;
1232
1233 case WM_PRESPARAMCHANGED:
1234 PresParamChanged(hwnd, "DirCnr", mp1, mp2);
1235 break;
1236
1237 case UM_UPDATERECORDLIST:
1238 if (dcd && mp1)
1239 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1240 return 0;
1241
1242 case UM_UPDATERECORD:
1243 if (dcd && mp1) {
1244
1245 CHAR *filename;
1246
1247 filename = mp1;
1248 if (filename)
1249 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1250 }
1251 return 0;
1252
1253 case WM_SETFOCUS:
1254 /*
1255 * put name of our window (directory name) on status line
1256 */
1257 if (dcd && hwndStatus && mp2) {
1258
1259 PCNRITEM pci = NULL;
1260
1261 if (fAutoView && hwndMain) {
1262 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
1263 MPFROMSHORT(CRA_CURSORED));
1264 if (pci && (INT) pci != -1 &&
1265 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1266 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1267 else
1268 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1269 }
1270 if (*dcd->directory) {
1271 if (hwndMain)
1272 WinSendMsg(hwndMain,
1273 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1274 else
1275 add_udir(FALSE, dcd->directory);
1276 }
1277 if (hwndMain)
1278 PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
1279 }
1280 if (mp2) {
1281 LastDir = hwnd;
1282 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1283 if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory)
1284 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID);
1285 }
1286 break;
1287
1288 case UM_SETDIR:
1289 if (dcd && mp1) {
1290
1291 CHAR fullname[CCHMAXPATH];
1292
1293 DosError(FERR_DISABLEHARDERR);
1294 if (!DosQueryPathInfo((CHAR *) mp1,
1295 FIL_QUERYFULLNAME, fullname, sizeof(fullname))) {
1296 if (stricmp(dcd->directory, fullname)) {
1297 strcpy(dcd->previous, dcd->directory);
1298 strcpy(dcd->directory, fullname);
1299 DosEnterCritSec();
1300 dcd->stopflag++;
1301 DosExitCritSec();
1302 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
1303 strcpy(dcd->directory, dcd->previous);
1304 DosEnterCritSec();
1305 dcd->stopflag--;
1306 DosExitCritSec();
1307 }
1308 else if (*dcd->directory) {
1309 if (hwndMain)
1310 WinSendMsg(hwndMain,
1311 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1312 else
1313 add_udir(FALSE, dcd->directory);
1314 }
1315 }
1316 }
1317 }
1318 break;
1319
1320 case UM_RESCAN:
1321 if (dcd) {
1322
1323 CNRINFO cnri;
1324 CHAR s[CCHMAXPATH * 2], tf[81], tb[81];
1325 PCNRITEM pci;
1326
1327 memset(&cnri, 0, sizeof(CNRINFO));
1328 cnri.cb = sizeof(CNRINFO);
1329 WinSendMsg(hwnd,
1330 CM_QUERYCNRINFO,
1331 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1332 cnri.pszCnrTitle = dcd->directory;
1333 WinSendMsg(hwnd,
1334 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
1335 dcd->totalfiles = cnri.cRecords;
1336 commafmt(tb, sizeof(tb), dcd->totalfiles);
1337 CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K');
1338 sprintf(s, "%s / %s", tb, tf);
1339 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1340 commafmt(tb, sizeof(tb), dcd->selectedfiles);
1341 CommaFmtULL(tf, sizeof(tf), dcd->selectedbytes, 'K');
1342 sprintf(s, "%s / %s", tb, tf);
1343 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1344 if (hwndStatus &&
1345 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1346 PostMsg(dcd->hwndObject, UM_RESCAN2, MPVOID, MPVOID);
1347 if ((fSplitStatus && hwndStatus2) || fMoreButtons) {
1348 pci = WinSendMsg(hwnd,
1349 CM_QUERYRECORDEMPHASIS,
1350 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1351 if (pci && (INT) pci != -1) {
1352 if (fSplitStatus && hwndStatus2) {
1353 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1354 if (!fMoreButtons)
1355 sprintf(s,
1356 " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
1357 tb,
1358 pci->date.year,
1359 pci->date.month,
1360 pci->date.day,
1361 pci->time.hours,
1362 pci->time.minutes,
1363 pci->time.seconds,
1364 pci->pszDispAttr, pci->pszFileName);
1365 else {
1366 *tf = 0;
1367 if (pci->cbFile + pci->easize > 1024) {
1368 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1369 }
1370 sprintf(s,
1371 GetPString(IDS_STATUSSIZETEXT),
1372 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1373 }
1374 WinSetWindowText(hwndStatus2, s);
1375 }
1376 else
1377 WinSetWindowText(hwndStatus2, NullStr);
1378 if (fMoreButtons) {
1379 WinSetWindowText(hwndName, pci->pszFileName);
1380 sprintf(s,
1381 "%04u/%02u/%02u %02u:%02u:%02u",
1382 pci->date.year,
1383 pci->date.month,
1384 pci->date.day,
1385 pci->time.hours, pci->time.minutes, pci->time.seconds);
1386 WinSetWindowText(hwndDate, s);
1387 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1388 }
1389 }
1390 else {
1391 WinSetWindowText(hwndStatus2, NullStr);
1392 WinSetWindowText(hwndName, NullStr);
1393 WinSetWindowText(hwndDate, NullStr);
1394 WinSetWindowText(hwndAttr, NullStr);
1395 }
1396 }
1397 }
1398 }
1399 return 0;
1400
1401 case UM_SORTRECORD:
1402 if (dcd) {
1403
1404 CNRINFO cnri;
1405
1406 memset(&cnri, 0, sizeof(CNRINFO));
1407 cnri.cb = sizeof(CNRINFO);
1408 WinSendMsg(hwnd,
1409 CM_QUERYCNRINFO,
1410 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1411 cnri.pSortRecord = (PVOID) SortDirCnr;
1412 WinSendMsg(hwnd,
1413 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PSORTRECORD));
1414 WinSendMsg(hwnd,
1415 CM_SORTRECORD,
1416 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
1417 }
1418 return 0;
1419
1420 case UM_SETUP:
1421 if (dcd) {
1422 if (!dcd->hwndObject) {
1423 /*
1424 * first time through -- set things up
1425 */
1426
1427 CNRINFO cnri;
1428
1429 RestorePresParams(hwnd, "DirCnr");
1430 memset(&cnri, 0, sizeof(CNRINFO));
1431 cnri.cb = sizeof(CNRINFO);
1432 WinSendMsg(hwnd,
1433 CM_QUERYCNRINFO,
1434 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1435 cnri.cyLineSpacing = 0;
1436 cnri.cxTreeIndent = 12L;
1437
1438 cnri.flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1439 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES | CV_MINI |
1440 CV_FLOW);
1441 cnri.pSortRecord = (PVOID) SortDirCnr;
1442
1443 {
1444 ULONG size = sizeof(ULONG);
1445
1446 PrfQueryProfileData(fmprof,
1447 appname,
1448 "DirflWindowAttr",
1449 (PVOID) & cnri.flWindowAttr, &size);
1450 size = sizeof(MASK);
1451 if (!*dcd->mask.szMask &&
1452 !dcd->mask.attrFile && !dcd->mask.antiattr) {
1453 if (PrfQueryProfileSize(fmprof,
1454 appname, "DirFilter", &size) && size) {
1455 PrfQueryProfileData(fmprof,
1456 appname, "DirFilter", &dcd->mask, &size);
1457 SetMask(dcd->mask.szMask, &dcd->mask);
1458 }
1459 else
1460 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1461 FILE_ARCHIVED | FILE_DIRECTORY |
1462 FILE_HIDDEN | FILE_SYSTEM);
1463 }
1464 *(dcd->mask.prompt) = 0;
1465 }
1466 if (dcd->flWindowAttr)
1467 cnri.flWindowAttr = dcd->flWindowAttr;
1468 else
1469 dcd->flWindowAttr = cnri.flWindowAttr;
1470 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH |
1471 CA_TITLEREADONLY | CA_TITLESEPARATOR));
1472 cnri.flWindowAttr |= CV_FLOW;
1473 dcd->flWindowAttr |= CV_FLOW;
1474 if (WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR))
1475 cnri.flWindowAttr &= (~CA_CONTAINERTITLE);
1476 else
1477 cnri.flWindowAttr |= CA_CONTAINERTITLE;
1478 if (!dcd->sortFlags)
1479 dcd->sortFlags = sortFlags;
1480 WinSendMsg(hwnd,
1481 CM_SETCNRINFO,
1482 MPFROMP(&cnri),
1483 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1484 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1485 SetCnrCols(hwnd, FALSE);
1486 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) {
1487 Runtime_Error(pszSrcFile, __LINE__,
1488 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1489 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1490 return 0;
1491 }
1492 else
1493 DosSleep(32); //05 Aug 07 GKY 64
1494 WinEnableMenuItem(DirCnrMenu, IDM_FINDINTREE, (hwndTree != (HWND) 0));
1495 }
1496 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1497 DIR_FILTER), &dcd->mask, FALSE);
1498 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1499 DIR_SORT), dcd->sortFlags, FALSE);
1500 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1501 DIR_VIEW), dcd->flWindowAttr);
1502 }
1503 else {
1504 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1505 return 0;
1506 }
1507 return 0;
1508
1509 case UM_SETUP2:
1510 if (dcd)
1511 {
1512 AdjustCnrColsForPref(hwnd, NULL, dcd, FALSE);
1513 }
1514 else {
1515 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1516 return 0;
1517 }
1518 return 0;
1519
1520 case WM_MENUEND:
1521 if (dcd) {
1522
1523 HWND hwndMenu = (HWND) mp2;
1524
1525 if (hwndMenu == DirCnrMenu ||
1526 hwndMenu == FileMenu || hwndMenu == DirMenu) {
1527 MarkAll(hwnd, TRUE, FALSE, TRUE);
1528 if (dcd->cnremphasized) {
1529 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1530 MPFROM2SHORT(FALSE, CRA_SOURCE));
1531 dcd->cnremphasized = FALSE;
1532 }
1533 }
1534 }
1535 break;
1536
1537 case UM_OPENWINDOWFORME:
1538 if (dcd) {
1539 if (mp1 && !IsFile((CHAR *) mp1)) {
1540 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
1541 }
1542 else if (mp1 && IsFile(mp1) == 1) {
1543 StartArcCnr(HWND_DESKTOP,
1544 dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
1545 }
1546 }
1547 return 0;
1548
1549 case MM_PORTHOLEINIT:
1550 if (dcd) {
1551 switch (SHORT1FROMMP(mp1)) {
1552 case 0:
1553 case 1:
1554 {
1555 ULONG wmsg;
1556
1557 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1558 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
1559 wmsg, MPVOID, MPVOID), mp1, mp2);
1560 }
1561 break;
1562 }
1563 }
1564 break;
1565
1566 case UM_INITMENU:
1567 case WM_INITMENU:
1568 if (dcd) {
1569 switch (SHORT1FROMMP(mp1)) {
1570 case IDM_FILESMENU:
1571 CopyPresParams((HWND) mp2, hwndMainMenu);
1572 if (isalpha(*dcd->directory)) {
1573 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
1574 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, FALSE);
1575 WinEnableMenuItem((HWND) mp2, IDM_RENAME, FALSE);
1576 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1577 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, FALSE);
1578 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, FALSE);
1579 WinEnableMenuItem((HWND) mp2, IDM_DELETE, FALSE);
1580 WinEnableMenuItem((HWND) mp2, IDM_EDIT, FALSE);
1581 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, FALSE);
1582 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, FALSE);
1583 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, FALSE);
1584 }
1585 else {
1586 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, TRUE);
1587 WinEnableMenuItem((HWND) mp2, IDM_RENAME, TRUE);
1588 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1589 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, TRUE);
1590 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, TRUE);
1591 WinEnableMenuItem((HWND) mp2, IDM_DELETE, TRUE);
1592 WinEnableMenuItem((HWND) mp2, IDM_EDIT, TRUE);
1593 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, TRUE);
1594 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, TRUE);
1595 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
1596 }
1597 }
1598 break;
1599
1600 case IDM_VIEWSMENU:
1601 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1602 CopyPresParams((HWND) mp2, hwndMainMenu);
1603 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1604 (dcd->lastselection != NULL));
1605 if (isalpha(*dcd->directory)) {
1606 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE)
1607 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1608 else
1609 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1610 }
1611 WinEnableMenuItem((HWND) mp2,
1612 IDM_SELECTCOMPAREMENU,
1613 (CountDirCnrs(dcd->hwndParent) > 1));
1614 break;
1615
1616 case IDM_DETAILSSETUP:
1617 SetDetailsSwitches((HWND) mp2, dcd);
1618 break;
1619
1620 case IDM_COMMANDSMENU:
1621 SetupCommandMenu((HWND) mp2, hwnd);
1622 break;
1623
1624 case IDM_SORTSUBMENU:
1625 SetSortChecks((HWND) mp2, dcd->sortFlags);
1626 break;
1627
1628 case IDM_WINDOWSMENU:
1629 SetupWinList((HWND) mp2,
1630 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
1631 break;
1632 }
1633 dcd->hwndLastMenu = (HWND) mp2;
1634 }
1635 if (msg == WM_INITMENU)
1636 break;
1637 return 0;
1638
1639 case UM_FILTER:
1640 if (dcd) {
1641
1642 PCNRITEM pci;
1643
1644 if (mp1) {
1645 DosEnterCritSec();
1646 SetMask((CHAR *) mp1, &dcd->mask);
1647 DosExitCritSec();
1648 }
1649 dcd->suspendview = 1;
1650 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1651 dcd->suspendview = 0;
1652 if (fAutoView && hwndMain) {
1653 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1654 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1655 if (pci && (INT) pci != -1 &&
1656 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1657 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1658 else
1659 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1660 }
1661 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1662 }
1663 return 0;
1664
1665 case UM_COMMAND:
1666 if (mp1) {
1667 if (dcd) {
1668 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1669 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1670 FreeListInfo((LISTINFO *) mp1);
1671 }
1672 else
1673 return (MRESULT) TRUE;
1674 }
1675 else
1676 FreeListInfo((LISTINFO *) mp1);
1677 }
1678 return 0;
1679
1680 case UM_NOTIFY:
1681 if (mp2)
1682 Notify((CHAR *) mp2);
1683 return 0;
1684
1685 case UM_DRIVECMD:
1686 if (mp1)
1687 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0), mp1);
1688 return 0;
1689
1690 case WM_COMMAND:
1691 DosError(FERR_DISABLEHARDERR);
1692 if (dcd) {
1693 switch (SHORT1FROMMP(mp1)) {
1694 case IDM_SETTARGET:
1695 SetTargetDir(hwnd, FALSE);
1696 break;
1697
1698 case IDM_CREATE:
1699 {
1700 STRINGINPARMS sip;
1701 CHAR filename[CCHMAXPATHCOMP];
1702
1703 memset(&sip, 0, sizeof(sip));
1704 sip.help = GetPString(IDS_CREATETEXT);
1705 sip.prompt = GetPString(IDS_CREATEPROMPTTEXT);
1706 sip.inputlen = CCHMAXPATHCOMP - (strlen(dcd->directory) - 1);
1707 strcpy(filename, "NEWFILE.TXT");
1708 sip.ret = filename;
1709 sip.title = GetPString(IDS_CREATETITLETEXT);
1710 if (WinDlgBox(HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle,
1711 STR_FRAME, &sip)) {
1712 bstrip(sip.ret);
1713 if (*sip.ret) {
1714 CHAR newfile[CCHMAXPATH];
1715 FILE *fp;
1716 INT test;
1717 PCNRITEM pci;
1718
1719 strcpy(newfile, dcd->directory);
1720 if (newfile[strlen(newfile) - 1] != '\\')
1721 strcat(newfile, "\\");
1722 strcat(newfile, sip.ret);
1723 test = IsFile(newfile);
1724 if (test != 1)
1725 fp = fopen(newfile, "w");
1726 if (test != 1 && !fp) {
1727 saymsg(MB_ENTER,
1728 hwnd,
1729 GetPString(IDS_ERRORTEXT),
1730 GetPString(IDS_CREATEERRORTEXT), newfile);
1731 }
1732 else {
1733 if (fp) {
1734 WinSendMsg(hwnd, UM_UPDATERECORD, MPFROMP(newfile), MPVOID);
1735 fclose(fp);
1736 }
1737 if (*editor) {
1738
1739 CHAR *dummy[2];
1740
1741 dummy[0] = newfile;
1742 dummy[1] = NULL;
1743 ExecOnList(hwnd,
1744 editor, WINDOWED | SEPARATE, NULL, dummy, NULL,
1745 pszSrcFile, __LINE__);
1746 }
1747 else
1748 StartMLEEditor(dcd->hwndParent, 4, newfile, dcd->hwndFrame);
1749 pci = FindCnrRecord(hwnd, newfile, NULL, TRUE, FALSE, TRUE);
1750 if (pci && (INT) pci != -1)
1751 /* make sure that record shows in viewport */
1752 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1753 }
1754 }
1755 }
1756 }
1757 break;
1758
1759 case IDM_CONTEXTMENU:
1760 {
1761 PCNRITEM pci;
1762
1763 pci = (PCNRITEM) CurrentRecord(hwnd);
1764 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
1765 MPFROMP(pci));
1766 }
1767 break;
1768
1769 case IDM_MAXIMIZE:
1770 PostMsg(hwndMain, UM_MAXIMIZE, MPFROMLONG(dcd->hwndFrame), MPVOID);
1771 break;
1772
1773 case IDM_SHOWALLFILESCNR:
1774 StartSeeAll(HWND_DESKTOP, FALSE, dcd->directory);
1775 break;
1776
1777 case IDM_SHOWALLFILES:
1778 {
1779 PCNRITEM pci;
1780
1781 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1782 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1783 if (pci && (INT) pci != -1) {
1784
1785 static CHAR dirname[CCHMAXPATH];
1786
1787 strcpy(dirname, pci->pszFileName);
1788 MakeValidDir(dirname);
1789 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1790 }
1791 }
1792 break;
1793
1794 case IDM_FINDINTREE:
1795 if (hwndTree)
1796 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory),
1797 MPFROMLONG(1L));
1798 break;
1799
1800 case IDM_BEGINEDIT:
1801 OpenEdit(hwnd);
1802 break;
1803
1804 case IDM_ENDEDIT:
1805 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1806 break;
1807
1808 case IDM_SHOWSELECT:
1809 QuickPopup(hwnd,
1810 dcd,
1811 CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP), IDM_SELECTSUBMENU);
1812 break;
1813
1814 case IDM_SHOWSORT:
1815 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP),
1816 IDM_SORTSUBMENU);
1817 break;
1818
1819 case IDM_VIEWORARC:
1820 {
1821 SWP swp;
1822 PCNRITEM pci;
1823
1824 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1825 MPFROMLONG(CMA_FIRST),
1826 MPFROMSHORT(CRA_CURSORED));
1827 if (pci && (INT) pci != -1) {
1828 WinQueryWindowPos(dcd->hwndFrame, &swp);
1829 DefaultViewKeys(hwnd,
1830 dcd->hwndFrame,
1831 dcd->hwndParent, &swp, pci->pszFileName);
1832 }
1833 }
1834 break;
1835
1836 case IDM_DIRCNRSETTINGS:
1837 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1838 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_DIRCNRSETTINGS), mp2);
1839 else {
1840 WinDlgBox(HWND_DESKTOP,
1841 hwnd,
1842 CfgDlgProc,
1843 FM3ModHandle,
1844 CFG_FRAME,
1845 MPFROMLONG(IDM_DIRCNRSETTINGS));
1846 }
1847 break;
1848
1849 case IDM_QTREE:
1850 case IDM_TREE:
1851 {
1852 CHAR newpath[CCHMAXPATH];
1853 APIRET rc;
1854 PCNRITEM pci;
1855
1856 if (SHORT1FROMMP(mp1) == IDM_TREE) {
1857 pci = (PCNRITEM) CurrentRecord(hwnd);
1858 if (pci && (INT) pci != -1)
1859 strcpy(newpath, pci->pszFileName);
1860 else
1861 strcpy(newpath, dcd->directory);
1862 }
1863 else
1864 strcpy(newpath, dcd->directory);
1865 MakeValidDir(newpath);
1866 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ObjCnrDlgProc,
1867 FM3ModHandle, QTREE_FRAME, MPFROMP(newpath));
1868 if (rc)
1869 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(newpath), MPVOID);
1870 }
1871 break;
1872
1873 case IDM_RESELECT:
1874 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1875 break;
1876
1877 case IDM_HELP:
1878 if (hwndHelp) {
1879 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1880 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
1881 else
1882 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
1883 }
1884 break;
1885
1886 case IDM_WINDOWDLG:
1887 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1888 PostMsg(dcd->hwndParent, UM_COMMAND,
1889 MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
1890 break;
1891
1892 case IDM_SORTSMARTNAME:
1893 case IDM_SORTNAME:
1894 case IDM_SORTFILENAME:
1895 case IDM_SORTSIZE:
1896 case IDM_SORTEASIZE:
1897 case IDM_SORTFIRST:
1898 case IDM_SORTLAST:
1899 case IDM_SORTLWDATE:
1900 case IDM_SORTLADATE:
1901 case IDM_SORTCRDATE:
1902 case IDM_SORTSUBJECT:
1903 dcd->sortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1904 case IDM_SORTDIRSFIRST:
1905 case IDM_SORTDIRSLAST:
1906 case IDM_SORTREVERSE:
1907 switch (SHORT1FROMMP(mp1)) {
1908 case IDM_SORTSUBJECT:
1909 dcd->sortFlags |= SORT_SUBJECT;
1910 break;
1911 case IDM_SORTSMARTNAME:
1912 case IDM_SORTFILENAME:
1913 dcd->sortFlags |= SORT_FILENAME;
1914 break;
1915 case IDM_SORTSIZE:
1916 dcd->sortFlags |= SORT_SIZE;
1917 break;
1918 case IDM_SORTEASIZE:
1919 dcd->sortFlags |= SORT_EASIZE;
1920 break;
1921 case IDM_SORTFIRST:
1922 dcd->sortFlags |= SORT_FIRSTEXTENSION;
1923 break;
1924 case IDM_SORTLAST:
1925 dcd->sortFlags |= SORT_LASTEXTENSION;
1926 break;
1927 case IDM_SORTLWDATE:
1928 dcd->sortFlags |= SORT_LWDATE;
1929 break;
1930 case IDM_SORTLADATE:
1931 dcd->sortFlags |= SORT_LADATE;
1932 break;
1933 case IDM_SORTCRDATE:
1934 dcd->sortFlags |= SORT_CRDATE;
1935 break;
1936 case IDM_SORTDIRSFIRST:
1937 if (dcd->sortFlags & SORT_DIRSFIRST)
1938 dcd->sortFlags &= (~SORT_DIRSFIRST);
1939 else {
1940 dcd->sortFlags |= SORT_DIRSFIRST;
1941 dcd->sortFlags &= (~SORT_DIRSLAST);
1942 }
1943 break;
1944 case IDM_SORTDIRSLAST:
1945 if (dcd->sortFlags & SORT_DIRSLAST)
1946 dcd->sortFlags &= (~SORT_DIRSLAST);
1947 else {
1948 dcd->sortFlags |= SORT_DIRSLAST;
1949 dcd->sortFlags &= (~SORT_DIRSFIRST);
1950 }
1951 break;
1952 case IDM_SORTREVERSE:
1953 if (dcd->sortFlags & SORT_REVERSE)
1954 dcd->sortFlags &= (~SORT_REVERSE);
1955 else
1956 dcd->sortFlags |= SORT_REVERSE;
1957 break;
1958 }
1959 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortDirCnr),
1960 MPFROMLONG(dcd->sortFlags));
1961 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1962 DIR_SORT), dcd->sortFlags, FALSE);
1963 break;
1964
1965 case IDM_COLLECT:
1966 if (!Collector) {
1967
1968 HWND hwndC;
1969 SWP swp;
1970
1971 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
1972 (!fExternalCollector && !strcmp(realappname, FM3Str)))
1973 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
1974 hwndC = StartCollector((fExternalCollector ||
1975 strcmp(realappname, FM3Str)) ?
1976 HWND_DESKTOP : dcd->hwndParent, 4);
1977 if (hwndC) {
1978 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
1979 (!fExternalCollector && !strcmp(realappname, FM3Str)))
1980 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
1981 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
1982 SWP_SHOW | SWP_ZORDER);
1983 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) && fAutoTile &&
1984 !strcmp(realappname, FM3Str))
1985 TileChildren(dcd->hwndParent, TRUE);
1986 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
1987 DosSleep(100); //05 Aug 07 GKY 250
1988 }
1989 }
1990 else
1991 StartCollector(dcd->hwndParent, 4);
1992 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
1993 break;
1994
1995 case IDM_COLLECTOR:
1996 DosSleep(32); //05 Aug 07 GKY 64
1997 {
1998 CHAR **list;
1999
2000 list = BuildList(hwnd);
2001 if (list) {
2002 if (Collector) {
2003 if (!PostMsg(Collector,
2004 WM_COMMAND,
2005 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2006 FreeList(list);
2007 else if (fUnHilite)
2008 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2009 }
2010 else
2011 FreeList(list);
2012 }
2013 }
2014 break;
2015
2016 case IDM_UNDELETE:
2017 {
2018 PCNRITEM pci;
2019 CHAR path[CCHMAXPATH];
2020
2021 pci = (PCNRITEM) CurrentRecord(hwnd);
2022 if (pci && (INT) pci != -1) {
2023 strcpy(path, pci->pszFileName);
2024 MakeValidDir(path);
2025 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2026 UNDEL_FRAME, MPFROMP(path));
2027 }
2028 }
2029 break;
2030
2031 case IDM_UNDELETESPEC:
2032 WinDlgBox(HWND_DESKTOP,
2033 hwnd,
2034 UndeleteDlgProc,
2035 FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
2036 break;
2037
2038 case IDM_RESORT:
2039// WinSendMsg(hwnd,
2040// CM_SORTRECORD,
2041// MPFROMP(SortDirCnr),
2042// MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
2043 WinSendMsg(hwnd,
2044 CM_SORTRECORD,
2045 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
2046 break;
2047
2048 case IDM_FILTER:
2049 {
2050 BOOL empty = FALSE;
2051 PCNRITEM pci;
2052 CHAR *p;
2053
2054 if (!*dcd->mask.szMask) {
2055 empty = TRUE;
2056 pci = (PCNRITEM) CurrentRecord(hwnd);
2057 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
2058 p = strrchr(pci->pszFileName, '\\');
2059 if (p) {
2060 p++;
2061 strcpy(dcd->mask.szMask, p);
2062 }
2063 }
2064 }
2065 *(dcd->mask.prompt) = 0;
2066
2067 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2068 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2069 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2070 else if (empty)
2071 *dcd->mask.szMask = 0;
2072 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2073 DIR_FILTER), &dcd->mask, FALSE);
2074 }
2075 break;
2076
2077 case IDM_UNHIDEALL:
2078 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2079 break;
2080
2081 case IDM_HIDEALL:
2082 if (fAutoView && hwndMain)
2083 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2084 dcd->suspendview = 1;
2085 HideAll(hwnd);
2086 dcd->suspendview = 0;
2087 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2088 break;
2089
2090 case IDM_SELECTBOTH:
2091 case IDM_SELECTONE:
2092 case IDM_SELECTMORE:
2093 case IDM_SELECTNEWER:
2094 case IDM_SELECTOLDER:
2095 case IDM_SELECTBIGGER:
2096 case IDM_SELECTSMALLER:
2097 case IDM_DESELECTBOTH:
2098 case IDM_DESELECTONE:
2099 case IDM_DESELECTMORE:
2100 case IDM_DESELECTNEWER:
2101 case IDM_DESELECTOLDER:
2102 case IDM_DESELECTBIGGER:
2103 case IDM_DESELECTSMALLER:
2104 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2105 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2106 break;
2107 }
2108 case IDM_SELECTLIST:
2109 case IDM_SELECTALL:
2110 case IDM_DESELECTALL:
2111 case IDM_SELECTALLFILES:
2112 case IDM_DESELECTALLFILES:
2113 case IDM_SELECTALLDIRS:
2114 case IDM_DESELECTALLDIRS:
2115 case IDM_SELECTMASK:
2116 case IDM_DESELECTMASK:
2117 case IDM_INVERT:
2118 case IDM_SELECTCLIP:
2119 case IDM_DESELECTCLIP:
2120 {
2121 PCNRITEM pci;
2122
2123 pci = (PCNRITEM) CurrentRecord(hwnd);
2124 if ((INT) pci == -1)
2125 pci = NULL;
2126 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2127 if (pci) {
2128 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2129 pci->rc.flRecordAttr |= CRA_FILTERED;
2130 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2131 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2132 break;
2133 }
2134 }
2135 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2136 }
2137 break;
2138
2139 case IDM_RESCAN:
2140 DosEnterCritSec();
2141 dcd->stopflag++;
2142 DosExitCritSec();
2143 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2144 DosEnterCritSec();
2145 dcd->stopflag--;
2146 DosExitCritSec();
2147 }
2148 break;
2149
2150 case IDM_SHOWLNAMES:
2151 case IDM_SHOWSUBJECT:
2152 case IDM_SHOWEAS:
2153 case IDM_SHOWSIZE:
2154 case IDM_SHOWICON:
2155 case IDM_SHOWLWDATE:
2156 case IDM_SHOWLWTIME:
2157 case IDM_SHOWLADATE:
2158 case IDM_SHOWLATIME:
2159 case IDM_SHOWCRDATE:
2160 case IDM_SHOWCRTIME:
2161 case IDM_SHOWATTR:
2162 AdjustDetailsSwitches(hwnd,
2163 dcd->hwndLastMenu,
2164 SHORT1FROMMP(mp1),
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 xfree((CHAR *)mp2);
3297 return MRFROMLONG(ret);
3298 }
3299 return 0;
3300
3301 case WM_SAVEAPPLICATION:
3302 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3303
3304 SWP swp;
3305
3306 WinQueryWindowPos(dcd->hwndFrame, &swp);
3307 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3308 PrfWriteProfileData(fmprof,
3309 appname, "VDirSizePos", &swp, sizeof(swp));
3310 }
3311 break;
3312
3313 case WM_CLOSE:
3314 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3315 if (LastDir == hwnd)
3316 LastDir = (HWND) 0;
3317 if (dcd) {
3318 dcd->stopflag++;
3319 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3320 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3321 if (!dcd->hwndObject ||
3322 !PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID)) {
3323 if (dcd->hwndObject)
3324 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3325 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3326 if (dcd->hwndRestore)
3327 WinSetWindowPos(dcd->hwndRestore,
3328 HWND_TOP,
3329 0,
3330 0,
3331 0,
3332 0,
3333 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3334 FreeList(dcd->lastselection);
3335 free(dcd);
3336 DosPostEventSem(CompactSem);
3337 }
3338 }
3339 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3340 QW_PARENT));
3341 return 0;
3342
3343 case WM_DESTROY:
3344 if (DirMenu)
3345 WinDestroyWindow(DirMenu);
3346 if (DirCnrMenu)
3347 WinDestroyWindow(DirCnrMenu);
3348 if (FileMenu)
3349 WinDestroyWindow(FileMenu);
3350 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3351 EmptyCnr(hwnd);
3352 break;
3353 }
3354 if (dcd && dcd->oldproc){
3355 return dcd->oldproc(hwnd, msg, mp1, mp2);
3356 }
3357 else
3358 return PFNWPCnr(hwnd, msg, mp1, mp2);
3359}
3360
3361HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3362 ULONG flags)
3363{
3364 /* bitmapped flags:
3365 * 0x00000001 = don't close app when window closes
3366 * 0x00000002 = no frame controls
3367 */
3368
3369 HWND hwndFrame = (HWND) 0, hwndClient;
3370 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3371 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3372 USHORT id;
3373 static USHORT idinc = 0;
3374 DIRCNRDATA *dcd;
3375 static BOOL first = FALSE;
3376
3377 if (flags & 2)
3378 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3379 FCF_MINMAX | FCF_ICON));
3380 if (!idinc)
3381 idinc = (rand() % 100);
3382 if (!hwndParent)
3383 hwndParent = HWND_DESKTOP;
3384 if (ParentIsDesktop(hwndParent, hwndParent))
3385 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3386 if (!hwndMain && !first) {
3387 if (DirCnrMenu) {
3388
3389 MENUITEM mi;
3390
3391 memset(&mi, 0, sizeof(mi));
3392 WinSendMsg(DirCnrMenu,
3393 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
3394 mi.iPosition = MIT_END;
3395 mi.afStyle = MIS_TEXT;
3396 mi.id = IDM_DRIVESMENU;
3397 WinSendMsg(DirCnrMenu,
3398 MM_INSERTITEM,
3399 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3400 }
3401 first = TRUE;
3402 }
3403 if (directory) {
3404 hwndFrame = WinCreateStdWindow(hwndParent,
3405 WS_VISIBLE,
3406 &FrameFlags,
3407 WC_DIRCONTAINER,
3408 NULL,
3409 WS_VISIBLE | fwsAnimate,
3410 FM3ModHandle, DIR_FRAME, &hwndClient);
3411 if (hwndFrame && hwndClient) {
3412 id = DIR_FRAME + idinc++;
3413 if (idinc > 99)
3414 idinc = 0;
3415 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3416 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3417 if (!dcd) {
3418 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3419 hwndFrame = (HWND) 0;
3420 }
3421 else {
3422 dcd->size = sizeof(DIRCNRDATA);
3423 dcd->id = id;
3424 dcd->type = DIR_FRAME;
3425 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3426 dcd->hwndFrame = hwndFrame;
3427 dcd->hwndClient = hwndClient;
3428 dcd->hwndRestore = hwndRestore;
3429 dcd->dontclose = ((flags & 1) != 0);
3430 dcd->detailslongname = detailslongname;
3431 dcd->detailssubject = detailssubject;
3432 dcd->detailsea = detailsea;
3433 dcd->detailssize = detailssize;
3434 dcd->detailsicon = detailsicon;
3435 dcd->detailsattr = detailsattr;
3436 dcd->detailscrdate = detailscrdate;
3437 dcd->detailscrtime = detailscrtime;
3438 dcd->detailslwdate = detailslwdate;
3439 dcd->detailslwtime = detailslwtime;
3440 dcd->detailsladate = detailsladate;
3441 dcd->detailslatime = detailslatime;
3442 strcpy(dcd->directory, directory);
3443 add_udir(FALSE, directory);
3444 {
3445 PFNWP oldproc;
3446
3447 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3448 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3449 }
3450 dcd->hwndCnr = WinCreateWindow(hwndClient,
3451 WC_CONTAINER,
3452 NULL,
3453 CCS_AUTOPOSITION | CCS_MINIICONS |
3454 CCS_MINIRECORDCORE | ulCnrType |
3455 WS_VISIBLE,
3456 0,
3457 0,
3458 0,
3459 0,
3460 hwndClient,
3461 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3462 if (!dcd->hwndCnr) {
3463 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3464 IDS_WINCREATEWINDOW);
3465 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3466 free(dcd);
3467 hwndFrame = (HWND) 0;
3468 }
3469 else {
3470 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3471 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3472 (PFNWP) DirCnrWndProc);
3473 {
3474 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3475 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3476 };
3477
3478 if (!(flags & 2))
3479 ids[6] = 0;
3480 CommonCreateTextChildren(dcd->hwndClient,
3481 WC_DIRSTATUS, ids);
3482 }
3483 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3484 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3485 if (FrameFlags & FCF_TASKLIST) {
3486
3487 SWP swp, swpD;
3488 ULONG size = sizeof(swp);
3489 LONG cxScreen, cyScreen;
3490
3491 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3492 if (PrfQueryProfileData(fmprof,
3493 appname, "VDirSizePos", &swpD, &size)) {
3494 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3495 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3496 if (swp.x + swpD.cx > cxScreen)
3497 swp.x = cxScreen - swpD.cx;
3498 if (swp.y + swpD.cy > cyScreen)
3499 swp.y = cyScreen - swpD.cy;
3500 swp.cx = swpD.cx;
3501 swp.cy = swpD.cy;
3502 }
3503 WinSetWindowPos(hwndFrame,
3504 HWND_TOP,
3505 swp.x,
3506 swp.y,
3507 swp.cx,
3508 swp.cy,
3509 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3510 SWP_ACTIVATE);
3511 }
3512 }
3513 }
3514 }
3515 }
3516 return hwndFrame;
3517}
3518
3519#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3520#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3521#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.