source: trunk/dll/dircnrs.c@ 953

Last change on this file since 953 was 953, checked in by Steven Levine, 18 years ago

Rework code and resources to support settings menu conditional cascade
Optimize last settings menu save/restore

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 91.4 KB
Line 
1
2/***********************************************************************
3
4 $Id: dircnrs.c 953 2008-02-16 02:15:16Z stevenhl $
5
6 Directory containers
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2008 Steven H. Levine
10
11 16 Oct 02 SHL Handle large partitions
12 01 Aug 04 SHL Rework lstrip/rstrip usage
13 23 May 05 SHL Use QWL_USER
14 24 May 05 SHL Rework Win_Error usage
15 25 May 05 SHL Use ULONGLONG and CommaFmtULL
16 26 May 05 SHL More large file formatting updates
17 05 Jun 05 SHL Use QWL_USER
18 10 Nov 05 SHL Comments
19 13 Jul 06 SHL Use Runtime_Error
20 26 Jul 06 SHL Use chop_at_crnl
21 15 Aug 06 SHL Rework warning message text
22 07 Jan 07 GKY Move error strings etc. to string file
23 30 Mar 07 GKY Remove GetPString for window class names
24 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
25 06 Apr 07 GKY Add some error checking in drag/drop
26 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checking.
27 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
28 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
29 02 Aug 07 SHL Sync with CNRITEM mods
30 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
31 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
32 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
33 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
34 10 Jan 08 SHL Sync with CfgDlgProc mods
35 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_HIDEALL:
2078 if (fAutoView && hwndMain)
2079 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2080 dcd->suspendview = 1;
2081 HideAll(hwnd);
2082 dcd->suspendview = 0;
2083 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2084 break;
2085
2086 case IDM_SELECTBOTH:
2087 case IDM_SELECTONE:
2088 case IDM_SELECTMORE:
2089 case IDM_SELECTNEWER:
2090 case IDM_SELECTOLDER:
2091 case IDM_SELECTBIGGER:
2092 case IDM_SELECTSMALLER:
2093 case IDM_DESELECTBOTH:
2094 case IDM_DESELECTONE:
2095 case IDM_DESELECTMORE:
2096 case IDM_DESELECTNEWER:
2097 case IDM_DESELECTOLDER:
2098 case IDM_DESELECTBIGGER:
2099 case IDM_DESELECTSMALLER:
2100 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2101 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2102 break;
2103 }
2104 case IDM_SELECTLIST:
2105 case IDM_SELECTALL:
2106 case IDM_DESELECTALL:
2107 case IDM_SELECTALLFILES:
2108 case IDM_DESELECTALLFILES:
2109 case IDM_SELECTALLDIRS:
2110 case IDM_DESELECTALLDIRS:
2111 case IDM_SELECTMASK:
2112 case IDM_DESELECTMASK:
2113 case IDM_INVERT:
2114 case IDM_SELECTCLIP:
2115 case IDM_DESELECTCLIP:
2116 {
2117 PCNRITEM pci;
2118
2119 pci = (PCNRITEM) CurrentRecord(hwnd);
2120 if ((INT) pci == -1)
2121 pci = NULL;
2122 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2123 if (pci) {
2124 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2125 pci->rc.flRecordAttr |= CRA_FILTERED;
2126 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2127 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2128 break;
2129 }
2130 }
2131 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2132 }
2133 break;
2134
2135 case IDM_RESCAN:
2136 DosEnterCritSec();
2137 dcd->stopflag++;
2138 DosExitCritSec();
2139 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2140 DosEnterCritSec();
2141 dcd->stopflag--;
2142 DosExitCritSec();
2143 }
2144 break;
2145
2146 case IDM_SHOWLNAMES:
2147 case IDM_SHOWSUBJECT:
2148 case IDM_SHOWEAS:
2149 case IDM_SHOWSIZE:
2150 case IDM_SHOWICON:
2151 case IDM_SHOWLWDATE:
2152 case IDM_SHOWLWTIME:
2153 case IDM_SHOWLADATE:
2154 case IDM_SHOWLATIME:
2155 case IDM_SHOWCRDATE:
2156 case IDM_SHOWCRTIME:
2157 case IDM_SHOWATTR:
2158 AdjustDetailsSwitches(hwnd,
2159 dcd->hwndLastMenu,
2160 SHORT1FROMMP(mp1),
2161 dcd->directory, NULL, dcd, FALSE);
2162 break;
2163
2164 case IDM_TREEVIEW:
2165 case IDM_ICON:
2166 case IDM_TEXT:
2167 case IDM_DETAILS:
2168 case IDM_NAME:
2169 case IDM_MINIICONS:
2170 case IDM_DETAILSTITLES:
2171 {
2172 CNRINFO cnri;
2173
2174 memset(&cnri, 0, sizeof(CNRINFO));
2175 cnri.cb = sizeof(CNRINFO);
2176 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2177 MPFROMLONG(sizeof(CNRINFO)));
2178 switch (SHORT1FROMMP(mp1)) {
2179 case IDM_TREEVIEW:
2180 if (!(cnri.flWindowAttr & CV_TREE))
2181 dcd->lastattr = cnri.flWindowAttr;
2182 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2183 CV_DETAIL | CV_NAME | CA_TREELINE));
2184 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2185 if (!dcd->firsttree)
2186 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2187 break;
2188 case IDM_ICON:
2189 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2190 CV_DETAIL | CV_NAME | CA_TREELINE));
2191 cnri.flWindowAttr |= CV_ICON;
2192 break;
2193 case IDM_NAME:
2194 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2195 CV_DETAIL | CV_NAME | CA_TREELINE));
2196 cnri.flWindowAttr |= CV_NAME;
2197 break;
2198 case IDM_TEXT:
2199 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2200 CV_DETAIL | CV_NAME | CA_TREELINE));
2201 cnri.flWindowAttr |= CV_TEXT;
2202 break;
2203 case IDM_DETAILS:
2204 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2205 CV_DETAIL | CV_NAME | CA_TREELINE));
2206 cnri.flWindowAttr |= CV_DETAIL;
2207 break;
2208 case IDM_MINIICONS:
2209 if (cnri.flWindowAttr & CV_MINI)
2210 cnri.flWindowAttr &= (~CV_MINI);
2211 else
2212 cnri.flWindowAttr |= CV_MINI;
2213 break;
2214 case IDM_DETAILSTITLES:
2215 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2216 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2217 else
2218 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2219 break;
2220 }
2221 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2222 cnri.flWindowAttr |= CV_FLOW;
2223 dcd->flWindowAttr = cnri.flWindowAttr;
2224 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2225 MPFROMLONG(CMA_FLWINDOWATTR));
2226 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2227 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2228 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2229 DIR_VIEW), dcd->flWindowAttr);
2230 }
2231 break;
2232
2233 case IDM_SAVETOLIST:
2234 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2235 SAV_FRAME, MPFROMP(&hwnd));
2236 break;
2237
2238 case IDM_SIZES:
2239 {
2240 PCNRITEM pci;
2241 CHAR path[CCHMAXPATH];
2242
2243 pci = (PCNRITEM) CurrentRecord(hwnd);
2244 if (pci && (INT) pci != -1)
2245 strcpy(path, pci->pszFileName);
2246 else
2247 strcpy(path, dcd->directory);
2248 MakeValidDir(path);
2249 WinDlgBox(HWND_DESKTOP,
2250 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2251 }
2252 break;
2253
2254 case IDM_MKDIR:
2255 {
2256 PCNRITEM pci;
2257 BOOL saved;
2258
2259 saved = fSelectedAlways;
2260 fSelectedAlways = FALSE;
2261 pci = (PCNRITEM)CurrentRecord(hwnd);
2262 // 01 Oct 07 SHL Make below selected directory or in current directory
2263 PMMkDir(dcd->hwndParent,
2264 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2265 FALSE);
2266 fSelectedAlways = saved;
2267 }
2268 break;
2269
2270 case IDM_SWITCH:
2271 if (mp2) {
2272 strcpy(dcd->previous, dcd->directory);
2273 strcpy(dcd->directory, (CHAR *) mp2);
2274 DosEnterCritSec();
2275 dcd->stopflag++;
2276 DosExitCritSec();
2277 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2278 strcpy(dcd->directory, dcd->previous);
2279 DosEnterCritSec();
2280 dcd->stopflag--;
2281 DosExitCritSec();
2282 }
2283 else if (*dcd->directory) {
2284 if (hwndMain)
2285 WinSendMsg(hwndMain,
2286 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2287 else
2288 add_udir(FALSE, dcd->directory);
2289 }
2290 }
2291 break;
2292
2293 case IDM_PARENT:
2294 {
2295 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
2296
2297 strcpy(tempname1, dcd->directory);
2298 if (tempname1[strlen(tempname1) - 1] != '\\')
2299 strcat(tempname1, "\\");
2300 strcat(tempname1, "..");
2301 DosError(FERR_DISABLEHARDERR);
2302 if (!DosQueryPathInfo(tempname1,
2303 FIL_QUERYFULLNAME,
2304 tempname2, sizeof(tempname2))) {
2305 if (stricmp(dcd->directory, tempname2)) {
2306 strcpy(dcd->previous, dcd->directory);
2307 strcpy(dcd->directory, tempname2);
2308 DosEnterCritSec();
2309 dcd->stopflag++;
2310 DosExitCritSec();
2311 if (!PostMsg(dcd->hwndObject,
2312 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2313 strcpy(dcd->directory, dcd->previous);
2314 DosEnterCritSec();
2315 dcd->stopflag--;
2316 DosExitCritSec();
2317 }
2318 else if (*dcd->directory) {
2319 if (hwndMain)
2320 WinSendMsg(hwndMain,
2321 UM_SETUSERLISTNAME,
2322 MPFROMP(dcd->directory), MPVOID);
2323 else
2324 add_udir(FALSE, dcd->directory);
2325 }
2326 }
2327 }
2328 }
2329 break;
2330
2331 case IDM_PREVIOUS:
2332 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
2333
2334 CHAR tempname[CCHMAXPATH];
2335
2336 if (IsValidDir(dcd->previous)) {
2337 strcpy(tempname, dcd->directory);
2338 strcpy(dcd->directory, dcd->previous);
2339 strcpy(dcd->previous, tempname);
2340 DosEnterCritSec();
2341 dcd->stopflag++;
2342 DosExitCritSec();
2343 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2344 strcpy(dcd->directory, dcd->previous);
2345 DosEnterCritSec();
2346 dcd->stopflag--;
2347 DosExitCritSec();
2348 }
2349 else if (*dcd->directory) {
2350 if (hwndMain)
2351 WinSendMsg(hwndMain,
2352 UM_SETUSERLISTNAME,
2353 MPFROMP(dcd->directory), MPVOID);
2354 else
2355 add_udir(FALSE, dcd->directory);
2356 }
2357 }
2358 else
2359 *dcd->previous = 0;
2360 }
2361 break;
2362
2363 case IDM_WALKDIR:
2364 {
2365 CHAR newdir[CCHMAXPATH];
2366
2367 strcpy(newdir, dcd->directory);
2368 if (!WinDlgBox(HWND_DESKTOP,
2369 dcd->hwndParent,
2370 WalkAllDlgProc,
2371 FM3ModHandle,
2372 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2373 break;
2374 if (stricmp(newdir, dcd->directory)) {
2375 strcpy(dcd->previous, dcd->directory);
2376 strcpy(dcd->directory, newdir);
2377 DosEnterCritSec();
2378 dcd->stopflag++;
2379 DosExitCritSec();
2380 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2381 strcpy(dcd->directory, dcd->previous);
2382 DosEnterCritSec();
2383 dcd->stopflag--;
2384 DosExitCritSec();
2385 }
2386 else if (*dcd->directory) {
2387 if (hwndMain)
2388 WinSendMsg(hwndMain,
2389 UM_SETUSERLISTNAME,
2390 MPFROMP(dcd->directory), MPVOID);
2391 else
2392 add_udir(FALSE, dcd->directory);
2393 }
2394 }
2395 }
2396 break;
2397
2398 case IDM_OPENICONME:
2399 OpenObject(dcd->directory, "ICON", dcd->hwndFrame);
2400 break;
2401 case IDM_OPENDETAILSME:
2402 OpenObject(dcd->directory, "DETAILS", dcd->hwndFrame);
2403 break;
2404 case IDM_OPENTREEME:
2405 OpenObject(dcd->directory, "TREE", dcd->hwndFrame);
2406 break;
2407 case IDM_OPENSETTINGSME:
2408 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2409 break;
2410
2411 case IDM_DOITYOURSELF:
2412 case IDM_UPDATE:
2413 case IDM_OPENWINDOW:
2414 case IDM_OPENSETTINGS:
2415 case IDM_OPENDEFAULT:
2416 case IDM_OPENICON:
2417 case IDM_OPENDETAILS:
2418 case IDM_OPENTREE:
2419 case IDM_OBJECT:
2420 case IDM_SHADOW:
2421 case IDM_SHADOW2:
2422 case IDM_DELETE:
2423 case IDM_PERMDELETE:
2424 case IDM_PRINT:
2425 case IDM_ATTRS:
2426 case IDM_INFO:
2427 case IDM_COPY:
2428 case IDM_MOVE:
2429 case IDM_WPSMOVE:
2430 case IDM_WPSCOPY:
2431 case IDM_WILDCOPY:
2432 case IDM_WILDMOVE:
2433 case IDM_RENAME:
2434 case IDM_COMPARE:
2435 case IDM_EAS:
2436 case IDM_SUBJECT:
2437 case IDM_VIEW:
2438 case IDM_VIEWTEXT:
2439 case IDM_VIEWBINARY:
2440 case IDM_VIEWARCHIVE:
2441 case IDM_EDIT:
2442 case IDM_EDITTEXT:
2443 case IDM_EDITBINARY:
2444 case IDM_SAVETOCLIP:
2445 case IDM_APPENDTOCLIP:
2446 case IDM_ARCHIVE:
2447 case IDM_ARCHIVEM:
2448 case IDM_EXTRACT:
2449 case IDM_MCIPLAY:
2450 case IDM_COLLECTFROMFILE:
2451 case IDM_UUDECODE:
2452 case IDM_MERGE:
2453 {
2454 LISTINFO *li;
2455 ULONG action = UM_ACTION;
2456
2457 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2458 if (li) {
2459 li->type = SHORT1FROMMP(mp1);
2460 li->hwnd = hwnd;
2461 li->list = BuildList(hwnd);
2462 switch (SHORT1FROMMP(mp1)) {
2463 case IDM_WILDMOVE:
2464 case IDM_WILDCOPY:
2465 case IDM_MOVE:
2466 case IDM_COPY:
2467 case IDM_WPSMOVE:
2468 case IDM_WPSCOPY:
2469 break;
2470 default:
2471 strcpy(li->targetpath, dcd->directory);
2472 break;
2473 }
2474 if (li->list) {
2475 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2476 if (!Collector) {
2477
2478 HWND hwndC;
2479 SWP swp;
2480
2481 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2482 !fAutoTile &&
2483 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2484 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2485 hwndC = StartCollector((fExternalCollector ||
2486 strcmp(realappname, FM3Str)) ?
2487 HWND_DESKTOP : dcd->hwndParent, 4);
2488 if (hwndC) {
2489 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2490 !fAutoTile && (!fExternalCollector &&
2491 !strcmp(realappname, FM3Str)))
2492 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2493 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2494 SWP_SHOW | SWP_ZORDER);
2495 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2496 fAutoTile && !strcmp(realappname, FM3Str))
2497 TileChildren(dcd->hwndParent, TRUE);
2498 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2499 SWP_ACTIVATE);
2500 DosSleep(100); //05 Aug 07 GKY 250
2501 }
2502 }
2503 else
2504 StartCollector(dcd->hwndParent, 4);
2505 }
2506 switch (SHORT1FROMMP(mp1)) {
2507 case IDM_APPENDTOCLIP:
2508 case IDM_SAVETOCLIP:
2509 case IDM_ARCHIVE:
2510 case IDM_ARCHIVEM:
2511 case IDM_DELETE:
2512 case IDM_PERMDELETE:
2513 case IDM_ATTRS:
2514 case IDM_PRINT:
2515 case IDM_SHADOW:
2516 case IDM_SHADOW2:
2517 case IDM_OBJECT:
2518 case IDM_VIEW:
2519 case IDM_VIEWTEXT:
2520 case IDM_VIEWBINARY:
2521 case IDM_EDIT:
2522 case IDM_EDITTEXT:
2523 case IDM_EDITBINARY:
2524 case IDM_MCIPLAY:
2525 case IDM_UPDATE:
2526 case IDM_DOITYOURSELF:
2527 case IDM_INFO:
2528 case IDM_EAS:
2529 action = UM_MASSACTION;
2530 break;
2531 }
2532 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2533 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2534 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2535 *li->targetpath = 0;
2536 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2537 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2538 FreeListInfo(li);
2539 }
2540 else if (fUnHilite)
2541 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2542 }
2543 else
2544 free(li);
2545 }
2546 }
2547 break;
2548
2549 case IDM_DRIVESMENU:
2550 if (!hwndMain)
2551 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2552 break;
2553
2554 default:
2555 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2556 return 0;
2557 else {
2558 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2559 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2560
2561 register INT x;
2562
2563 if (!cmdloaded)
2564 load_commands();
2565 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2566 if (x >= 0) {
2567 x++;
2568 RunCommand(hwnd, x);
2569 if (fUnHilite)
2570 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2571 }
2572 }
2573 }
2574 break;
2575 }
2576 }
2577 return 0;
2578
2579 case UM_FIXCNRMLE:
2580 case UM_FIXEDITNAME:
2581 return CommonCnrProc(hwnd, msg, mp1, mp2);
2582
2583 case UM_FILESMENU:
2584 {
2585 PCNRITEM pci;
2586 HWND menuHwnd = (HWND) 0;
2587
2588 pci = (PCNRITEM) CurrentRecord(hwnd);
2589 if (pci && (INT) pci != -1) {
2590 if (pci->attrFile & FILE_DIRECTORY) {
2591 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2592// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2593 }
2594 else
2595 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2596 }
2597 return MRFROMLONG(menuHwnd);
2598 }
2599
2600 case WM_CONTROL:
2601 DosError(FERR_DISABLEHARDERR);
2602 if (dcd) {
2603 switch (SHORT2FROMMP(mp1)) {
2604 case CN_COLLAPSETREE:
2605 case CN_EXPANDTREE:
2606 {
2607 PCNRITEM pci = (PCNRITEM) mp2;
2608
2609 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
2610 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
2611 struct
2612 {
2613 ULONG serial;
2614 CHAR volumelength;
2615 CHAR volumelabel[CCHMAXPATH];
2616 }
2617 volser;
2618 APIRET rc;
2619
2620 memset(&volser, 0, sizeof(volser));
2621 DosError(FERR_DISABLEHARDERR);
2622 // fixme?
2623 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2624 FSIL_VOLSER, &volser, sizeof(volser));
2625 if (rc) {
2626 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2627 GetPString(IDS_CANTFINDDIRTEXT),
2628 pci->pszFileName);
2629 DosBeep(250,100);
2630 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2631 UnFlesh(hwnd, pci);
2632 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2633 }
2634 else {
2635 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2636 !volser.serial ||
2637 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2638 volser.serial)
2639 UnFlesh(hwnd, pci);
2640 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2641 (!volser.serial ||
2642 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2643 volser.serial)) {
2644 if (Flesh(hwnd, pci) &&
2645 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2646 !dcd->suspendview && fTopDir)
2647 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2648 }
2649 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2650 }
2651 }
2652 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2653 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
2654 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2655 }
2656 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2657 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2658 }
2659 }
2660 break;
2661
2662/*
2663 case CN_PICKUP:
2664 return PickUp(hwnd,dcd->hwndObject,mp2);
2665*/
2666
2667 case CN_CONTEXTMENU:
2668 {
2669 PCNRITEM pci = (PCNRITEM) mp2;
2670
2671 if (pci) {
2672 WinSendMsg(hwnd,
2673 CM_SETRECORDEMPHASIS,
2674 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2675 MarkAll(hwnd, FALSE, FALSE, TRUE);
2676 if (pci->attrFile & FILE_DIRECTORY)
2677 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2678 else
2679 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2680 }
2681 else {
2682 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
2683 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2684 WinSendMsg(hwnd,
2685 CM_SETRECORDEMPHASIS,
2686 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2687 dcd->cnremphasized = TRUE;
2688 }
2689 }
2690 if (dcd->hwndLastMenu) {
2691 if (dcd->hwndLastMenu == DirCnrMenu) {
2692 if (dcd->flWindowAttr & CV_MINI)
2693 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2694 }
2695 if (dcd->hwndLastMenu == DirMenu)
2696 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2697 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2698 if (dcd->cnremphasized) {
2699 WinSendMsg(hwnd,
2700 CM_SETRECORDEMPHASIS,
2701 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2702 dcd->cnremphasized = TRUE;
2703 }
2704 MarkAll(hwnd, TRUE, FALSE, TRUE);
2705 }
2706 }
2707 }
2708 break;
2709
2710 case CN_DROPHELP:
2711 if (mp2) {
2712
2713 PDRAGINFO pDInfo;
2714 PCNRITEM pci;
2715 ULONG numitems;
2716 USHORT usOperation;
2717
2718 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2719 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2720 if (!DrgAccessDraginfo(pDInfo)) {
2721 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2722 GetPString(IDS_DROPERRORTEXT));
2723 }
2724 else {
2725 numitems = DrgQueryDragitemCount(pDInfo);
2726 usOperation = pDInfo->usOperation;
2727 FreeDragInfoData(hwnd, pDInfo);
2728 saymsg(MB_ENTER | MB_ICONASTERISK,
2729 hwnd,
2730 GetPString(IDS_DROPHELPHDRTEXT),
2731 GetPString(IDS_DROPHELPTEXT),
2732 numitems,
2733 &"s"[numitems == 1L],
2734 pci ? NullStr : GetPString(IDS_NOTEXT),
2735 pci ? NullStr : " ",
2736 pci ? pci->pszFileName : NullStr,
2737 pci ? " " : NullStr,
2738 GetPString((usOperation == DO_COPY) ?
2739 IDS_COPYTEXT :
2740 (usOperation == DO_LINK) ?
2741 IDS_LINKTEXT : IDS_MOVETEXT));
2742 }
2743 }
2744 return 0;
2745
2746 case CN_DRAGLEAVE:
2747 return 0;
2748
2749 case CN_DRAGAFTER:
2750 case CN_DRAGOVER:
2751 if (mp2) {
2752
2753 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2754 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2755 PCNRITEM pci;
2756 USHORT uso;
2757
2758 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2759 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2760 if (!DrgAccessDraginfo(pDInfo)) {
2761 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2762 "DrgAccessDraginfo");
2763 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2764 }
2765 if (*dcd->directory &&
2766 (driveflags[toupper(*dcd->directory) - 'A'] &
2767 DRIVE_NOTWRITEABLE)) {
2768 DrgFreeDraginfo(pDInfo);
2769 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
2770 DO_LINK); /* (compare) only */
2771 }
2772 if (pci) {
2773 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2774 DrgFreeDraginfo(pDInfo);
2775 return (MRFROM2SHORT(DOR_NODROP, 0));
2776 }
2777 uso = pDInfo->usOperation;
2778 if (uso == DO_DEFAULT)
2779 uso = fCopyDefault ? DO_COPY : DO_MOVE;
2780 if (!(pci->attrFile & FILE_DIRECTORY)) {
2781 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2782 DrgFreeDraginfo(pDInfo);
2783 return MRFROM2SHORT(DOR_NODROP, 0);
2784 }
2785 if (uso != DO_LINK &&
2786 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2787 DRIVE_NOTWRITEABLE)) {
2788
2789 ARC_TYPE *info = NULL;
2790
2791 if (!fQuickArcFind &&
2792 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2793 DRIVE_SLOW))
2794 info = find_type(pci->pszFileName, NULL);
2795 else
2796 info = quick_find_type(pci->pszFileName, NULL);
2797 if (!info || ((uso == DO_MOVE && !info->move) ||
2798 (uso == DO_COPY && !info->create))) {
2799 DrgFreeDraginfo(pDInfo);
2800 return MRFROM2SHORT(DOR_NODROP, 0);
2801 }
2802 }
2803 }
2804 }
2805
2806 /* Access DRAGITEM index to DRAGITEM
2807 * Check valid rendering mechanisms and data
2808 */
2809 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
2810 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL) ||
2811 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
2812 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) {
2813 DrgFreeDraginfo(pDInfo);
2814 if (driveflags[toupper(*dcd->directory) - 'A'] &
2815 DRIVE_NOTWRITEABLE)
2816 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2817 if (toupper(*dcd->directory) < 'C')
2818 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2819 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2820 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2821 }
2822 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2823 }
2824 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
2825
2826 case CN_INITDRAG:
2827 {
2828 BOOL wasemphasized = FALSE;
2829 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2830 PCNRITEM pci;
2831
2832 if (pcd) {
2833 pci = (PCNRITEM) pcd->pRecord;
2834 if (pci) {
2835 if ((INT) pci == -1)
2836 pci = NULL;
2837 else if (pci->rc.flRecordAttr & CRA_SELECTED)
2838 wasemphasized = TRUE;
2839 }
2840 else if (!*dcd->directory) {
2841 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2842 break;
2843 }
2844 else if (IsRoot(dcd->directory)) {
2845 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
2846 GetPString(IDS_CANTDRAGROOTDIR));
2847 break;
2848 }
2849 if (hwndStatus2) {
2850 if (pci)
2851 WinSetWindowText(hwndStatus2,
2852 GetPString(IDS_DRAGFILEOBJTEXT));
2853 else
2854 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGDIRTEXT));
2855 }
2856 if (DoFileDrag(hwnd,
2857 dcd->hwndObject,
2858 mp2,
2859 NULL,
2860 pci ? NULL : dcd->directory,
2861 pci ? TRUE : FALSE)) {
2862 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
2863 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2864 }
2865 }
2866 if (hwndStatus2) {
2867 WinSetFocus(HWND_DESKTOP, hwnd);
2868 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2869 }
2870 }
2871 }
2872 return 0;
2873
2874 case CN_DROP:
2875 if (mp2) {
2876
2877 LISTINFO *li;
2878 ULONG action = UM_ACTION;
2879
2880 // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
2881 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
2882 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2883 if (li) {
2884 if (li->list && li->list[0] && IsRoot(li->list[0]))
2885 li->type = DO_LINK;
2886 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2887
2888 CHECKLIST cl;
2889
2890 memset(&cl, 0, sizeof(cl));
2891 cl.size = sizeof(cl);
2892 cl.flags = li->type;
2893 cl.list = li->list;
2894 cl.cmd = li->type;
2895 cl.prompt = li->targetpath;
2896 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2897 DropListProc, FM3ModHandle,
2898 DND_FRAME, MPFROMP(&cl));
2899 if (li->type == DID_ERROR)
2900 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2901 "Drag & Drop Dialog");
2902 if (!li->type) {
2903 FreeListInfo(li);
2904 return 0;
2905 }
2906 li->list = cl.list;
2907 if (!li->list || !li->list[0]) {
2908 FreeListInfo(li);
2909 return 0;
2910 }
2911 }
2912 switch (li->type) {
2913 case DND_LAUNCH:
2914 strcat(li->targetpath, " %a");
2915 ExecOnList(dcd->hwndParent, li->targetpath,
2916 PROMPT | WINDOWED, NULL, li->list, NULL,
2917 pszSrcFile, __LINE__);
2918 FreeList(li->list);
2919 li->list = NULL;
2920 break;
2921 case DO_LINK:
2922 if (fLinkSetsIcon) {
2923 li->type = IDM_SETICON;
2924 action = UM_MASSACTION;
2925 }
2926 else
2927 li->type = IDM_COMPARE;
2928 break;
2929 case DND_EXTRACT:
2930 if (*li->targetpath && !IsFile(li->targetpath))
2931 li->type = IDM_EXTRACT;
2932 break;
2933 case DND_MOVE:
2934 li->type = IDM_MOVE;
2935 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2936 action = UM_MASSACTION;
2937 li->type = IDM_ARCHIVEM;
2938 }
2939 break;
2940 case DND_WILDMOVE:
2941 li->type = IDM_WILDMOVE;
2942 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2943 action = UM_MASSACTION;
2944 li->type = IDM_ARCHIVEM;
2945 }
2946 break;
2947 case DND_OBJECT:
2948 li->type = IDM_OBJECT;
2949 action = UM_MASSACTION;
2950 break;
2951 case DND_SHADOW:
2952 li->type = IDM_SHADOW;
2953 action = UM_MASSACTION;
2954 break;
2955 case DND_COMPARE:
2956 li->type = IDM_COMPARE;
2957 break;
2958 case DND_SETICON:
2959 action = UM_MASSACTION;
2960 li->type = IDM_SETICON;
2961 break;
2962 case DND_COPY:
2963 li->type = IDM_COPY;
2964 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2965 action = UM_MASSACTION;
2966 li->type = IDM_ARCHIVE;
2967 }
2968 break;
2969 case DND_WILDCOPY:
2970 li->type = IDM_WILDCOPY;
2971 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2972 action = UM_MASSACTION;
2973 li->type = IDM_ARCHIVE;
2974 }
2975 break;
2976 default:
2977 if (*li->arcname && li->info) {
2978 action = UM_MASSACTION;
2979 li->type =
2980 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2981 }
2982 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2983 action = UM_MASSACTION;
2984 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2985 }
2986 else
2987 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2988 break;
2989 }
2990 if (!li->list || !li->list[0])
2991 FreeListInfo(li);
2992 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2993 FreeListInfo(li);
2994 else {
2995
2996 USHORT usop = 0;
2997
2998 switch (li->type) {
2999 case IDM_COPY:
3000 case IDM_WILDCOPY:
3001 usop = DO_COPY;
3002 break;
3003 case IDM_MOVE:
3004 case IDM_WILDMOVE:
3005 case IDM_ARCHIVEM:
3006 usop = DO_MOVE;
3007 break;
3008 }
3009 if (usop)
3010 return MRFROM2SHORT(DOR_DROP, usop);
3011 }
3012 }
3013 }
3014 return 0;
3015
3016 case CN_ENDEDIT:
3017 case CN_BEGINEDIT:
3018 {
3019 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3020 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3021
3022 if (pfi || pci) {
3023
3024 MRESULT mre;
3025
3026 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3027 if (mre != (MRESULT) - 1)
3028 return mre;
3029 }
3030 else if (!pfi && !pci)
3031 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3032 }
3033 return 0;
3034
3035 case CN_REALLOCPSZ:
3036 {
3037 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3038 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3039 HWND hwndMLE;
3040 static CHAR szData[CCHMAXPATH];
3041 CHAR testname[CCHMAXPATH];
3042
3043 if (!pci && !pfi) {
3044 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3045 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
3046 chop_at_crnl(szData);
3047 bstrip(szData);
3048 if (*szData) {
3049 if (!DosQueryPathInfo(szData,
3050 FIL_QUERYFULLNAME,
3051 testname, sizeof(testname))) {
3052 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3053 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3054 }
3055 }
3056 }
3057 }
3058 else {
3059
3060 MRESULT mre;
3061
3062 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3063 if (mre != (MRESULT) - 1)
3064 return mre;
3065 }
3066 }
3067 return 0;
3068
3069 case CN_EMPHASIS:
3070 if (!mp2)
3071 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3072 else {
3073 PNOTIFYRECORDEMPHASIS pre = mp2;
3074 PCNRITEM pci;
3075 CHAR s[CCHMAXPATHCOMP + 91], tb[81], tf[81];
3076
3077 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
3078 if (!pci) {
3079 if (hwndStatus2)
3080 WinSetWindowText(hwndStatus2, NullStr);
3081 if (fMoreButtons) {
3082 WinSetWindowText(hwndName, NullStr);
3083 WinSetWindowText(hwndDate, NullStr);
3084 WinSetWindowText(hwndAttr, NullStr);
3085 }
3086 if (hwndMain)
3087 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3088 break;
3089 }
3090 if (pre->fEmphasisMask & CRA_SELECTED) {
3091 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3092 dcd->selectedbytes += (pci->cbFile + pci->easize);
3093 dcd->selectedfiles++;
3094 }
3095 else if (dcd->selectedfiles) {
3096 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3097 dcd->selectedfiles--;
3098 }
3099 if (!dcd->suspendview) {
3100 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3101 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3102 sprintf(s, "%s / %s", tf, tb);
3103 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3104 }
3105 }
3106 if (!dcd->suspendview && hwndMain &&
3107 (pre->fEmphasisMask & CRA_CURSORED) &&
3108 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3109 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3110 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
3111 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3112 else
3113 WinSendMsg(hwndMain,
3114 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
3115 }
3116 if (!dcd->suspendview &&
3117 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3118 if (pre->fEmphasisMask & CRA_CURSORED) {
3119 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3120 if (fSplitStatus && hwndStatus2) {
3121 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3122 if (!fMoreButtons) {
3123 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
3124 tb, pci->date.year,
3125 pci->date.month, pci->date.day, pci->time.hours,
3126 pci->time.minutes, pci->time.seconds,
3127 pci->pszDispAttr, pci->pszFileName);
3128 }
3129 else {
3130 *tf = 0;
3131 if (pci->cbFile + pci->easize > 1024) {
3132 CommaFmtULL(tf, sizeof(tf),
3133 pci->cbFile + pci->easize, 'K');
3134 }
3135 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3136 tb,
3137 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3138 }
3139 WinSetWindowText(hwndStatus2, s);
3140 }
3141 if (fMoreButtons) {
3142 WinSetWindowText(hwndName, pci->pszFileName);
3143 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
3144 pci->date.year, pci->date.month,
3145 pci->date.day, pci->time.hours, pci->time.minutes,
3146 pci->time.seconds);
3147 WinSetWindowText(hwndDate, s);
3148 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3149 }
3150 }
3151 }
3152 }
3153 }
3154 break;
3155
3156 case CN_ENTER:
3157 if (mp2) {
3158
3159 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3160 FILEFINDBUF3 ffb;
3161 HDIR hDir = HDIR_CREATE;
3162 ULONG nm = 1;
3163 APIRET status = 0;
3164
3165 SetShiftState();
3166 if (pci) {
3167 if (pci->rc.flRecordAttr & CRA_INUSE)
3168 break;
3169 DosError(FERR_DISABLEHARDERR);
3170 status = DosFindFirst(pci->pszFileName,
3171 &hDir,
3172 FILE_NORMAL | FILE_DIRECTORY |
3173 FILE_ARCHIVED | FILE_READONLY |
3174 FILE_HIDDEN | FILE_SYSTEM,
3175 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
3176 priority_bumped();
3177 if (!status) {
3178 DosFindClose(hDir);
3179 if (ffb.attrFile & FILE_DIRECTORY) {
3180 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3181 PostMsg(hwnd,
3182 WM_COMMAND,
3183 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3184 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3185 (KC_CTRL | KC_SHIFT))
3186 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
3187 else if (shiftstate & KC_CTRL)
3188 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
3189 else if (shiftstate & KC_SHIFT) {
3190
3191 HWND hwndDir;
3192
3193 hwndDir = OpenDirCnr((HWND) 0,
3194 dcd->hwndParent,
3195 dcd->hwndFrame,
3196 FALSE, pci->pszFileName);
3197 if (hwndDir) {
3198 if (fMinOnOpen)
3199 WinSetWindowPos(dcd->hwndFrame,
3200 HWND_BOTTOM,
3201 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3202 if (fAutoTile)
3203 TileChildren(dcd->hwndParent, TRUE);
3204 WinSetWindowPos(hwndDir,
3205 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3206 }
3207 }
3208 else {
3209 strcpy(dcd->previous, dcd->directory);
3210 strcpy(dcd->directory, pci->pszFileName);
3211 DosEnterCritSec();
3212 dcd->stopflag++;
3213 DosExitCritSec();
3214 if (!PostMsg(dcd->hwndObject,
3215 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
3216 DosEnterCritSec();
3217 dcd->stopflag--;
3218 DosExitCritSec();
3219 }
3220 else if (*dcd->directory) {
3221 if (hwndMain)
3222 WinSendMsg(hwndMain,
3223 UM_SETUSERLISTNAME,
3224 MPFROMP(dcd->directory), MPVOID);
3225 else
3226 add_udir(FALSE, dcd->directory);
3227 }
3228 }
3229 }
3230 else {
3231
3232 SWP swp;
3233
3234 WinQueryWindowPos(dcd->hwndFrame, &swp);
3235 WinSendMsg(hwnd,
3236 CM_SETRECORDEMPHASIS,
3237 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3238 DefaultViewKeys(hwnd,
3239 dcd->hwndFrame,
3240 dcd->hwndParent, &swp, pci->pszFileName);
3241 WinSendMsg(hwnd,
3242 CM_SETRECORDEMPHASIS,
3243 MPFROMP(pci),
3244 MPFROM2SHORT(FALSE,
3245 CRA_INUSE |
3246 ((fUnHilite) ? CRA_SELECTED : 0)));
3247 }
3248 }
3249 else {
3250 if (!*dcd->directory || IsValidDir(dcd->directory)) {
3251 NotifyError(pci->pszFileName, status);
3252 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
3253 if (hwndStatus)
3254 WinSetWindowText(hwndStatus,
3255 GetPString(IDS_RESCANSUGGESTEDTEXT));
3256 }
3257 else {
3258 DosEnterCritSec();
3259 dcd->stopflag++;
3260 DosExitCritSec();
3261 if (!PostMsg(dcd->hwndObject,
3262 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3263 DosEnterCritSec();
3264 dcd->stopflag--;
3265 DosExitCritSec();
3266 }
3267 else if (*dcd->directory) {
3268 if (hwndMain)
3269 WinSendMsg(hwndMain,
3270 UM_SETUSERLISTNAME,
3271 MPFROMP(dcd->directory), MPVOID);
3272 else
3273 add_udir(FALSE, dcd->directory);
3274 }
3275 }
3276 }
3277 }
3278 else if (*dcd->directory)
3279 OpenObject(dcd->directory, Default, hwnd);
3280 } // CN_ENTER
3281 break;
3282 } // switch mp1
3283 break;
3284 } // if dcd
3285 return 0;
3286
3287 case UM_LOADFILE:
3288 if (dcd && mp2) {
3289
3290 HWND ret = StartMLEEditor(dcd->hwndParent,
3291 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
3292 if (mp2)
3293 free((CHAR *)mp2);
3294 return MRFROMLONG(ret);
3295 }
3296 return 0;
3297
3298 case WM_SAVEAPPLICATION:
3299 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3300
3301 SWP swp;
3302
3303 WinQueryWindowPos(dcd->hwndFrame, &swp);
3304 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3305 PrfWriteProfileData(fmprof,
3306 appname, "VDirSizePos", &swp, sizeof(swp));
3307 }
3308 break;
3309
3310 case WM_CLOSE:
3311 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3312 if (LastDir == hwnd)
3313 LastDir = (HWND) 0;
3314 if (dcd) {
3315 dcd->stopflag++;
3316 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3317 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3318 if (!dcd->hwndObject ||
3319 !PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID)) {
3320 if (dcd->hwndObject)
3321 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3322 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3323 if (dcd->hwndRestore)
3324 WinSetWindowPos(dcd->hwndRestore,
3325 HWND_TOP,
3326 0,
3327 0,
3328 0,
3329 0,
3330 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3331 FreeList(dcd->lastselection);
3332 free(dcd);
3333 DosPostEventSem(CompactSem);
3334 }
3335 }
3336 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3337 QW_PARENT));
3338 return 0;
3339
3340 case WM_DESTROY:
3341 if (DirMenu)
3342 WinDestroyWindow(DirMenu);
3343 if (DirCnrMenu)
3344 WinDestroyWindow(DirCnrMenu);
3345 if (FileMenu)
3346 WinDestroyWindow(FileMenu);
3347 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3348 EmptyCnr(hwnd);
3349 break;
3350 }
3351 if (dcd && dcd->oldproc){
3352 return dcd->oldproc(hwnd, msg, mp1, mp2);
3353 }
3354 else
3355 return PFNWPCnr(hwnd, msg, mp1, mp2);
3356}
3357
3358HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3359 ULONG flags)
3360{
3361 /* bitmapped flags:
3362 * 0x00000001 = don't close app when window closes
3363 * 0x00000002 = no frame controls
3364 */
3365
3366 HWND hwndFrame = (HWND) 0, hwndClient;
3367 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3368 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3369 USHORT id;
3370 static USHORT idinc = 0;
3371 DIRCNRDATA *dcd;
3372 static BOOL first = FALSE;
3373
3374 if (flags & 2)
3375 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3376 FCF_MINMAX | FCF_ICON));
3377 if (!idinc)
3378 idinc = (rand() % 100);
3379 if (!hwndParent)
3380 hwndParent = HWND_DESKTOP;
3381 if (ParentIsDesktop(hwndParent, hwndParent))
3382 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3383 if (!hwndMain && !first) {
3384 if (DirCnrMenu) {
3385
3386 MENUITEM mi;
3387
3388 memset(&mi, 0, sizeof(mi));
3389 WinSendMsg(DirCnrMenu,
3390 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
3391 mi.iPosition = MIT_END;
3392 mi.afStyle = MIS_TEXT;
3393 mi.id = IDM_DRIVESMENU;
3394 WinSendMsg(DirCnrMenu,
3395 MM_INSERTITEM,
3396 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3397 }
3398 first = TRUE;
3399 }
3400 if (directory) {
3401 hwndFrame = WinCreateStdWindow(hwndParent,
3402 WS_VISIBLE,
3403 &FrameFlags,
3404 WC_DIRCONTAINER,
3405 NULL,
3406 WS_VISIBLE | fwsAnimate,
3407 FM3ModHandle, DIR_FRAME, &hwndClient);
3408 if (hwndFrame && hwndClient) {
3409 id = DIR_FRAME + idinc++;
3410 if (idinc > 99)
3411 idinc = 0;
3412 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3413 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3414 if (!dcd) {
3415 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3416 hwndFrame = (HWND) 0;
3417 }
3418 else {
3419 dcd->size = sizeof(DIRCNRDATA);
3420 dcd->id = id;
3421 dcd->type = DIR_FRAME;
3422 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3423 dcd->hwndFrame = hwndFrame;
3424 dcd->hwndClient = hwndClient;
3425 dcd->hwndRestore = hwndRestore;
3426 dcd->dontclose = ((flags & 1) != 0);
3427 dcd->detailslongname = detailslongname;
3428 dcd->detailssubject = detailssubject;
3429 dcd->detailsea = detailsea;
3430 dcd->detailssize = detailssize;
3431 dcd->detailsicon = detailsicon;
3432 dcd->detailsattr = detailsattr;
3433 dcd->detailscrdate = detailscrdate;
3434 dcd->detailscrtime = detailscrtime;
3435 dcd->detailslwdate = detailslwdate;
3436 dcd->detailslwtime = detailslwtime;
3437 dcd->detailsladate = detailsladate;
3438 dcd->detailslatime = detailslatime;
3439 strcpy(dcd->directory, directory);
3440 add_udir(FALSE, directory);
3441 {
3442 PFNWP oldproc;
3443
3444 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3445 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3446 }
3447 dcd->hwndCnr = WinCreateWindow(hwndClient,
3448 WC_CONTAINER,
3449 NULL,
3450 CCS_AUTOPOSITION | CCS_MINIICONS |
3451 CCS_MINIRECORDCORE | ulCnrType |
3452 WS_VISIBLE,
3453 0,
3454 0,
3455 0,
3456 0,
3457 hwndClient,
3458 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3459 if (!dcd->hwndCnr) {
3460 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3461 IDS_WINCREATEWINDOW);
3462 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3463 free(dcd);
3464 hwndFrame = (HWND) 0;
3465 }
3466 else {
3467 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3468 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3469 (PFNWP) DirCnrWndProc);
3470 {
3471 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3472 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3473 };
3474
3475 if (!(flags & 2))
3476 ids[6] = 0;
3477 CommonCreateTextChildren(dcd->hwndClient,
3478 WC_DIRSTATUS, ids);
3479 }
3480 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3481 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3482 if (FrameFlags & FCF_TASKLIST) {
3483
3484 SWP swp, swpD;
3485 ULONG size = sizeof(swp);
3486 LONG cxScreen, cyScreen;
3487
3488 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3489 if (PrfQueryProfileData(fmprof,
3490 appname, "VDirSizePos", &swpD, &size)) {
3491 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3492 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3493 if (swp.x + swpD.cx > cxScreen)
3494 swp.x = cxScreen - swpD.cx;
3495 if (swp.y + swpD.cy > cyScreen)
3496 swp.y = cyScreen - swpD.cy;
3497 swp.cx = swpD.cx;
3498 swp.cy = swpD.cy;
3499 }
3500 WinSetWindowPos(hwndFrame,
3501 HWND_TOP,
3502 swp.x,
3503 swp.y,
3504 swp.cx,
3505 swp.cy,
3506 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3507 SWP_ACTIVATE);
3508 }
3509 }
3510 }
3511 }
3512 }
3513 return hwndFrame;
3514}
3515
3516#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3517#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3518#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.