source: trunk/dll/dircnrs.c@ 992

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

A fix for incorrectly described sorts on restored directory containers.

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