source: trunk/dll/dircnrs.c@ 1357

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

Fixed DROPHELP issues Tickets 320 & 324

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 99.7 KB
Line 
1
2/***********************************************************************
3
4 $Id: dircnrs.c 1357 2008-12-26 23:57:18Z 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 PostMsg(Collector, WM_COMMAND,
2151 MPFROM2SHORT(IDM_GREP, 0), MPVOID);
2152 else
2153 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2154 break;
2155
2156 case IDM_COLLECTOR:
2157 DosSleep(32); //05 Aug 07 GKY 64
2158 {
2159 CHAR **list;
2160
2161 list = BuildList(hwnd);
2162 if (list) {
2163 if (Collector) {
2164 if (!PostMsg(Collector,
2165 WM_COMMAND,
2166 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2167 FreeList(list);
2168 else if (fUnHilite)
2169 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2170 }
2171 else
2172 FreeList(list);
2173 }
2174 }
2175 break;
2176
2177 case IDM_UNDELETE:
2178 {
2179 PCNRITEM pci;
2180 CHAR path[CCHMAXPATH];
2181 HOBJECT hObject;
2182 HWND hwndDesktop;
2183
2184 hObject = WinQueryObject("<XWP_TRASHCAN>");
2185 if (hObject != NULLHANDLE && fTrashCan) {
2186 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
2187 WinSetFocus(HWND_DESKTOP, hwndDesktop);
2188 WinOpenObject(hObject, 0, TRUE);
2189 }
2190 else {
2191 pci = (PCNRITEM) CurrentRecord(hwnd);
2192 if (pci && (INT) pci != -1) {
2193 strcpy(path, pci->pszFileName);
2194 MakeValidDir(path);
2195 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2196 UNDEL_FRAME, MPFROMP(path));
2197 }
2198 }
2199 }
2200 break;
2201
2202 case IDM_UNDELETESPEC:
2203 {
2204 HOBJECT hObject;
2205 HWND hwndDesktop;
2206
2207 hObject = WinQueryObject("<XWP_TRASHCAN>");
2208 if (hObject != NULLHANDLE && fTrashCan) {
2209 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
2210 WinSetFocus(HWND_DESKTOP, hwndDesktop);
2211 WinOpenObject(hObject, 0, TRUE);
2212 }
2213 else
2214 WinDlgBox(HWND_DESKTOP,
2215 hwnd,
2216 UndeleteDlgProc,
2217 FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
2218 }
2219 break;
2220
2221 case IDM_RESORT:
2222// WinSendMsg(hwnd,
2223// CM_SORTRECORD,
2224// MPFROMP(SortDirCnr),
2225// MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
2226 WinSendMsg(hwnd,
2227 CM_SORTRECORD,
2228 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
2229 break;
2230
2231 case IDM_FILTER:
2232 {
2233 BOOL empty = FALSE;
2234 PCNRITEM pci;
2235 CHAR *p;
2236
2237 if (!*dcd->mask.szMask) {
2238 empty = TRUE;
2239 pci = (PCNRITEM) CurrentRecord(hwnd);
2240 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
2241 p = strrchr(pci->pszFileName, '\\');
2242 if (p) {
2243 p++;
2244 strcpy(dcd->mask.szMask, p);
2245 }
2246 }
2247 }
2248 *(dcd->mask.prompt) = 0;
2249
2250 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2251 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2252 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2253 else if (empty)
2254 *dcd->mask.szMask = 0;
2255 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2256 DIR_FILTER), &dcd->mask, FALSE);
2257 }
2258 break;
2259
2260 case IDM_UNHIDEALL:
2261 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2262 break;
2263
2264 case IDM_HIDEALL:
2265 if (fAutoView && hwndMain)
2266 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2267 dcd->suspendview = 1;
2268 HideAll(hwnd);
2269 dcd->suspendview = 0;
2270 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2271 break;
2272
2273 case IDM_SELECTBOTH:
2274 case IDM_SELECTONE:
2275 case IDM_SELECTMORE:
2276 case IDM_SELECTNEWER:
2277 case IDM_SELECTOLDER:
2278 case IDM_SELECTBIGGER:
2279 case IDM_SELECTSMALLER:
2280 case IDM_DESELECTBOTH:
2281 case IDM_DESELECTONE:
2282 case IDM_DESELECTMORE:
2283 case IDM_DESELECTNEWER:
2284 case IDM_DESELECTOLDER:
2285 case IDM_DESELECTBIGGER:
2286 case IDM_DESELECTSMALLER:
2287 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2288 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2289 break;
2290 }
2291 case IDM_SELECTLIST:
2292 case IDM_SELECTALL:
2293 case IDM_DESELECTALL:
2294 case IDM_SELECTALLFILES:
2295 case IDM_DESELECTALLFILES:
2296 case IDM_SELECTALLDIRS:
2297 case IDM_DESELECTALLDIRS:
2298 case IDM_SELECTMASK:
2299 case IDM_DESELECTMASK:
2300 case IDM_INVERT:
2301 case IDM_SELECTCLIP:
2302 case IDM_DESELECTCLIP:
2303 {
2304 PCNRITEM pci;
2305
2306 pci = (PCNRITEM) CurrentRecord(hwnd);
2307 if ((INT) pci == -1)
2308 pci = NULL;
2309 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2310 if (pci) {
2311 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2312 pci->rc.flRecordAttr |= CRA_FILTERED;
2313 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2314 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2315 break;
2316 }
2317 }
2318 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2319 }
2320 break;
2321
2322 case IDM_RESCAN:
2323 //DosEnterCritSec(); //GKY 11-27-08
2324 dcd->stopflag++;
2325 //DosExitCritSec();
2326 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2327 //DosEnterCritSec(); //GKY 11-27-08
2328 dcd->stopflag--;
2329 //DosExitCritSec();
2330 }
2331 break;
2332
2333 case IDM_SHOWLNAMES:
2334 case IDM_SHOWSUBJECT:
2335 case IDM_SHOWEAS:
2336 case IDM_SHOWSIZE:
2337 case IDM_SHOWICON:
2338 case IDM_SHOWLWDATE:
2339 case IDM_SHOWLWTIME:
2340 case IDM_SHOWLADATE:
2341 case IDM_SHOWLATIME:
2342 case IDM_SHOWCRDATE:
2343 case IDM_SHOWCRTIME:
2344 case IDM_SHOWATTR:
2345 AdjustDetailsSwitches(hwnd,
2346 dcd->hwndLastMenu,
2347 SHORT1FROMMP(mp1),
2348 dcd->directory, NULL, &dcd->ds, FALSE);
2349 break;
2350
2351 case IDM_TREEVIEW:
2352 case IDM_ICON:
2353 case IDM_TEXT:
2354 case IDM_DETAILS:
2355 case IDM_NAME:
2356 case IDM_MINIICONS:
2357 case IDM_DETAILSTITLES:
2358 {
2359 CNRINFO cnri;
2360
2361 memset(&cnri, 0, sizeof(CNRINFO));
2362 cnri.cb = sizeof(CNRINFO);
2363 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2364 MPFROMLONG(sizeof(CNRINFO)));
2365 switch (SHORT1FROMMP(mp1)) {
2366 case IDM_TREEVIEW:
2367 if (!(cnri.flWindowAttr & CV_TREE))
2368 dcd->lastattr = cnri.flWindowAttr;
2369 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2370 CV_DETAIL | CV_NAME | CA_TREELINE));
2371 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2372 if (!dcd->firsttree)
2373 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2374 break;
2375 case IDM_ICON:
2376 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2377 CV_DETAIL | CV_NAME | CA_TREELINE));
2378 cnri.flWindowAttr |= CV_ICON;
2379 break;
2380 case IDM_NAME:
2381 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2382 CV_DETAIL | CV_NAME | CA_TREELINE));
2383 cnri.flWindowAttr |= CV_NAME;
2384 break;
2385 case IDM_TEXT:
2386 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2387 CV_DETAIL | CV_NAME | CA_TREELINE));
2388 cnri.flWindowAttr |= CV_TEXT;
2389 break;
2390 case IDM_DETAILS:
2391 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2392 CV_DETAIL | CV_NAME | CA_TREELINE));
2393 cnri.flWindowAttr |= CV_DETAIL;
2394 break;
2395 case IDM_MINIICONS:
2396 if (cnri.flWindowAttr & CV_MINI)
2397 cnri.flWindowAttr &= (~CV_MINI);
2398 else
2399 cnri.flWindowAttr |= CV_MINI;
2400 break;
2401 case IDM_DETAILSTITLES:
2402 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2403 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2404 else
2405 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2406 break;
2407 }
2408 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2409 cnri.flWindowAttr |= CV_FLOW;
2410 dcd->flWindowAttr = cnri.flWindowAttr;
2411 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2412 MPFROMLONG(CMA_FLWINDOWATTR));
2413 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2414 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2415 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2416 DIR_VIEW), dcd->flWindowAttr);
2417 }
2418 break;
2419
2420 case IDM_SAVETOLIST:
2421 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2422 SAV_FRAME, MPFROMP(&hwnd));
2423 break;
2424
2425 case IDM_SIZES:
2426 {
2427 PCNRITEM pci;
2428 CHAR path[CCHMAXPATH];
2429
2430 pci = (PCNRITEM) CurrentRecord(hwnd);
2431 if (pci && (INT) pci != -1)
2432 strcpy(path, pci->pszFileName);
2433 else
2434 strcpy(path, dcd->directory);
2435 MakeValidDir(path);
2436 WinDlgBox(HWND_DESKTOP,
2437 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2438 }
2439 break;
2440
2441 case IDM_MKDIR:
2442 {
2443 PCNRITEM pci;
2444 BOOL saved;
2445
2446 saved = fSelectedAlways;
2447 fSelectedAlways = FALSE;
2448 pci = (PCNRITEM)CurrentRecord(hwnd);
2449 // 01 Oct 07 SHL Make below selected directory or in current directory
2450 PMMkDir(dcd->hwndParent,
2451 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2452 FALSE);
2453 fSelectedAlways = saved;
2454 }
2455 break;
2456
2457 case IDM_SWITCH:
2458 if (mp2) {
2459 strcpy(dcd->previous, dcd->directory);
2460 strcpy(dcd->directory, (CHAR *)mp2);
2461 //DosEnterCritSec(); // GKY 11-27-08
2462 dcd->stopflag++;
2463 //DosExitCritSec();
2464 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2465 strcpy(dcd->directory, dcd->previous);
2466 //DosEnterCritSec(); // GKY 11-27-08
2467 dcd->stopflag--;
2468 //DosExitCritSec();
2469 }
2470 else if (*dcd->directory) {
2471 if (hwndMain)
2472 WinSendMsg(hwndMain,
2473 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2474 else
2475 add_udir(FALSE, dcd->directory);
2476 }
2477 }
2478 break;
2479
2480 case IDM_PARENT:
2481 {
2482 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
2483
2484 strcpy(tempname1, dcd->directory);
2485 if (tempname1[strlen(tempname1) - 1] != '\\')
2486 strcat(tempname1, "\\");
2487 strcat(tempname1, "..");
2488 DosError(FERR_DISABLEHARDERR);
2489 if (!DosQueryPathInfo(tempname1,
2490 FIL_QUERYFULLNAME,
2491 tempname2, sizeof(tempname2))) {
2492 if (stricmp(dcd->directory, tempname2)) {
2493 strcpy(dcd->previous, dcd->directory);
2494 strcpy(dcd->directory, tempname2);
2495 //DosEnterCritSec(); // GKY 11-27-08
2496 dcd->stopflag++;
2497 //DosExitCritSec();
2498 if (!PostMsg(dcd->hwndObject,
2499 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2500 strcpy(dcd->directory, dcd->previous);
2501 //DosEnterCritSec();// GKY 11-27-08
2502 dcd->stopflag--;
2503 //DosExitCritSec();
2504 }
2505 else if (*dcd->directory) {
2506 if (hwndMain)
2507 WinSendMsg(hwndMain,
2508 UM_SETUSERLISTNAME,
2509 MPFROMP(dcd->directory), MPVOID);
2510 else
2511 add_udir(FALSE, dcd->directory);
2512 }
2513 }
2514 }
2515 }
2516 break;
2517
2518 case IDM_PREVIOUS:
2519 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
2520
2521 CHAR tempname[CCHMAXPATH];
2522
2523 if (IsValidDir(dcd->previous)) {
2524 strcpy(tempname, dcd->directory);
2525 strcpy(dcd->directory, dcd->previous);
2526 strcpy(dcd->previous, tempname);
2527 //DosEnterCritSec(); // GKY 11-27-08
2528 dcd->stopflag++;
2529 //DosExitCritSec();
2530 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2531 strcpy(dcd->directory, dcd->previous);
2532 //DosEnterCritSec(); // GKY 11-27-08
2533 dcd->stopflag--;
2534 //DosExitCritSec();
2535 }
2536 else if (*dcd->directory) {
2537 if (hwndMain)
2538 WinSendMsg(hwndMain,
2539 UM_SETUSERLISTNAME,
2540 MPFROMP(dcd->directory), MPVOID);
2541 else
2542 add_udir(FALSE, dcd->directory);
2543 }
2544 }
2545 else
2546 *dcd->previous = 0;
2547 }
2548 break;
2549
2550 case IDM_WALKDIR:
2551 {
2552 CHAR newdir[CCHMAXPATH];
2553
2554 strcpy(newdir, dcd->directory);
2555 if (!WinDlgBox(HWND_DESKTOP,
2556 dcd->hwndParent,
2557 WalkAllDlgProc,
2558 FM3ModHandle,
2559 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2560 break;
2561 if (stricmp(newdir, dcd->directory)) {
2562 strcpy(dcd->previous, dcd->directory);
2563 strcpy(dcd->directory, newdir);
2564 //DosEnterCritSec(); //GKY 11-27-08
2565 dcd->stopflag++;
2566 //DosExitCritSec();
2567 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2568 strcpy(dcd->directory, dcd->previous);
2569 //DosEnterCritSec(); // GKY 11-27-08
2570 dcd->stopflag--;
2571 //DosExitCritSec();
2572 }
2573 else if (*dcd->directory) {
2574 if (hwndMain)
2575 WinSendMsg(hwndMain,
2576 UM_SETUSERLISTNAME,
2577 MPFROMP(dcd->directory), MPVOID);
2578 else
2579 add_udir(FALSE, dcd->directory);
2580 }
2581 }
2582 }
2583 break;
2584
2585 case IDM_OPENICONME:
2586 OpenObject(dcd->directory, "ICON", dcd->hwndFrame);
2587 break;
2588 case IDM_OPENDETAILSME:
2589 OpenObject(dcd->directory, "DETAILS", dcd->hwndFrame);
2590 break;
2591 case IDM_OPENTREEME:
2592 OpenObject(dcd->directory, "TREE", dcd->hwndFrame);
2593 break;
2594 case IDM_OPENSETTINGSME:
2595 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2596 break;
2597
2598 case IDM_DOITYOURSELF:
2599 case IDM_UPDATE:
2600 case IDM_OPENWINDOW:
2601 case IDM_OPENSETTINGS:
2602 case IDM_OPENDEFAULT:
2603 case IDM_OPENICON:
2604 case IDM_OPENDETAILS:
2605 case IDM_OPENTREE:
2606 case IDM_OBJECT:
2607 case IDM_SHADOW:
2608 case IDM_SHADOW2:
2609 case IDM_DELETE:
2610 case IDM_PERMDELETE:
2611 case IDM_PRINT:
2612 case IDM_ATTRS:
2613 case IDM_INFO:
2614 case IDM_COPY:
2615 case IDM_MOVE:
2616 case IDM_WPSMOVE:
2617 case IDM_WPSCOPY:
2618 case IDM_WILDCOPY:
2619 case IDM_WILDMOVE:
2620 case IDM_RENAME:
2621 case IDM_COMPARE:
2622 case IDM_EAS:
2623 case IDM_SUBJECT:
2624 case IDM_VIEW:
2625 case IDM_VIEWTEXT:
2626 case IDM_VIEWBINARY:
2627 case IDM_VIEWARCHIVE:
2628 case IDM_EDIT:
2629 case IDM_EDITTEXT:
2630 case IDM_EDITBINARY:
2631 case IDM_SAVETOCLIP:
2632 case IDM_SAVETOCLIPFILENAME:
2633 case IDM_APPENDTOCLIP:
2634 case IDM_APPENDTOCLIPFILENAME:
2635 case IDM_ARCHIVE:
2636 case IDM_ARCHIVEM:
2637 case IDM_EXTRACT:
2638 case IDM_MCIPLAY:
2639 case IDM_COLLECTFROMFILE:
2640 case IDM_UUDECODE:
2641 case IDM_MERGE:
2642 {
2643 LISTINFO *li;
2644 ULONG action = UM_ACTION;
2645 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2646 if (li) {
2647 li->type = SHORT1FROMMP(mp1);
2648 li->hwnd = hwnd;
2649 li->list = BuildList(hwnd);
2650 switch (SHORT1FROMMP(mp1)) {
2651 case IDM_WILDMOVE:
2652 case IDM_WILDCOPY:
2653 case IDM_MOVE:
2654 case IDM_COPY:
2655 case IDM_WPSMOVE:
2656 case IDM_WPSCOPY:
2657 break;
2658 default:
2659 strcpy(li->targetpath, dcd->directory);
2660 break;
2661 }
2662 if (li->list) {
2663 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2664 if (!Collector) {
2665
2666 HWND hwndC;
2667 SWP swp;
2668
2669 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2670 !fAutoTile &&
2671 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2672 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2673 hwndC = StartCollector((fExternalCollector ||
2674 strcmp(realappname, FM3Str)) ?
2675 HWND_DESKTOP : dcd->hwndParent, 4);
2676 if (hwndC) {
2677 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2678 !fAutoTile && (!fExternalCollector &&
2679 !strcmp(realappname, FM3Str)))
2680 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2681 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2682 SWP_SHOW | SWP_ZORDER);
2683 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2684 fAutoTile && !strcmp(realappname, FM3Str))
2685 TileChildren(dcd->hwndParent, TRUE);
2686 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2687 SWP_ACTIVATE);
2688 DosSleep(100); //05 Aug 07 GKY 250
2689 }
2690 }
2691 else
2692 StartCollector(dcd->hwndParent, 4);
2693 }
2694 switch (SHORT1FROMMP(mp1)) {
2695 case IDM_APPENDTOCLIP:
2696 case IDM_APPENDTOCLIPFILENAME:
2697 case IDM_SAVETOCLIP:
2698 case IDM_SAVETOCLIPFILENAME:
2699 case IDM_ARCHIVE:
2700 case IDM_ARCHIVEM:
2701 case IDM_DELETE:
2702 case IDM_PERMDELETE:
2703 case IDM_ATTRS:
2704 case IDM_PRINT:
2705 case IDM_SHADOW:
2706 case IDM_SHADOW2:
2707 case IDM_OBJECT:
2708 case IDM_VIEW:
2709 case IDM_VIEWTEXT:
2710 case IDM_VIEWBINARY:
2711 case IDM_EDIT:
2712 case IDM_EDITTEXT:
2713 case IDM_EDITBINARY:
2714 case IDM_MCIPLAY:
2715 case IDM_UPDATE:
2716 case IDM_DOITYOURSELF:
2717 case IDM_INFO:
2718 case IDM_EAS:
2719 action = UM_MASSACTION;
2720 break;
2721 }
2722 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2723 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2724 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2725 *li->targetpath = 0;
2726 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2727 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2728 FreeListInfo(li);
2729 }
2730 else if (fUnHilite)
2731 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2732 }
2733 else
2734 free(li);
2735 }
2736 }
2737 break;
2738
2739 case IDM_DRIVESMENU:
2740 if (!hwndMain)
2741 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2742 break;
2743
2744 default:
2745 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2746 return 0;
2747 else {
2748 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2749 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2750
2751 register INT x;
2752
2753 if (!cmdloaded)
2754 load_commands();
2755 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2756 if (x >= 0) {
2757 x++;
2758 RunCommand(hwnd, x);
2759 if (fUnHilite)
2760 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2761 }
2762 }
2763 }
2764 break;
2765 }
2766 }
2767 return 0;
2768
2769 case UM_FIXCNRMLE:
2770 case UM_FIXEDITNAME:
2771 return CommonCnrProc(hwnd, msg, mp1, mp2);
2772
2773 case UM_FILESMENU:
2774 {
2775 PCNRITEM pci;
2776 HWND menuHwnd = (HWND) 0;
2777
2778 pci = (PCNRITEM) CurrentRecord(hwnd);
2779 if (pci && (INT) pci != -1) {
2780 if (pci->attrFile & FILE_DIRECTORY) {
2781 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2782// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2783 }
2784 else
2785 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2786 }
2787 return MRFROMLONG(menuHwnd);
2788 }
2789
2790 case WM_CONTROL:
2791 DosError(FERR_DISABLEHARDERR);
2792 if (dcd) {
2793 switch (SHORT2FROMMP(mp1)) {
2794 case CN_COLLAPSETREE:
2795 case CN_EXPANDTREE:
2796 {
2797 PCNRITEM pci = (PCNRITEM) mp2;
2798
2799 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
2800 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
2801 struct
2802 {
2803 ULONG serial;
2804 CHAR volumelength;
2805 CHAR volumelabel[CCHMAXPATH];
2806 }
2807 volser;
2808 APIRET rc;
2809
2810 memset(&volser, 0, sizeof(volser));
2811 DosError(FERR_DISABLEHARDERR);
2812 // fixme?
2813 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2814 FSIL_VOLSER, &volser, sizeof(volser));
2815 if (rc) {
2816 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2817 GetPString(IDS_CANTFINDDIRTEXT),
2818 pci->pszFileName);
2819 DosBeep(250,100);
2820 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2821 UnFlesh(hwnd, pci);
2822 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2823 }
2824 else {
2825 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2826 !volser.serial ||
2827 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2828 volser.serial)
2829 UnFlesh(hwnd, pci);
2830 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2831 (!volser.serial ||
2832 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2833 volser.serial)) {
2834 if (Flesh(hwnd, pci) &&
2835 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2836 !dcd->suspendview && fTopDir)
2837 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2838 }
2839 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2840 }
2841 }
2842 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2843 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
2844 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2845 }
2846 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2847 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2848 }
2849 }
2850 break;
2851
2852/*
2853 case CN_PICKUP:
2854 return PickUp(hwnd,dcd->hwndObject,mp2);
2855*/
2856
2857 case CN_CONTEXTMENU:
2858 {
2859 PCNRITEM pci = (PCNRITEM) mp2;
2860
2861 if (pci) {
2862 WinSendMsg(hwnd,
2863 CM_SETRECORDEMPHASIS,
2864 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2865 MarkAll(hwnd, FALSE, FALSE, TRUE);
2866 if (pci->attrFile & FILE_DIRECTORY)
2867 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2868 else
2869 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2870 }
2871 else {
2872 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
2873 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2874 WinSendMsg(hwnd,
2875 CM_SETRECORDEMPHASIS,
2876 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2877 dcd->cnremphasized = TRUE;
2878 }
2879 }
2880 if (dcd->hwndLastMenu) {
2881 if (dcd->hwndLastMenu == DirCnrMenu) {
2882 if (dcd->flWindowAttr & CV_MINI)
2883 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2884 }
2885 if (dcd->hwndLastMenu == DirMenu)
2886 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2887 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2888 if (dcd->cnremphasized) {
2889 WinSendMsg(hwnd,
2890 CM_SETRECORDEMPHASIS,
2891 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2892 dcd->cnremphasized = TRUE;
2893 }
2894 MarkAll(hwnd, TRUE, FALSE, TRUE);
2895 }
2896 }
2897 }
2898 break;
2899
2900 case CN_DROPHELP:
2901 if (mp2) {
2902
2903 PDRAGINFO pDInfo;
2904 PCNRITEM pci;
2905 ULONG numitems;
2906 USHORT usOperation;
2907
2908 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2909 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2910 if (!DrgAccessDraginfo(pDInfo)) {
2911 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2912 GetPString(IDS_DROPERRORTEXT));
2913 }
2914 else {
2915 numitems = DrgQueryDragitemCount(pDInfo);
2916 usOperation = pDInfo->usOperation;
2917 if (usOperation == DO_DEFAULT)
2918 usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
2919 FreeDragInfoData(hwnd, pDInfo);
2920 saymsg(MB_ENTER | MB_ICONASTERISK,
2921 hwnd,
2922 GetPString(IDS_DROPHELPHDRTEXT),
2923 GetPString(IDS_DROPHELPTEXT),
2924 numitems,
2925 &"s"[numitems == 1L],
2926 pci ? NullStr : GetPString(IDS_NOTEXT),
2927 pci ? NullStr : " ",
2928 pci ? pci->pszFileName : NullStr,
2929 pci ? " " : NullStr,
2930 GetPString((usOperation == DO_MOVE) ?
2931 IDS_MOVETEXT :
2932 (usOperation == DO_LINK) ?
2933 IDS_LINKTEXT : IDS_COPYTEXT));
2934 }
2935 }
2936 return 0;
2937
2938 case CN_DRAGLEAVE:
2939 return 0;
2940
2941 case CN_DRAGAFTER:
2942 case CN_DRAGOVER:
2943 if (mp2) {
2944
2945 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2946 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2947 PCNRITEM pci;
2948 USHORT uso;
2949
2950 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2951 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2952 if (!DrgAccessDraginfo(pDInfo)) {
2953 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2954 "DrgAccessDraginfo");
2955 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2956 }
2957 if (*dcd->directory &&
2958 (driveflags[toupper(*dcd->directory) - 'A'] &
2959 DRIVE_NOTWRITEABLE)) {
2960 DrgFreeDraginfo(pDInfo);
2961 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
2962 DO_LINK); /* (compare) only */
2963 }
2964 if (pci) {
2965 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2966 DrgFreeDraginfo(pDInfo);
2967 return (MRFROM2SHORT(DOR_NODROP, 0));
2968 }
2969 uso = pDInfo->usOperation;
2970 if (uso == DO_DEFAULT)
2971 uso = fCopyDefault ? DO_COPY : DO_MOVE;
2972 if (!(pci->attrFile & FILE_DIRECTORY)) {
2973 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2974 DrgFreeDraginfo(pDInfo);
2975 return MRFROM2SHORT(DOR_NODROP, 0);
2976 }
2977 if (uso != DO_LINK &&
2978 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2979 DRIVE_NOTWRITEABLE)) {
2980
2981 ARC_TYPE *info = NULL;
2982
2983 if (!fQuickArcFind &&
2984 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2985 DRIVE_SLOW))
2986 info = find_type(pci->pszFileName, NULL);
2987 else
2988 info = quick_find_type(pci->pszFileName, NULL);
2989 if (!info || ((uso == DO_MOVE && !info->move) ||
2990 (uso == DO_COPY && !info->create))) {
2991 DrgFreeDraginfo(pDInfo);
2992 return MRFROM2SHORT(DOR_NODROP, 0);
2993 }
2994 }
2995 }
2996 }
2997
2998 /* Access DRAGITEM index to DRAGITEM
2999 * Check valid rendering mechanisms and data
3000 */
3001 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
3002 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL) ||
3003 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
3004 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) {
3005 DrgFreeDraginfo(pDInfo);
3006 if (driveflags[toupper(*dcd->directory) - 'A'] &
3007 DRIVE_NOTWRITEABLE)
3008 return MRFROM2SHORT(DOR_DROP, DO_LINK);
3009 if (toupper(*dcd->directory) < 'C')
3010 return MRFROM2SHORT(DOR_DROP, DO_COPY);
3011 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
3012 ((fCopyDefault) ? DO_COPY : DO_MOVE));
3013 }
3014 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
3015 }
3016 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
3017
3018 case CN_INITDRAG:
3019 {
3020 BOOL wasemphasized = FALSE;
3021 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
3022 PCNRITEM pci;
3023
3024 if (pcd) {
3025 pci = (PCNRITEM) pcd->pRecord;
3026 if (pci) {
3027 if ((INT) pci == -1)
3028 pci = NULL;
3029 else if (pci->rc.flRecordAttr & CRA_SELECTED)
3030 wasemphasized = TRUE;
3031 }
3032 else if (!*dcd->directory) {
3033 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
3034 break;
3035 }
3036 else if (IsRoot(dcd->directory)) {
3037 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
3038 GetPString(IDS_CANTDRAGROOTDIR));
3039 break;
3040 }
3041 if (hwndStatus2) {
3042 if (pci)
3043 WinSetWindowText(hwndStatus2,
3044 GetPString(IDS_DRAGFILEOBJTEXT));
3045 else
3046 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGDIRTEXT));
3047 }
3048 if (DoFileDrag(hwnd,
3049 dcd->hwndObject,
3050 mp2,
3051 NULL,
3052 pci ? NULL : dcd->directory,
3053 pci ? TRUE : FALSE)) {
3054 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
3055 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
3056 }
3057 }
3058 if (hwndStatus2) {
3059 WinSetFocus(HWND_DESKTOP, hwnd);
3060 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3061 }
3062 }
3063 }
3064 return 0;
3065
3066 case CN_DROP:
3067 if (mp2) {
3068
3069 LISTINFO *li;
3070 ULONG action = UM_ACTION;
3071
3072 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
3073 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
3074 if (li) {
3075 if (li->list && li->list[0] && IsRoot(li->list[0]))
3076 li->type = DO_LINK;
3077 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
3078
3079 CHECKLIST cl;
3080
3081 memset(&cl, 0, sizeof(cl));
3082 cl.size = sizeof(cl);
3083 cl.flags = li->type;
3084 cl.list = li->list;
3085 cl.cmd = li->type;
3086 cl.prompt = li->targetpath;
3087 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
3088 DropListProc, FM3ModHandle,
3089 DND_FRAME, MPFROMP(&cl));
3090 if (li->type == DID_ERROR)
3091 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
3092 "Drag & Drop Dialog");
3093 if (!li->type) {
3094 FreeListInfo(li);
3095 return 0;
3096 }
3097 li->list = cl.list;
3098 if (!li->list || !li->list[0]) {
3099 FreeListInfo(li);
3100 return 0;
3101 }
3102 }
3103 switch (li->type) {
3104 case DND_LAUNCH:
3105 strcat(li->targetpath, " %a");
3106 ExecOnList(dcd->hwndParent, li->targetpath,
3107 PROMPT | WINDOWED, NULL, li->list, NULL,
3108 pszSrcFile, __LINE__);
3109 FreeList(li->list);
3110 li->list = NULL;
3111 break;
3112 case DO_LINK:
3113 if (fLinkSetsIcon) {
3114 li->type = IDM_SETICON;
3115 action = UM_MASSACTION;
3116 }
3117 else
3118 li->type = IDM_COMPARE;
3119 break;
3120 case DND_EXTRACT:
3121 if (*li->targetpath && !IsFile(li->targetpath))
3122 li->type = IDM_EXTRACT;
3123 break;
3124 case DND_MOVE:
3125 li->type = IDM_MOVE;
3126 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3127 action = UM_MASSACTION;
3128 li->type = IDM_ARCHIVEM;
3129 }
3130 break;
3131 case DND_WILDMOVE:
3132 li->type = IDM_WILDMOVE;
3133 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3134 action = UM_MASSACTION;
3135 li->type = IDM_ARCHIVEM;
3136 }
3137 break;
3138 case DND_OBJECT:
3139 li->type = IDM_OBJECT;
3140 action = UM_MASSACTION;
3141 break;
3142 case DND_SHADOW:
3143 li->type = IDM_SHADOW;
3144 action = UM_MASSACTION;
3145 break;
3146 case DND_COMPARE:
3147 li->type = IDM_COMPARE;
3148 break;
3149 case DND_SETICON:
3150 action = UM_MASSACTION;
3151 li->type = IDM_SETICON;
3152 break;
3153 case DND_COPY:
3154 li->type = IDM_COPY;
3155 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3156 action = UM_MASSACTION;
3157 li->type = IDM_ARCHIVE;
3158 }
3159 break;
3160 case DND_WILDCOPY:
3161 li->type = IDM_WILDCOPY;
3162 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3163 action = UM_MASSACTION;
3164 li->type = IDM_ARCHIVE;
3165 }
3166 break;
3167 default:
3168 if (*li->arcname && li->info) {
3169 action = UM_MASSACTION;
3170 li->type =
3171 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
3172 }
3173 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
3174 action = UM_MASSACTION;
3175 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
3176 }
3177 else
3178 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
3179 break;
3180 }
3181 if (!li->list || !li->list[0])
3182 FreeListInfo(li);
3183 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
3184 FreeListInfo(li);
3185 else {
3186
3187 USHORT usop = 0;
3188
3189 switch (li->type) {
3190 case IDM_COPY:
3191 case IDM_WILDCOPY:
3192 usop = DO_COPY;
3193 break;
3194 case IDM_MOVE:
3195 case IDM_WILDMOVE:
3196 case IDM_ARCHIVEM:
3197 usop = DO_MOVE;
3198 break;
3199 }
3200 if (usop)
3201 return MRFROM2SHORT(DOR_DROP, usop);
3202 }
3203 }
3204 }
3205 return 0;
3206
3207 case CN_ENDEDIT:
3208 case CN_BEGINEDIT:
3209 {
3210 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3211 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3212
3213 if (pfi || pci) {
3214
3215 MRESULT mre;
3216
3217 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3218 if (mre != (MRESULT) - 1)
3219 return mre;
3220 }
3221 else if (!pfi && !pci)
3222 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3223 }
3224 return 0;
3225
3226 case CN_REALLOCPSZ:
3227 {
3228 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3229 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3230 HWND hwndMLE;
3231 static CHAR szData[CCHMAXPATH];
3232 CHAR testname[CCHMAXPATH];
3233
3234 if (!pci && !pfi) {
3235 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3236 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
3237 chop_at_crnl(szData);
3238 bstrip(szData);
3239 if (*szData) {
3240 if (!DosQueryPathInfo(szData,
3241 FIL_QUERYFULLNAME,
3242 testname, sizeof(testname))) {
3243 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3244 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3245 }
3246 }
3247 }
3248 }
3249 else {
3250
3251 MRESULT mre;
3252
3253 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3254 if (mre != (MRESULT) - 1)
3255 return mre;
3256 }
3257 }
3258 return 0;
3259
3260 case CN_EMPHASIS:
3261 if (!mp2)
3262 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3263 else {
3264 PNOTIFYRECORDEMPHASIS pre = mp2;
3265 PCNRITEM pci;
3266 CHAR s[CCHMAXPATHCOMP + 91], tb[81], tf[81];
3267
3268 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
3269 if (!pci) {
3270 if (hwndStatus2)
3271 WinSetWindowText(hwndStatus2, NullStr);
3272 if (fMoreButtons) {
3273 WinSetWindowText(hwndName, NullStr);
3274 WinSetWindowText(hwndDate, NullStr);
3275 WinSetWindowText(hwndAttr, NullStr);
3276 }
3277 if (hwndMain)
3278 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3279 break;
3280 }
3281 if (pre->fEmphasisMask & CRA_SELECTED) {
3282 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3283 dcd->selectedbytes += (pci->cbFile + pci->easize);
3284 dcd->selectedfiles++;
3285 }
3286 else if (dcd->selectedfiles) {
3287 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3288 dcd->selectedfiles--;
3289 }
3290 if (!dcd->suspendview) {
3291 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3292 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3293 sprintf(s, "%s / %s", tf, tb);
3294 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3295 }
3296 }
3297 if (!dcd->suspendview && hwndMain &&
3298 (pre->fEmphasisMask & CRA_CURSORED) &&
3299 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3300 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3301 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
3302 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3303 else
3304 WinSendMsg(hwndMain,
3305 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
3306 }
3307 if (!dcd->suspendview &&
3308 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3309 if (pre->fEmphasisMask & CRA_CURSORED) {
3310 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3311 if (fSplitStatus && hwndStatus2) {
3312 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3313 if (!fMoreButtons) {
3314 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
3315 tb, pci->date.year,
3316 pci->date.month, pci->date.day, pci->time.hours,
3317 pci->time.minutes, pci->time.seconds,
3318 pci->pszDispAttr, pci->pszFileName);
3319 }
3320 else {
3321 *tf = 0;
3322 if (pci->cbFile + pci->easize > 1024) {
3323 CommaFmtULL(tf, sizeof(tf),
3324 pci->cbFile + pci->easize, 'K');
3325 }
3326 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3327 tb,
3328 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3329 }
3330 WinSetWindowText(hwndStatus2, s);
3331 }
3332 if (fMoreButtons) {
3333 WinSetWindowText(hwndName, pci->pszFileName);
3334 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
3335 pci->date.year, pci->date.month,
3336 pci->date.day, pci->time.hours, pci->time.minutes,
3337 pci->time.seconds);
3338 WinSetWindowText(hwndDate, s);
3339 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3340 }
3341 }
3342 }
3343 }
3344 }
3345 break;
3346
3347 case CN_ENTER:
3348 if (mp2) {
3349
3350 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3351 FILEFINDBUF3 ffb;
3352 HDIR hDir = HDIR_CREATE;
3353 ULONG nm = 1;
3354 APIRET status = 0;
3355
3356 SetShiftState();
3357 if (pci) {
3358 if (pci->rc.flRecordAttr & CRA_INUSE)
3359 break;
3360 DosError(FERR_DISABLEHARDERR);
3361 status = DosFindFirst(pci->pszFileName,
3362 &hDir,
3363 FILE_NORMAL | FILE_DIRECTORY |
3364 FILE_ARCHIVED | FILE_READONLY |
3365 FILE_HIDDEN | FILE_SYSTEM,
3366 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
3367 priority_bumped();
3368 if (!status) {
3369 DosFindClose(hDir);
3370 if (ffb.attrFile & FILE_DIRECTORY) {
3371 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3372 PostMsg(hwnd,
3373 WM_COMMAND,
3374 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3375 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3376 (KC_CTRL | KC_SHIFT))
3377 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
3378 else if (shiftstate & KC_CTRL)
3379 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
3380 else if (shiftstate & KC_SHIFT) {
3381
3382 HWND hwndDir;
3383
3384 hwndDir = OpenDirCnr((HWND) 0,
3385 dcd->hwndParent,
3386 dcd->hwndFrame,
3387 FALSE, pci->pszFileName);
3388 if (hwndDir) {
3389 if (fMinOnOpen)
3390 WinSetWindowPos(dcd->hwndFrame,
3391 HWND_BOTTOM,
3392 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3393 if (fAutoTile)
3394 TileChildren(dcd->hwndParent, TRUE);
3395 WinSetWindowPos(hwndDir,
3396 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3397 }
3398 }
3399 else {
3400 strcpy(dcd->previous, dcd->directory);
3401 strcpy(dcd->directory, pci->pszFileName);
3402 //DosEnterCritSec(); // GKY 11-27-08
3403 dcd->stopflag++;
3404 //DosExitCritSec();
3405 if (!PostMsg(dcd->hwndObject,
3406 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
3407 //DosEnterCritSec(); // GKY 11-27-08
3408 dcd->stopflag--;
3409 //DosExitCritSec();
3410 }
3411 else if (*dcd->directory) {
3412 if (hwndMain)
3413 WinSendMsg(hwndMain,
3414 UM_SETUSERLISTNAME,
3415 MPFROMP(dcd->directory), MPVOID);
3416 else
3417 add_udir(FALSE, dcd->directory);
3418 }
3419 }
3420 }
3421 else {
3422
3423 SWP swp;
3424
3425 WinQueryWindowPos(dcd->hwndFrame, &swp);
3426 WinSendMsg(hwnd,
3427 CM_SETRECORDEMPHASIS,
3428 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3429 DefaultViewKeys(hwnd,
3430 dcd->hwndFrame,
3431 dcd->hwndParent, &swp, pci->pszFileName);
3432 WinSendMsg(hwnd,
3433 CM_SETRECORDEMPHASIS,
3434 MPFROMP(pci),
3435 MPFROM2SHORT(FALSE,
3436 CRA_INUSE |
3437 ((fUnHilite) ? CRA_SELECTED : 0)));
3438 }
3439 }
3440 else {
3441 if (!*dcd->directory || IsValidDir(dcd->directory)) {
3442 NotifyError(pci->pszFileName, status);
3443 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
3444 if (hwndStatus)
3445 WinSetWindowText(hwndStatus,
3446 GetPString(IDS_RESCANSUGGESTEDTEXT));
3447 }
3448 else {
3449 //DosEnterCritSec(); // GKY 11-27-08
3450 dcd->stopflag++;
3451 //DosExitCritSec();
3452 if (!PostMsg(dcd->hwndObject,
3453 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3454 //DosEnterCritSec(); // GKY 11-27-08
3455 dcd->stopflag--;
3456 //DosExitCritSec();
3457 }
3458 else if (*dcd->directory) {
3459 if (hwndMain)
3460 WinSendMsg(hwndMain,
3461 UM_SETUSERLISTNAME,
3462 MPFROMP(dcd->directory), MPVOID);
3463 else
3464 add_udir(FALSE, dcd->directory);
3465 }
3466 }
3467 }
3468 }
3469 else if (*dcd->directory)
3470 OpenObject(dcd->directory, Default, hwnd);
3471 } // CN_ENTER
3472 break;
3473 } // switch mp1
3474 break;
3475 } // if dcd
3476 return 0;
3477
3478 case UM_LOADFILE:
3479 if (dcd && mp2) {
3480
3481 HWND hwnd;
3482
3483 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
3484 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
3485 (CHAR *)mp2, dcd->hwndFrame);
3486 else
3487 hwnd = StartMLEEditor(dcd->hwndParent,
3488 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
3489 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
3490 return MRFROMLONG(hwnd);
3491 }
3492 return 0;
3493
3494 case WM_SAVEAPPLICATION:
3495 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3496
3497 SWP swp;
3498
3499 WinQueryWindowPos(dcd->hwndFrame, &swp);
3500 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3501 PrfWriteProfileData(fmprof,
3502 appname, "VDirSizePos", &swp, sizeof(swp));
3503 }
3504 break;
3505
3506 case WM_CLOSE:
3507 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3508 if (LastDir == hwnd)
3509 LastDir = (HWND) 0;
3510 if (dcd) {
3511 dcd->stopflag++;
3512 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3513 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3514 if (dcd->hwndObject) {
3515 // Ensure object window destroy does not attempt duplicate clean up
3516 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3517 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3518 Win_Error(dcd->hwndObject, hwnd, pszSrcFile, __LINE__, "hwndObject WinPostMsg failed");
3519 }
3520 if (dcd->hwndRestore)
3521 WinSetWindowPos(dcd->hwndRestore,
3522 HWND_TOP,
3523 0,
3524 0,
3525 0,
3526 0,
3527 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3528 FreeList(dcd->lastselection);
3529 free(dcd);
3530 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3531 DosPostEventSem(CompactSem);
3532 }
3533 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3534 QW_PARENT));
3535 return 0;
3536
3537 case WM_DESTROY:
3538# ifdef FORTIFY
3539 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
3540# endif
3541 if (DirMenu)
3542 WinDestroyWindow(DirMenu);
3543 if (DirCnrMenu)
3544 WinDestroyWindow(DirCnrMenu);
3545 if (FileMenu)
3546 WinDestroyWindow(FileMenu);
3547 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3548 EmptyCnr(hwnd);
3549# ifdef FORTIFY
3550 Fortify_LeaveScope();
3551# endif
3552 break;
3553 } // switch
3554
3555 if (dcd && dcd->oldproc) {
3556 // 11 May 08 SHL fixme debug fortify
3557 if ((ULONG)dcd->oldproc == 0xa9a9a9a9)
3558 DbgMsg(pszSrcFile, __LINE__, "calling oldproc after dcd free msg %x mp1 %x mp2 %x", msg, mp1, mp2);
3559 return dcd->oldproc(hwnd, msg, mp1, mp2);
3560 }
3561 else
3562 return PFNWPCnr(hwnd, msg, mp1, mp2);
3563}
3564
3565HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3566 ULONG flags)
3567{
3568 /* bitmapped flags:
3569 * 0x00000001 = don't close app when window closes
3570 * 0x00000002 = no frame controls
3571 */
3572
3573 HWND hwndFrame = (HWND) 0, hwndClient;
3574 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3575 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3576 USHORT id;
3577 static USHORT idinc = 0;
3578 DIRCNRDATA *dcd;
3579 static BOOL first = FALSE;
3580
3581 if (flags & 2)
3582 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3583 FCF_MINMAX | FCF_ICON));
3584 if (!idinc)
3585 idinc = (rand() % 100);
3586 if (!hwndParent)
3587 hwndParent = HWND_DESKTOP;
3588 if (ParentIsDesktop(hwndParent, hwndParent))
3589 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3590 if (!hwndMain && !first) {
3591 if (DirCnrMenu) {
3592 MENUITEM mi;
3593 memset(&mi, 0, sizeof(mi));
3594 WinSendMsg(DirCnrMenu,
3595 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
3596 mi.iPosition = MIT_END;
3597 mi.afStyle = MIS_TEXT;
3598 mi.id = IDM_DRIVESMENU;
3599 WinSendMsg(DirCnrMenu,
3600 MM_INSERTITEM,
3601 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3602 }
3603 first = TRUE;
3604 }
3605 if (directory) {
3606 hwndFrame = WinCreateStdWindow(hwndParent,
3607 WS_VISIBLE,
3608 &FrameFlags,
3609 WC_DIRCONTAINER,
3610 NULL,
3611 WS_VISIBLE | fwsAnimate,
3612 FM3ModHandle, DIR_FRAME, &hwndClient);
3613 if (hwndFrame && hwndClient) {
3614 id = DIR_FRAME + idinc++;
3615 if (idinc > 99)
3616 idinc = 0;
3617 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3618# ifdef FORTIFY
3619 Fortify_EnterScope();
3620# endif
3621 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3622 if (!dcd) {
3623 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3624 hwndFrame = (HWND) 0;
3625 }
3626 else {
3627 dcd->size = sizeof(DIRCNRDATA);
3628 dcd->id = id;
3629 dcd->type = DIR_FRAME;
3630 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3631 dcd->hwndFrame = hwndFrame;
3632 dcd->hwndClient = hwndClient;
3633 dcd->hwndRestore = hwndRestore;
3634 dcd->dontclose = ((flags & 1) != 0);
3635 dcd->ds.detailslongname = dsDirCnrDefault.detailslongname;
3636 dcd->ds.detailssubject = dsDirCnrDefault.detailssubject;
3637 dcd->ds.detailsea = dsDirCnrDefault.detailsea;
3638 dcd->ds.detailssize = dsDirCnrDefault.detailssize;
3639 dcd->ds.detailsicon = dsDirCnrDefault.detailsicon;
3640 dcd->ds.detailsattr = dsDirCnrDefault.detailsattr;
3641 dcd->ds.detailscrdate = dsDirCnrDefault.detailscrdate;
3642 dcd->ds.detailscrtime = dsDirCnrDefault.detailscrtime;
3643 dcd->ds.detailslwdate = dsDirCnrDefault.detailslwdate;
3644 dcd->ds.detailslwtime = dsDirCnrDefault.detailslwtime;
3645 dcd->ds.detailsladate = dsDirCnrDefault.detailsladate;
3646 dcd->ds.detailslatime = dsDirCnrDefault.detailslatime;
3647 strcpy(dcd->directory, directory);
3648 add_udir(FALSE, directory);
3649 {
3650 PFNWP oldproc;
3651
3652 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3653 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3654 }
3655 dcd->hwndCnr = WinCreateWindow(hwndClient,
3656 WC_CONTAINER,
3657 NULL,
3658 CCS_AUTOPOSITION | CCS_MINIICONS |
3659 CCS_MINIRECORDCORE | ulCnrType, // |
3660 //WS_VISIBLE,
3661 0,
3662 0,
3663 0,
3664 0,
3665 hwndClient,
3666 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3667 if (!dcd->hwndCnr) {
3668 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3669 IDS_WINCREATEWINDOW);
3670 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3671 free(dcd);
3672 hwndFrame = (HWND) 0;
3673 }
3674 else {
3675# ifdef FORTIFY
3676 Fortify_ChangeScope(dcd, -1);
3677# endif
3678 RestorePresParams(dcd->hwndCnr, "DirCnr");
3679 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3680 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3681 (PFNWP) DirCnrWndProc);
3682 {
3683 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3684 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3685 };
3686
3687 if (!(flags & 2))
3688 ids[6] = 0;
3689 CommonCreateTextChildren(dcd->hwndClient,
3690 WC_DIRSTATUS, ids);
3691 }
3692 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3693 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3694 if (FrameFlags & FCF_TASKLIST) {
3695
3696 SWP swp, swpD;
3697 ULONG size = sizeof(swp);
3698 LONG cxScreen, cyScreen;
3699
3700 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3701 if (PrfQueryProfileData(fmprof,
3702 appname, "VDirSizePos", &swpD, &size)) {
3703 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3704 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3705 if (swp.x + swpD.cx > cxScreen)
3706 swp.x = cxScreen - swpD.cx;
3707 if (swp.y + swpD.cy > cyScreen)
3708 swp.y = cyScreen - swpD.cy;
3709 swp.cx = swpD.cx;
3710 swp.cy = swpD.cy;
3711 }
3712 WinSetWindowPos(hwndFrame,
3713 HWND_TOP,
3714 swp.x,
3715 swp.y,
3716 swp.cx,
3717 swp.cy,
3718 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3719 SWP_ACTIVATE);
3720 }
3721 WinShowWindow(dcd->hwndCnr, TRUE);
3722 }
3723 }
3724# ifdef FORTIFY
3725 Fortify_LeaveScope();
3726# endif
3727 }
3728 }
3729 return hwndFrame;
3730}
3731
3732#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3733#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3734#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.