source: trunk/dll/dircnrs.c@ 1041

Last change on this file since 1041 was 1041, checked in by Gregg Young, 17 years ago

Adds optional support for delete being move to X/Eworkplace trashcan (ticket 43)

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