source: trunk/dll/dircnrs.c@ 1438

Last change on this file since 1438 was 1438, checked in by Gregg Young, 16 years ago

Improved drivebar changes; Added AddBackslashToPath() to remove repeatative code. replaced "
" with PCSZ variable; ANY_OBJ added the DosAlloc... (experimental)

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