source: trunk/dll/dircnrs.c@ 1455

Last change on this file since 1455 was 1455, checked in by Steven Levine, 16 years ago

Blink thread LEDs while worker threads are working
Drop expermental code

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