source: trunk/dll/dircnrs.c@ 1156

Last change on this file since 1156 was 1156, checked in by John Small, 17 years ago

Ticket 187: Draft 1: Functions only

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