source: trunk/dll/dircnrs.c@ 1354

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

Added Seek & Scan to directory context menu. (Ticket 167)

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