source: trunk/dll/dircnrs.c@ 1421

Last change on this file since 1421 was 1412, checked in by Steven Levine, 17 years ago

Keep more keys away from PM if extended search in progress
Increase extended search timeout to 3 seconds

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