source: trunk/dll/dircnrs.c@ 907

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

Avoid out of memory traps in Compare Directories
Rework Compare Directories progress display for 2 second update rate
Start refactoring to reduce dependence on fm3dll.h
Add timer services (IsITimerExpired etc.)

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