source: trunk/dll/dircnrs.c@ 1398

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

Move embeded strings to PCSZ variables or string table; Eliminate Error2 functions Runtime_Error with NULL format string returns "No data" error. Change declares from PSZ to PCSZ in functions where the variable isn't changed. Added btm as an executable file type in several additional places. Use fProtectOnly to prevent attempt to execute Dos and Win programs on "Protect only" installs in several additional places.

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