source: branches/ticket_150/dll/dircnrs.c@ 869

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

A "first draft" of code to address ticket 150.

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