source: trunk/dll/dircnrs.c@ 989

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

Refactor fm3dll.h to create command.h; broken ini is now replaced with backup or new ini as available; more variable command line ledth changes

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