source: trunk/dll/dircnrs.c@ 1366

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

Seek and scan called from the dir or drive context menu opens seek and scan and provides the path to start the search from. (Ticket 167)

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