source: trunk/dll/dircnrs.c@ 1411

Last change on this file since 1411 was 1411, checked in by Steven Levine, 16 years ago

Rework extended container search to use common logic
Update docs to match code
Shift now reverses configured state of extended container search enable
Backslash optional in not ambiguous

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