source: trunk/dll/dircnrs.c@ 1394

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

Ticket 340: Convert GetPString to use STRINGTABLE.

Drop fm3dll.str and mkstr.exe from makefiles and wpi builders

Convert many functions to expect PCSZ arguments.
Correct walk, compare and dirsizes dialog setups to ignore saved dialog size
Drop copyright.c logic from makefile

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