source: trunk/dll/dircnrs.c@ 1402

Last change on this file since 1402 was 1402, checked in by Gregg Young, 16 years ago

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 100.9 KB
Line 
1
2/***********************************************************************
3
4 $Id: dircnrs.c 1402 2009-03-14 17:17:59Z gyoung $
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 else if ((shiftstate & KC_ALT) == KC_ALT)
1229 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_CREATE, 0), MPVOID);
1230 break;
1231 case VK_PAGEUP:
1232 if ((shiftstate & KC_CTRL) == KC_CTRL)
1233 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PARENT, 0), MPVOID);
1234 break;
1235 case VK_PAGEDOWN:
1236 if ((shiftstate & KC_CTRL) == KC_CTRL)
1237 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PREVIOUS, 0), MPVOID);
1238 break;
1239 case VK_HOME:
1240 if ((shiftstate & KC_CTRL) == KC_CTRL && dcd) {
1241
1242 CHAR s[CCHMAXPATH], *p;
1243
1244 strcpy(s, dcd->directory);
1245 p = strchr(s, '\\');
1246 if (p) {
1247 p++;
1248 *p = 0;
1249 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(s), MPVOID);
1250 }
1251 }
1252 break;
1253 case VK_DELETE:
1254 if ((shiftstate & KC_CTRL) == KC_CTRL)
1255 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1256 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1257 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1258 else
1259 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1260 break;
1261 }
1262 }
1263 if (shiftstate || fNoSearch)
1264 break;
1265 if (SHORT1FROMMP(mp1) & KC_CHAR) {
1266
1267 ULONG thistime, len;
1268 SEARCHSTRING srch;
1269 PCNRITEM pci;
1270
1271 if (!dcd)
1272 break;
1273 switch (SHORT1FROMMP(mp2)) {
1274 case '\x1b':
1275 case '\r':
1276 case '\n':
1277 dcd->lasttime = 0;
1278 *dcd->szCommonName = 0;
1279 break;
1280 default:
1281 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1282 if (thistime > dcd->lasttime + 1250)
1283 *dcd->szCommonName = 0;
1284 dcd->lasttime = thistime;
1285 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
1286 break;
1287 KbdRetry:
1288 len = strlen(dcd->szCommonName);
1289 if (len >= CCHMAXPATH - 1) {
1290 *dcd->szCommonName = 0;
1291 len = 0;
1292 }
1293 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1294 dcd->szCommonName[len + 1] = 0;
1295 memset(&srch, 0, sizeof(SEARCHSTRING));
1296 srch.cb = (ULONG) sizeof(SEARCHSTRING);
1297 srch.pszSearch = (PSZ) dcd->szCommonName;
1298 srch.fsPrefix = TRUE;
1299 srch.fsCaseSensitive = FALSE;
1300 srch.usView = CV_ICON;
1301 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
1302 MPFROMLONG(CMA_FIRST));
1303 if (pci && (INT) pci != -1) {
1304
1305 USHORT attrib = CRA_CURSORED;
1306
1307 /* make found item current item */
1308 if (!stricmp(pci->pszFileName, dcd->szCommonName))
1309 attrib |= CRA_SELECTED;
1310 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1311 MPFROM2SHORT(TRUE, attrib));
1312 /* make sure that record shows in viewport */
1313 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1314 return (MRESULT) TRUE;
1315 }
1316 else {
1317 if (SHORT1FROMMP(mp2) == ' ') {
1318 dcd->szCommonName[len] = 0;
1319 break;
1320 }
1321 *dcd->szCommonName = 0;
1322 dcd->lasttime = 0;
1323 if (len) // retry as first letter if no match
1324 goto KbdRetry;
1325 }
1326 break;
1327 }
1328 }
1329 break;
1330
1331 case WM_MOUSEMOVE:
1332 case WM_BUTTON1UP:
1333 case WM_BUTTON2UP:
1334 case WM_BUTTON3UP:
1335 case WM_CHORD:
1336 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1337 break;
1338
1339 case WM_BUTTON1MOTIONEND:
1340 {
1341 CNRINFO cnri;
1342
1343 memset(&cnri, 0, sizeof(CNRINFO));
1344 cnri.cb = sizeof(CNRINFO);
1345 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1346 MPFROMLONG(sizeof(CNRINFO)))) {
1347 if (cnri.flWindowAttr & CV_DETAIL)
1348 PrfWriteProfileData(fmprof, appname, "CnrSplitBar",
1349 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
1350 }
1351 }
1352 break;
1353
1354 case UM_COMPARE:
1355 if (dcd && mp1 && mp2) {
1356
1357 COMPARE *cmp;
1358 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
1359
1360 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1361# ifdef FORTIFY
1362 Fortify_EnterScope();
1363# endif
1364 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1365 if (cmp) {
1366 cmp->size = sizeof(COMPARE);
1367 strcpy(cmp->leftdir, leftdir);
1368 strcpy(cmp->rightdir, rightdir);
1369 cmp->hwndParent = dcd->hwndParent;
1370 cmp->dcd.hwndParent = dcd->hwndParent;
1371 WinDlgBox(HWND_DESKTOP,
1372 HWND_DESKTOP,
1373 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1374 }
1375# ifdef FORTIFY
1376 Fortify_LeaveScope();
1377# endif
1378 }
1379 }
1380 return 0;
1381
1382 case WM_PRESPARAMCHANGED:
1383 PresParamChanged(hwnd, PCSZ_DIRCNR, mp1, mp2);
1384 break;
1385
1386 case UM_UPDATERECORDLIST:
1387 if (dcd && mp1)
1388 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1389 return 0;
1390
1391 case UM_UPDATERECORD:
1392 if (dcd && mp1) {
1393
1394 CHAR *filename;
1395
1396 filename = mp1;
1397 if (filename)
1398 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1399 }
1400 return 0;
1401
1402 case WM_SETFOCUS:
1403 /*
1404 * put name of our window (directory name) on status line
1405 */
1406 if (dcd && hwndStatus && mp2) {
1407
1408 PCNRITEM pci = NULL;
1409
1410 if (fAutoView && hwndMain) {
1411 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
1412 MPFROMSHORT(CRA_CURSORED));
1413 if (pci && (INT) pci != -1 &&
1414 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1415 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1416 else
1417 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1418 }
1419 if (*dcd->directory) {
1420 if (hwndMain)
1421 WinSendMsg(hwndMain,
1422 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1423 else
1424 add_udir(FALSE, dcd->directory);
1425 }
1426 if (hwndMain)
1427 PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
1428 }
1429 if (mp2) {
1430 LastDir = hwnd;
1431 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1432 if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory) {
1433 PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
1434
1435 if (pszTempDir) {
1436 if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
1437 free(pszTempDir);
1438 }
1439 }
1440 }
1441 break;
1442
1443 case UM_SETDIR:
1444 if (dcd && mp1) {
1445
1446 CHAR fullname[CCHMAXPATH];
1447
1448 DosError(FERR_DISABLEHARDERR);
1449 if (!DosQueryPathInfo((CHAR *)mp1,
1450 FIL_QUERYFULLNAME, fullname, sizeof(fullname))) {
1451 if (stricmp(dcd->directory, fullname)) {
1452 strcpy(dcd->previous, dcd->directory);
1453 strcpy(dcd->directory, fullname);
1454 //DosEnterCritSec(); //GKY 11-27-08
1455 dcd->stopflag++;
1456 //DosExitCritSec();
1457 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
1458 strcpy(dcd->directory, dcd->previous);
1459 //DosEnterCritSec(); //GKY 11-27-08
1460 dcd->stopflag--;
1461 //DosExitCritSec();
1462 }
1463 else if (*dcd->directory) {
1464 if (hwndMain)
1465 WinSendMsg(hwndMain,
1466 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1467 else
1468 add_udir(FALSE, dcd->directory);
1469 }
1470 }
1471 }
1472 }
1473 break;
1474
1475 case UM_RESCAN:
1476 if (dcd) {
1477
1478 CNRINFO cnri;
1479 CHAR s[CCHMAXPATH * 2], tf[81], tb[81], szDate[DATE_BUF_BYTES];
1480 PCNRITEM pci;
1481
1482 memset(&cnri, 0, sizeof(CNRINFO));
1483 cnri.cb = sizeof(CNRINFO);
1484 WinSendMsg(hwnd,
1485 CM_QUERYCNRINFO,
1486 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1487 cnri.pszCnrTitle = dcd->directory;
1488 WinSendMsg(hwnd,
1489 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
1490 dcd->totalfiles = cnri.cRecords;
1491 commafmt(tb, sizeof(tb), dcd->totalfiles);
1492 CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K');
1493 sprintf(s, "%s / %s", tb, tf);
1494 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1495 commafmt(tb, sizeof(tb), dcd->selectedfiles);
1496 CommaFmtULL(tf, sizeof(tf), dcd->selectedbytes, 'K');
1497 sprintf(s, "%s / %s", tb, tf);
1498 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1499 if (hwndStatus &&
1500 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1501 PostMsg(dcd->hwndObject, UM_RESCAN2, MPVOID, MPVOID);
1502 if ((fSplitStatus && hwndStatus2) || fMoreButtons) {
1503 pci = WinSendMsg(hwnd,
1504 CM_QUERYRECORDEMPHASIS,
1505 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1506 if (pci && (INT) pci != -1) {
1507 if (fSplitStatus && hwndStatus2) {
1508 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1509 if (!fMoreButtons) {
1510 DateFormat(szDate, pci->date);
1511 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
1512 tb,
1513 szDate,
1514 pci->time.hours,
1515 TimeSeparator,
1516 pci->time.minutes,
1517 TimeSeparator,
1518 pci->time.seconds,
1519 pci->pszDispAttr, pci->pszFileName);
1520 }
1521 else {
1522 *tf = 0;
1523 if (pci->cbFile + pci->easize > 1024) {
1524 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1525 }
1526 sprintf(s,
1527 GetPString(IDS_STATUSSIZETEXT),
1528 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1529 }
1530 WinSetWindowText(hwndStatus2, s);
1531 }
1532 else
1533 WinSetWindowText(hwndStatus2, NullStr);
1534 if (fMoreButtons) {
1535 WinSetWindowText(hwndName, pci->pszFileName);
1536 DateFormat(szDate, pci->date);
1537 sprintf(s, "%s %02u%s%02u%s%02u",
1538 szDate,
1539 pci->time.hours, TimeSeparator,
1540 pci->time.minutes, TimeSeparator,
1541 pci->time.seconds);
1542 WinSetWindowText(hwndDate, s);
1543 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1544 }
1545 }
1546 else {
1547 WinSetWindowText(hwndStatus2, NullStr);
1548 WinSetWindowText(hwndName, NullStr);
1549 WinSetWindowText(hwndDate, NullStr);
1550 WinSetWindowText(hwndAttr, NullStr);
1551 }
1552 }
1553 }
1554 }
1555 return 0;
1556
1557 case UM_SORTRECORD:
1558 if (dcd) {
1559
1560 CNRINFO cnri;
1561
1562 memset(&cnri, 0, sizeof(CNRINFO));
1563 cnri.cb = sizeof(CNRINFO);
1564 WinSendMsg(hwnd,
1565 CM_QUERYCNRINFO,
1566 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1567 cnri.pSortRecord = (PVOID) SortDirCnr;
1568 WinSendMsg(hwnd,
1569 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PSORTRECORD));
1570 WinSendMsg(hwnd,
1571 CM_SORTRECORD,
1572 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
1573 }
1574 return 0;
1575
1576 case UM_SETUP:
1577 if (dcd) {
1578 if (!dcd->hwndObject) {
1579 /*
1580 * first time through -- set things up
1581 */
1582
1583 CNRINFO cnri;
1584
1585 memset(&cnri, 0, sizeof(CNRINFO));
1586 cnri.cb = sizeof(CNRINFO);
1587 WinSendMsg(hwnd,
1588 CM_QUERYCNRINFO,
1589 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1590 cnri.cyLineSpacing = 0;
1591 cnri.cxTreeIndent = 12L;
1592
1593 cnri.flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1594 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES | CV_MINI |
1595 CV_FLOW);
1596 cnri.pSortRecord = (PVOID) SortDirCnr;
1597
1598 {
1599 ULONG size = sizeof(ULONG);
1600
1601 PrfQueryProfileData(fmprof,
1602 appname,
1603 "DirflWindowAttr",
1604 (PVOID) & cnri.flWindowAttr, &size);
1605 size = sizeof(MASK);
1606 if (!*dcd->mask.szMask &&
1607 !dcd->mask.attrFile && !dcd->mask.antiattr) {
1608 if (PrfQueryProfileSize(fmprof,
1609 appname, "DirFilter", &size) && size) {
1610 PrfQueryProfileData(fmprof,
1611 appname, "DirFilter", &dcd->mask, &size);
1612 SetMask(dcd->mask.szMask, &dcd->mask);
1613 }
1614 else
1615 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1616 FILE_ARCHIVED | FILE_DIRECTORY |
1617 FILE_HIDDEN | FILE_SYSTEM);
1618 }
1619 *(dcd->mask.prompt) = 0;
1620 }
1621 if (dcd->flWindowAttr)
1622 cnri.flWindowAttr = dcd->flWindowAttr;
1623 else
1624 dcd->flWindowAttr = cnri.flWindowAttr;
1625 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH |
1626 CA_TITLEREADONLY | CA_TITLESEPARATOR));
1627 cnri.flWindowAttr |= CV_FLOW;
1628 dcd->flWindowAttr |= CV_FLOW;
1629 if (WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR))
1630 cnri.flWindowAttr &= (~CA_CONTAINERTITLE);
1631 else
1632 cnri.flWindowAttr |= CA_CONTAINERTITLE;
1633 if (!dcd->sortFlags)
1634 dcd->sortFlags = sortFlags;
1635 WinSendMsg(hwnd,
1636 CM_SETCNRINFO,
1637 MPFROMP(&cnri),
1638 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1639 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1640 SetCnrCols(hwnd, FALSE);
1641 if (xbeginthread(MakeObjWin,
1642 245760,
1643 dcd,
1644 pszSrcFile,
1645 __LINE__) == -1)
1646 {
1647 Runtime_Error(pszSrcFile, __LINE__,
1648 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1649 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1650 return 0;
1651 }
1652 else
1653 DosSleep(32); //05 Aug 07 GKY 64
1654 WinEnableMenuItem(DirCnrMenu, IDM_FINDINTREE, (hwndTree != (HWND) 0));
1655 }
1656 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1657 }
1658 else {
1659 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1660 return 0;
1661 }
1662 return 0;
1663
1664 case UM_SETUP2:
1665 if (dcd) {
1666 AdjustCnrColsForPref(hwnd, NULL, &dcd->ds, FALSE);
1667 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1668 DIR_FILTER), &dcd->mask, FALSE);
1669 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1670 DIR_SORT), dcd->sortFlags, FALSE);
1671 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1672 DIR_VIEW), dcd->flWindowAttr);
1673 } else
1674 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1675 return 0;
1676
1677 case WM_MENUEND:
1678 if (dcd) {
1679
1680 HWND hwndMenu = (HWND) mp2;
1681
1682 if (hwndMenu == DirCnrMenu ||
1683 hwndMenu == FileMenu ||
1684 hwndMenu == DirMenu) {
1685 MarkAll(hwnd, TRUE, FALSE, TRUE);
1686 if (dcd->cnremphasized) {
1687 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1688 MPFROM2SHORT(FALSE, CRA_SOURCE));
1689 dcd->cnremphasized = FALSE;
1690 }
1691 }
1692 }
1693 break;
1694
1695 case UM_OPENWINDOWFORME:
1696 if (dcd) {
1697 if (mp1 && !IsFile((CHAR *)mp1)) {
1698 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
1699 }
1700 else if (mp1 && IsFile(mp1) == 1 &&
1701 CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2) {
1702 StartArcCnr(HWND_DESKTOP,
1703 dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
1704 }
1705 }
1706 return 0;
1707
1708 case MM_PORTHOLEINIT:
1709 if (dcd) {
1710 switch (SHORT1FROMMP(mp1)) {
1711 case 0:
1712 case 1:
1713 {
1714 ULONG wmsg;
1715
1716 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1717 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
1718 wmsg, MPVOID, MPVOID), mp1, mp2);
1719 }
1720 break;
1721 }
1722 }
1723 break;
1724
1725 case UM_INITMENU:
1726 case WM_INITMENU:
1727 if (dcd) {
1728 switch (SHORT1FROMMP(mp1)) {
1729 case IDM_FILESMENU:
1730 CopyPresParams((HWND) mp2, hwndMainMenu);
1731 if (isalpha(*dcd->directory)) {
1732 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
1733 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, FALSE);
1734 WinEnableMenuItem((HWND) mp2, IDM_RENAME, FALSE);
1735 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1736 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, FALSE);
1737 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, FALSE);
1738 WinEnableMenuItem((HWND) mp2, IDM_DELETE, FALSE);
1739 WinEnableMenuItem((HWND) mp2, IDM_EDIT, FALSE);
1740 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, FALSE);
1741 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, FALSE);
1742 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, FALSE);
1743 }
1744 else {
1745 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, TRUE);
1746 WinEnableMenuItem((HWND) mp2, IDM_RENAME, TRUE);
1747 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1748 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, TRUE);
1749 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, TRUE);
1750 WinEnableMenuItem((HWND) mp2, IDM_DELETE, TRUE);
1751 WinEnableMenuItem((HWND) mp2, IDM_EDIT, TRUE);
1752 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, TRUE);
1753 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, TRUE);
1754 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
1755 }
1756 }
1757 break;
1758
1759 case IDM_VIEWSMENU:
1760 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1761 CopyPresParams((HWND) mp2, hwndMainMenu);
1762 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1763 (dcd->lastselection != NULL));
1764 if (isalpha(*dcd->directory)) {
1765 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE)
1766 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1767 else
1768 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1769 }
1770 WinEnableMenuItem((HWND) mp2,
1771 IDM_SELECTCOMPAREMENU,
1772 (CountDirCnrs(dcd->hwndParent) > 1));
1773 break;
1774
1775 case IDM_DETAILSSETUP:
1776 SetDetailsSwitches((HWND) mp2, &dcd->ds);
1777 break;
1778
1779 case IDM_COMMANDSMENU:
1780 SetupCommandMenu((HWND) mp2, hwnd);
1781 break;
1782
1783 case IDM_SORTSUBMENU:
1784 SetSortChecks((HWND) mp2, dcd->sortFlags);
1785 break;
1786
1787 case IDM_WINDOWSMENU:
1788 SetupWinList((HWND) mp2,
1789 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
1790 break;
1791 }
1792 dcd->hwndLastMenu = (HWND) mp2;
1793 }
1794 if (msg == WM_INITMENU)
1795 break;
1796 return 0;
1797
1798 case UM_FILTER:
1799 if (dcd) {
1800
1801 PCNRITEM pci;
1802
1803 if (mp1) {
1804 //DosEnterCritSec(); // GKY 11-30-08 moved to SetMask
1805 SetMask((CHAR *)mp1, &dcd->mask);
1806 //DosExitCritSec();
1807 }
1808 dcd->suspendview = 1;
1809 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1810 dcd->suspendview = 0;
1811 if (fAutoView && hwndMain) {
1812 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1813 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1814 if (pci && (INT) pci != -1 &&
1815 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1816 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1817 else
1818 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1819 }
1820 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1821 }
1822 return 0;
1823
1824 case UM_COMMAND:
1825 if (mp1) {
1826 if (dcd) {
1827 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1828 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
1829 FreeListInfo((LISTINFO *) mp1);
1830 }
1831 else
1832 return (MRESULT) TRUE;
1833 }
1834 else
1835 FreeListInfo((LISTINFO *) mp1);
1836 }
1837 return 0;
1838
1839 case UM_NOTIFY:
1840 if (mp2)
1841 Notify((CHAR *)mp2);
1842 return 0;
1843
1844 case UM_DRIVECMD:
1845 if (mp1)
1846 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0), mp1);
1847 return 0;
1848
1849 case WM_COMMAND:
1850 DosError(FERR_DISABLEHARDERR);
1851 if (dcd) {
1852 switch (SHORT1FROMMP(mp1)) {
1853 case IDM_SETTARGET:
1854 SetTargetDir(hwnd, FALSE);
1855 break;
1856
1857 case IDM_CREATE:
1858 {
1859 STRINGINPARMS sip;
1860 CHAR filename[CCHMAXPATHCOMP];
1861
1862 memset(&sip, 0, sizeof(sip));
1863 sip.help = GetPString(IDS_CREATETEXT);
1864 sip.prompt = GetPString(IDS_CREATEPROMPTTEXT);
1865 sip.inputlen = CCHMAXPATHCOMP - (strlen(dcd->directory) - 1);
1866 strcpy(filename, "NEWFILE.TXT");
1867 sip.ret = filename;
1868 sip.title = GetPString(IDS_CREATETITLETEXT);
1869 if (WinDlgBox(HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle,
1870 STR_FRAME, &sip)) {
1871 bstrip(sip.ret);
1872 if (*sip.ret) {
1873 CHAR newfile[CCHMAXPATH];
1874 FILE *fp;
1875 INT test;
1876 PCNRITEM pci;
1877
1878 strcpy(newfile, dcd->directory);
1879 if (newfile[strlen(newfile) - 1] != '\\')
1880 strcat(newfile, "\\");
1881 strcat(newfile, sip.ret);
1882 test = IsFile(newfile);
1883 if (test != 1)
1884 fp = fopen(newfile, "w");
1885 if (test != 1 && !fp) {
1886 saymsg(MB_ENTER,
1887 hwnd,
1888 GetPString(IDS_ERRORTEXT),
1889 GetPString(IDS_CREATEERRORTEXT), newfile);
1890 }
1891 else {
1892 if (fp) {
1893 WinSendMsg(hwnd, UM_UPDATERECORD, MPFROMP(newfile), MPVOID);
1894 fclose(fp);
1895 }
1896 if (*editor) {
1897
1898 CHAR *dummy[2];
1899
1900 dummy[0] = newfile;
1901 dummy[1] = NULL;
1902 ExecOnList(hwnd,
1903 editor, WINDOWED | SEPARATE, NULL, dummy, NULL,
1904 pszSrcFile, __LINE__);
1905 }
1906 else
1907 StartMLEEditor(dcd->hwndParent, 4, newfile, dcd->hwndFrame);
1908 pci = FindCnrRecord(hwnd, newfile, NULL, TRUE, FALSE, TRUE);
1909 if (pci && (INT) pci != -1)
1910 /* make sure that record shows in viewport */
1911 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1912 }
1913 }
1914 }
1915 }
1916 break;
1917
1918 case IDM_CONTEXTMENU:
1919 {
1920 PCNRITEM pci;
1921
1922 pci = (PCNRITEM) CurrentRecord(hwnd);
1923 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
1924 MPFROMP(pci));
1925 }
1926 break;
1927
1928 case IDM_MAXIMIZE:
1929 PostMsg(hwndMain, UM_MAXIMIZE, MPFROMLONG(dcd->hwndFrame), MPVOID);
1930 break;
1931
1932 case IDM_SHOWALLFILESCNR:
1933 StartSeeAll(HWND_DESKTOP, FALSE, dcd->directory);
1934 break;
1935
1936 case IDM_SHOWALLFILES:
1937 {
1938 PCNRITEM pci;
1939
1940 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1941 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1942 if (pci && (INT) pci != -1) {
1943
1944 static CHAR dirname[CCHMAXPATH];
1945
1946 strcpy(dirname, pci->pszFileName);
1947 MakeValidDir(dirname);
1948 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1949 }
1950 }
1951 break;
1952
1953 case IDM_FINDINTREE:
1954 if (hwndTree) {
1955 PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
1956
1957 if (pszTempDir) {
1958 if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir),
1959 MPFROMLONG(1L)))
1960 free(pszTempDir);
1961 }
1962 }
1963 break;
1964
1965 case IDM_BEGINEDIT:
1966 OpenEdit(hwnd);
1967 break;
1968
1969 case IDM_ENDEDIT:
1970 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1971 break;
1972
1973 case IDM_SHOWSELECT:
1974 QuickPopup(hwnd,
1975 dcd,
1976 CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP), IDM_SELECTSUBMENU);
1977 break;
1978
1979 case IDM_SHOWSORT:
1980 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP),
1981 IDM_SORTSUBMENU);
1982 break;
1983
1984 case IDM_VIEWORARC:
1985 {
1986 SWP swp;
1987 PCNRITEM pci;
1988
1989 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1990 MPFROMLONG(CMA_FIRST),
1991 MPFROMSHORT(CRA_CURSORED));
1992 if (pci && (INT) pci != -1) {
1993 WinQueryWindowPos(dcd->hwndFrame, &swp);
1994 DefaultViewKeys(hwnd,
1995 dcd->hwndFrame,
1996 dcd->hwndParent, &swp, pci->pszFileName);
1997 }
1998 }
1999 break;
2000
2001 case IDM_DIRCNRSETTINGS:
2002 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
2003 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_DIRCNRSETTINGS), mp2);
2004 else {
2005 WinDlgBox(HWND_DESKTOP,
2006 hwnd,
2007 CfgDlgProc,
2008 FM3ModHandle,
2009 CFG_FRAME,
2010 MPFROMLONG(IDM_DIRCNRSETTINGS));
2011 }
2012 break;
2013
2014 case IDM_QTREE:
2015 case IDM_TREE:
2016 {
2017 CHAR newpath[CCHMAXPATH];
2018 APIRET rc;
2019 PCNRITEM pci;
2020
2021 if (SHORT1FROMMP(mp1) == IDM_TREE) {
2022 pci = (PCNRITEM) CurrentRecord(hwnd);
2023 if (pci && (INT) pci != -1)
2024 strcpy(newpath, pci->pszFileName);
2025 else
2026 strcpy(newpath, dcd->directory);
2027 }
2028 else
2029 strcpy(newpath, dcd->directory);
2030 MakeValidDir(newpath);
2031 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ObjCnrDlgProc,
2032 FM3ModHandle, QTREE_FRAME, MPFROMP(newpath));
2033 if (rc)
2034 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(newpath), MPVOID);
2035 }
2036 break;
2037
2038 case IDM_RESELECT:
2039 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
2040 break;
2041
2042 case IDM_HELP:
2043 if (hwndHelp) {
2044 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2045 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
2046 else
2047 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
2048 }
2049 break;
2050
2051 case IDM_WINDOWDLG:
2052 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2053 PostMsg(dcd->hwndParent, UM_COMMAND,
2054 MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
2055 break;
2056
2057 case IDM_SORTSMARTNAME:
2058 case IDM_SORTNAME:
2059 case IDM_SORTFILENAME:
2060 case IDM_SORTSIZE:
2061 case IDM_SORTEASIZE:
2062 case IDM_SORTFIRST:
2063 case IDM_SORTLAST:
2064 case IDM_SORTLWDATE:
2065 case IDM_SORTLADATE:
2066 case IDM_SORTCRDATE:
2067 case IDM_SORTSUBJECT:
2068 dcd->sortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
2069 case IDM_SORTDIRSFIRST:
2070 case IDM_SORTDIRSLAST:
2071 case IDM_SORTREVERSE:
2072 switch (SHORT1FROMMP(mp1)) {
2073 case IDM_SORTSUBJECT:
2074 dcd->sortFlags |= SORT_SUBJECT;
2075 break;
2076 case IDM_SORTSMARTNAME:
2077 case IDM_SORTFILENAME:
2078 dcd->sortFlags |= SORT_FILENAME;
2079 break;
2080 case IDM_SORTSIZE:
2081 dcd->sortFlags |= SORT_SIZE;
2082 break;
2083 case IDM_SORTEASIZE:
2084 dcd->sortFlags |= SORT_EASIZE;
2085 break;
2086 case IDM_SORTFIRST:
2087 dcd->sortFlags |= SORT_FIRSTEXTENSION;
2088 break;
2089 case IDM_SORTLAST:
2090 dcd->sortFlags |= SORT_LASTEXTENSION;
2091 break;
2092 case IDM_SORTLWDATE:
2093 dcd->sortFlags |= SORT_LWDATE;
2094 break;
2095 case IDM_SORTLADATE:
2096 dcd->sortFlags |= SORT_LADATE;
2097 break;
2098 case IDM_SORTCRDATE:
2099 dcd->sortFlags |= SORT_CRDATE;
2100 break;
2101 case IDM_SORTDIRSFIRST:
2102 if (dcd->sortFlags & SORT_DIRSFIRST)
2103 dcd->sortFlags &= (~SORT_DIRSFIRST);
2104 else {
2105 dcd->sortFlags |= SORT_DIRSFIRST;
2106 dcd->sortFlags &= (~SORT_DIRSLAST);
2107 }
2108 break;
2109 case IDM_SORTDIRSLAST:
2110 if (dcd->sortFlags & SORT_DIRSLAST)
2111 dcd->sortFlags &= (~SORT_DIRSLAST);
2112 else {
2113 dcd->sortFlags |= SORT_DIRSLAST;
2114 dcd->sortFlags &= (~SORT_DIRSFIRST);
2115 }
2116 break;
2117 case IDM_SORTREVERSE:
2118 if (dcd->sortFlags & SORT_REVERSE)
2119 dcd->sortFlags &= (~SORT_REVERSE);
2120 else
2121 dcd->sortFlags |= SORT_REVERSE;
2122 break;
2123 }
2124 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortDirCnr),
2125 MPFROMLONG(dcd->sortFlags));
2126 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2127 DIR_SORT), dcd->sortFlags, FALSE);
2128 break;
2129
2130 case IDM_COLLECT:
2131 case IDM_GREP:
2132 if (!Collector) {
2133
2134 HWND hwndC;
2135 SWP swp;
2136
2137 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2138 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2139 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2140 hwndC = StartCollector((fExternalCollector ||
2141 strcmp(realappname, FM3Str)) ?
2142 HWND_DESKTOP : dcd->hwndParent, 4);
2143 if (hwndC) {
2144 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2145 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2146 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2147 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2148 SWP_SHOW | SWP_ZORDER);
2149 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) && fAutoTile &&
2150 !strcmp(realappname, FM3Str))
2151 TileChildren(dcd->hwndParent, TRUE);
2152 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
2153 DosSleep(100); //05 Aug 07 GKY 250
2154 }
2155 }
2156 else
2157 StartCollector(dcd->hwndParent, 4);
2158 if (SHORT1FROMMP(mp1) == IDM_GREP) {
2159 PCNRITEM pci = NULL;
2160
2161 pci = WinSendMsg(hwnd,
2162 CM_QUERYRECORDEMPHASIS,
2163 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
2164 if (pci && (INT) pci != -1)
2165 PostMsg(Collector, WM_COMMAND,
2166 MPFROM2SHORT(IDM_GREP, 0), MPFROMP(pci->pszFileName));
2167 else
2168 PostMsg(Collector, WM_COMMAND,
2169 MPFROM2SHORT(IDM_GREP, 0), MPVOID);
2170 }
2171 else
2172 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2173 break;
2174
2175 case IDM_COLLECTOR:
2176 DosSleep(32); //05 Aug 07 GKY 64
2177 {
2178 CHAR **list;
2179
2180 list = BuildList(hwnd);
2181 if (list) {
2182 if (Collector) {
2183 if (!PostMsg(Collector,
2184 WM_COMMAND,
2185 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2186 FreeList(list);
2187 else if (fUnHilite)
2188 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2189 }
2190 else
2191 FreeList(list);
2192 }
2193 }
2194 break;
2195
2196 case IDM_UNDELETE:
2197 {
2198 PCNRITEM pci;
2199 CHAR path[CCHMAXPATH];
2200 HOBJECT hObject;
2201 HWND hwndDesktop;
2202
2203 hObject = WinQueryObject("<XWP_TRASHCAN>");
2204 if (hObject != NULLHANDLE && fTrashCan) {
2205 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
2206 WinSetFocus(HWND_DESKTOP, hwndDesktop);
2207 WinOpenObject(hObject, 0, TRUE);
2208 }
2209 else {
2210 pci = (PCNRITEM) CurrentRecord(hwnd);
2211 if (pci && (INT) pci != -1) {
2212 strcpy(path, pci->pszFileName);
2213 MakeValidDir(path);
2214 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2215 UNDEL_FRAME, MPFROMP(path));
2216 }
2217 }
2218 }
2219 break;
2220
2221 case IDM_UNDELETESPEC:
2222 {
2223 HOBJECT hObject;
2224 HWND hwndDesktop;
2225
2226 hObject = WinQueryObject("<XWP_TRASHCAN>");
2227 if (hObject != NULLHANDLE && fTrashCan) {
2228 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
2229 WinSetFocus(HWND_DESKTOP, hwndDesktop);
2230 WinOpenObject(hObject, 0, TRUE);
2231 }
2232 else
2233 WinDlgBox(HWND_DESKTOP,
2234 hwnd,
2235 UndeleteDlgProc,
2236 FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
2237 }
2238 break;
2239
2240 case IDM_RESORT:
2241// WinSendMsg(hwnd,
2242// CM_SORTRECORD,
2243// MPFROMP(SortDirCnr),
2244// MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
2245 WinSendMsg(hwnd,
2246 CM_SORTRECORD,
2247 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
2248 break;
2249
2250 case IDM_FILTER:
2251 {
2252 BOOL empty = FALSE;
2253 PCNRITEM pci;
2254 CHAR *p;
2255
2256 if (!*dcd->mask.szMask) {
2257 empty = TRUE;
2258 pci = (PCNRITEM) CurrentRecord(hwnd);
2259 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
2260 p = strrchr(pci->pszFileName, '\\');
2261 if (p) {
2262 p++;
2263 strcpy(dcd->mask.szMask, p);
2264 }
2265 }
2266 }
2267 *(dcd->mask.prompt) = 0;
2268
2269 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2270 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2271 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2272 else if (empty)
2273 *dcd->mask.szMask = 0;
2274 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2275 DIR_FILTER), &dcd->mask, FALSE);
2276 }
2277 break;
2278
2279 case IDM_UNHIDEALL:
2280 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2281 break;
2282
2283 case IDM_HIDEALL:
2284 if (fAutoView && hwndMain)
2285 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2286 dcd->suspendview = 1;
2287 HideAll(hwnd);
2288 dcd->suspendview = 0;
2289 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2290 break;
2291
2292 case IDM_SELECTBOTH:
2293 case IDM_SELECTONE:
2294 case IDM_SELECTMORE:
2295 case IDM_SELECTNEWER:
2296 case IDM_SELECTOLDER:
2297 case IDM_SELECTBIGGER:
2298 case IDM_SELECTSMALLER:
2299 case IDM_DESELECTBOTH:
2300 case IDM_DESELECTONE:
2301 case IDM_DESELECTMORE:
2302 case IDM_DESELECTNEWER:
2303 case IDM_DESELECTOLDER:
2304 case IDM_DESELECTBIGGER:
2305 case IDM_DESELECTSMALLER:
2306 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2307 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2308 break;
2309 }
2310 case IDM_SELECTLIST:
2311 case IDM_SELECTALL:
2312 case IDM_DESELECTALL:
2313 case IDM_SELECTALLFILES:
2314 case IDM_DESELECTALLFILES:
2315 case IDM_SELECTALLDIRS:
2316 case IDM_DESELECTALLDIRS:
2317 case IDM_SELECTMASK:
2318 case IDM_DESELECTMASK:
2319 case IDM_INVERT:
2320 case IDM_SELECTCLIP:
2321 case IDM_DESELECTCLIP:
2322 {
2323 PCNRITEM pci;
2324
2325 pci = (PCNRITEM) CurrentRecord(hwnd);
2326 if ((INT) pci == -1)
2327 pci = NULL;
2328 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2329 if (pci) {
2330 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2331 pci->rc.flRecordAttr |= CRA_FILTERED;
2332 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2333 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2334 break;
2335 }
2336 }
2337 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2338 }
2339 break;
2340
2341 case IDM_RESCAN:
2342 //DosEnterCritSec(); //GKY 11-27-08
2343 dcd->stopflag++;
2344 //DosExitCritSec();
2345 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2346 //DosEnterCritSec(); //GKY 11-27-08
2347 dcd->stopflag--;
2348 //DosExitCritSec();
2349 }
2350 break;
2351
2352 case IDM_SHOWLNAMES:
2353 case IDM_SHOWSUBJECT:
2354 case IDM_SHOWEAS:
2355 case IDM_SHOWSIZE:
2356 case IDM_SHOWICON:
2357 case IDM_SHOWLWDATE:
2358 case IDM_SHOWLWTIME:
2359 case IDM_SHOWLADATE:
2360 case IDM_SHOWLATIME:
2361 case IDM_SHOWCRDATE:
2362 case IDM_SHOWCRTIME:
2363 case IDM_SHOWATTR:
2364 AdjustDetailsSwitches(hwnd,
2365 dcd->hwndLastMenu,
2366 SHORT1FROMMP(mp1),
2367 dcd->directory, NULL, &dcd->ds, FALSE);
2368 break;
2369
2370 case IDM_TREEVIEW:
2371 case IDM_ICON:
2372 case IDM_TEXT:
2373 case IDM_DETAILS:
2374 case IDM_NAME:
2375 case IDM_MINIICONS:
2376 case IDM_DETAILSTITLES:
2377 {
2378 CNRINFO cnri;
2379
2380 memset(&cnri, 0, sizeof(CNRINFO));
2381 cnri.cb = sizeof(CNRINFO);
2382 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2383 MPFROMLONG(sizeof(CNRINFO)));
2384 switch (SHORT1FROMMP(mp1)) {
2385 case IDM_TREEVIEW:
2386 if (!(cnri.flWindowAttr & CV_TREE))
2387 dcd->lastattr = cnri.flWindowAttr;
2388 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2389 CV_DETAIL | CV_NAME | CA_TREELINE));
2390 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2391 if (!dcd->firsttree)
2392 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2393 break;
2394 case IDM_ICON:
2395 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2396 CV_DETAIL | CV_NAME | CA_TREELINE));
2397 cnri.flWindowAttr |= CV_ICON;
2398 break;
2399 case IDM_NAME:
2400 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2401 CV_DETAIL | CV_NAME | CA_TREELINE));
2402 cnri.flWindowAttr |= CV_NAME;
2403 break;
2404 case IDM_TEXT:
2405 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2406 CV_DETAIL | CV_NAME | CA_TREELINE));
2407 cnri.flWindowAttr |= CV_TEXT;
2408 break;
2409 case IDM_DETAILS:
2410 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2411 CV_DETAIL | CV_NAME | CA_TREELINE));
2412 cnri.flWindowAttr |= CV_DETAIL;
2413 break;
2414 case IDM_MINIICONS:
2415 if (cnri.flWindowAttr & CV_MINI)
2416 cnri.flWindowAttr &= (~CV_MINI);
2417 else
2418 cnri.flWindowAttr |= CV_MINI;
2419 break;
2420 case IDM_DETAILSTITLES:
2421 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2422 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2423 else
2424 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2425 break;
2426 }
2427 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2428 cnri.flWindowAttr |= CV_FLOW;
2429 dcd->flWindowAttr = cnri.flWindowAttr;
2430 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2431 MPFROMLONG(CMA_FLWINDOWATTR));
2432 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2433 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2434 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2435 DIR_VIEW), dcd->flWindowAttr);
2436 }
2437 break;
2438
2439 case IDM_SAVETOLIST:
2440 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2441 SAV_FRAME, MPFROMP(&hwnd));
2442 break;
2443
2444 case IDM_SIZES:
2445 {
2446 PCNRITEM pci;
2447 CHAR path[CCHMAXPATH];
2448
2449 pci = (PCNRITEM) CurrentRecord(hwnd);
2450 if (pci && (INT) pci != -1)
2451 strcpy(path, pci->pszFileName);
2452 else
2453 strcpy(path, dcd->directory);
2454 MakeValidDir(path);
2455 WinDlgBox(HWND_DESKTOP,
2456 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2457 }
2458 break;
2459
2460 case IDM_MKDIR:
2461 {
2462 PCNRITEM pci;
2463 BOOL saved;
2464
2465 saved = fSelectedAlways;
2466 fSelectedAlways = FALSE;
2467 pci = (PCNRITEM)CurrentRecord(hwnd);
2468 // 01 Oct 07 SHL Make below selected directory or in current directory
2469 PMMkDir(dcd->hwndParent,
2470 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2471 FALSE);
2472 fSelectedAlways = saved;
2473 }
2474 break;
2475
2476 case IDM_SWITCH:
2477 if (mp2) {
2478 strcpy(dcd->previous, dcd->directory);
2479 strcpy(dcd->directory, (CHAR *)mp2);
2480 //DosEnterCritSec(); // GKY 11-27-08
2481 dcd->stopflag++;
2482 //DosExitCritSec();
2483 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2484 strcpy(dcd->directory, dcd->previous);
2485 //DosEnterCritSec(); // GKY 11-27-08
2486 dcd->stopflag--;
2487 //DosExitCritSec();
2488 }
2489 else if (*dcd->directory) {
2490 if (hwndMain)
2491 WinSendMsg(hwndMain,
2492 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2493 else
2494 add_udir(FALSE, dcd->directory);
2495 }
2496 }
2497 break;
2498
2499 case IDM_PARENT:
2500 {
2501 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
2502
2503 strcpy(tempname1, dcd->directory);
2504 if (tempname1[strlen(tempname1) - 1] != '\\')
2505 strcat(tempname1, "\\");
2506 strcat(tempname1, "..");
2507 DosError(FERR_DISABLEHARDERR);
2508 if (!DosQueryPathInfo(tempname1,
2509 FIL_QUERYFULLNAME,
2510 tempname2, sizeof(tempname2))) {
2511 if (stricmp(dcd->directory, tempname2)) {
2512 strcpy(dcd->previous, dcd->directory);
2513 strcpy(dcd->directory, tempname2);
2514 //DosEnterCritSec(); // GKY 11-27-08
2515 dcd->stopflag++;
2516 //DosExitCritSec();
2517 if (!PostMsg(dcd->hwndObject,
2518 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2519 strcpy(dcd->directory, dcd->previous);
2520 //DosEnterCritSec();// GKY 11-27-08
2521 dcd->stopflag--;
2522 //DosExitCritSec();
2523 }
2524 else if (*dcd->directory) {
2525 if (hwndMain)
2526 WinSendMsg(hwndMain,
2527 UM_SETUSERLISTNAME,
2528 MPFROMP(dcd->directory), MPVOID);
2529 else
2530 add_udir(FALSE, dcd->directory);
2531 }
2532 }
2533 }
2534 }
2535 break;
2536
2537 case IDM_PREVIOUS:
2538 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
2539
2540 CHAR tempname[CCHMAXPATH];
2541
2542 if (IsValidDir(dcd->previous)) {
2543 strcpy(tempname, dcd->directory);
2544 strcpy(dcd->directory, dcd->previous);
2545 strcpy(dcd->previous, tempname);
2546 //DosEnterCritSec(); // GKY 11-27-08
2547 dcd->stopflag++;
2548 //DosExitCritSec();
2549 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2550 strcpy(dcd->directory, dcd->previous);
2551 //DosEnterCritSec(); // GKY 11-27-08
2552 dcd->stopflag--;
2553 //DosExitCritSec();
2554 }
2555 else if (*dcd->directory) {
2556 if (hwndMain)
2557 WinSendMsg(hwndMain,
2558 UM_SETUSERLISTNAME,
2559 MPFROMP(dcd->directory), MPVOID);
2560 else
2561 add_udir(FALSE, dcd->directory);
2562 }
2563 }
2564 else
2565 *dcd->previous = 0;
2566 }
2567 break;
2568
2569 case IDM_WALKDIR:
2570 {
2571 CHAR newdir[CCHMAXPATH];
2572
2573 strcpy(newdir, dcd->directory);
2574 if (!WinDlgBox(HWND_DESKTOP,
2575 dcd->hwndParent,
2576 WalkAllDlgProc,
2577 FM3ModHandle,
2578 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2579 break;
2580 if (stricmp(newdir, dcd->directory)) {
2581 strcpy(dcd->previous, dcd->directory);
2582 strcpy(dcd->directory, newdir);
2583 //DosEnterCritSec(); //GKY 11-27-08
2584 dcd->stopflag++;
2585 //DosExitCritSec();
2586 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2587 strcpy(dcd->directory, dcd->previous);
2588 //DosEnterCritSec(); // GKY 11-27-08
2589 dcd->stopflag--;
2590 //DosExitCritSec();
2591 }
2592 else if (*dcd->directory) {
2593 if (hwndMain)
2594 WinSendMsg(hwndMain,
2595 UM_SETUSERLISTNAME,
2596 MPFROMP(dcd->directory), MPVOID);
2597 else
2598 add_udir(FALSE, dcd->directory);
2599 }
2600 }
2601 }
2602 break;
2603
2604 case IDM_OPENICONME:
2605 OpenObject(dcd->directory, PCSZ_ICON, dcd->hwndFrame);
2606 break;
2607 case IDM_OPENDETAILSME:
2608 OpenObject(dcd->directory, Details, dcd->hwndFrame);
2609 break;
2610 case IDM_OPENTREEME:
2611 OpenObject(dcd->directory, PCSZ_TREE, dcd->hwndFrame);
2612 break;
2613 case IDM_OPENSETTINGSME:
2614 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2615 break;
2616
2617 case IDM_DOITYOURSELF:
2618 case IDM_UPDATE:
2619 case IDM_OPENWINDOW:
2620 case IDM_OPENSETTINGS:
2621 case IDM_OPENDEFAULT:
2622 case IDM_OPENICON:
2623 case IDM_OPENDETAILS:
2624 case IDM_OPENTREE:
2625 case IDM_OBJECT:
2626 case IDM_SHADOW:
2627 case IDM_SHADOW2:
2628 case IDM_DELETE:
2629 case IDM_PERMDELETE:
2630 case IDM_PRINT:
2631 case IDM_ATTRS:
2632 case IDM_INFO:
2633 case IDM_COPY:
2634 case IDM_MOVE:
2635 case IDM_WPSMOVE:
2636 case IDM_WPSCOPY:
2637 case IDM_WILDCOPY:
2638 case IDM_WILDMOVE:
2639 case IDM_RENAME:
2640 case IDM_COMPARE:
2641 case IDM_EAS:
2642 case IDM_SUBJECT:
2643 case IDM_VIEW:
2644 case IDM_VIEWTEXT:
2645 case IDM_VIEWBINARY:
2646 case IDM_VIEWARCHIVE:
2647 case IDM_EDIT:
2648 case IDM_EDITTEXT:
2649 case IDM_EDITBINARY:
2650 case IDM_SAVETOCLIP:
2651 case IDM_SAVETOCLIPFILENAME:
2652 case IDM_APPENDTOCLIP:
2653 case IDM_APPENDTOCLIPFILENAME:
2654 case IDM_ARCHIVE:
2655 case IDM_ARCHIVEM:
2656 case IDM_EXTRACT:
2657 case IDM_MCIPLAY:
2658 case IDM_COLLECTFROMFILE:
2659 case IDM_UUDECODE:
2660 case IDM_MERGE:
2661 {
2662 LISTINFO *li;
2663 ULONG action = UM_ACTION;
2664 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2665 if (li) {
2666 li->type = SHORT1FROMMP(mp1);
2667 li->hwnd = hwnd;
2668 li->list = BuildList(hwnd);
2669 switch (SHORT1FROMMP(mp1)) {
2670 case IDM_WILDMOVE:
2671 case IDM_WILDCOPY:
2672 case IDM_MOVE:
2673 case IDM_COPY:
2674 case IDM_WPSMOVE:
2675 case IDM_WPSCOPY:
2676 break;
2677 default:
2678 strcpy(li->targetpath, dcd->directory);
2679 break;
2680 }
2681 if (li->list) {
2682 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2683 if (!Collector) {
2684
2685 HWND hwndC;
2686 SWP swp;
2687
2688 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2689 !fAutoTile &&
2690 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2691 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2692 hwndC = StartCollector((fExternalCollector ||
2693 strcmp(realappname, FM3Str)) ?
2694 HWND_DESKTOP : dcd->hwndParent, 4);
2695 if (hwndC) {
2696 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2697 !fAutoTile && (!fExternalCollector &&
2698 !strcmp(realappname, FM3Str)))
2699 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2700 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2701 SWP_SHOW | SWP_ZORDER);
2702 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2703 fAutoTile && !strcmp(realappname, FM3Str))
2704 TileChildren(dcd->hwndParent, TRUE);
2705 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2706 SWP_ACTIVATE);
2707 DosSleep(100); //05 Aug 07 GKY 250
2708 }
2709 }
2710 else
2711 StartCollector(dcd->hwndParent, 4);
2712 }
2713 switch (SHORT1FROMMP(mp1)) {
2714 case IDM_APPENDTOCLIP:
2715 case IDM_APPENDTOCLIPFILENAME:
2716 case IDM_SAVETOCLIP:
2717 case IDM_SAVETOCLIPFILENAME:
2718 case IDM_ARCHIVE:
2719 case IDM_ARCHIVEM:
2720 case IDM_DELETE:
2721 case IDM_PERMDELETE:
2722 case IDM_ATTRS:
2723 case IDM_PRINT:
2724 case IDM_SHADOW:
2725 case IDM_SHADOW2:
2726 case IDM_OBJECT:
2727 case IDM_VIEW:
2728 case IDM_VIEWTEXT:
2729 case IDM_VIEWBINARY:
2730 case IDM_EDIT:
2731 case IDM_EDITTEXT:
2732 case IDM_EDITBINARY:
2733 case IDM_MCIPLAY:
2734 case IDM_UPDATE:
2735 case IDM_DOITYOURSELF:
2736 case IDM_INFO:
2737 case IDM_EAS:
2738 action = UM_MASSACTION;
2739 break;
2740 }
2741 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2742 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2743 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2744 *li->targetpath = 0;
2745 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2746 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2747 FreeListInfo(li);
2748 }
2749 else if (fUnHilite)
2750 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2751 }
2752 else
2753 free(li);
2754 }
2755 }
2756 break;
2757
2758 case IDM_DRIVESMENU:
2759 if (!hwndMain)
2760 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2761 break;
2762
2763 default:
2764 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2765 return 0;
2766 else {
2767 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2768 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2769
2770 register INT x;
2771
2772 if (!cmdloaded)
2773 load_commands();
2774 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2775 if (x >= 0) {
2776 x++;
2777 RunCommand(hwnd, x);
2778 if (fUnHilite)
2779 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2780 }
2781 }
2782 }
2783 break;
2784 }
2785 }
2786 return 0;
2787
2788 case UM_FIXCNRMLE:
2789 case UM_FIXEDITNAME:
2790 return CommonCnrProc(hwnd, msg, mp1, mp2);
2791
2792 case UM_FILESMENU:
2793 {
2794 PCNRITEM pci;
2795 HWND menuHwnd = (HWND) 0;
2796
2797 pci = (PCNRITEM) CurrentRecord(hwnd);
2798 if (pci && (INT) pci != -1) {
2799 if (pci->attrFile & FILE_DIRECTORY) {
2800 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2801// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2802 }
2803 else
2804 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2805 }
2806 return MRFROMLONG(menuHwnd);
2807 }
2808
2809 case WM_CONTROL:
2810 DosError(FERR_DISABLEHARDERR);
2811 if (dcd) {
2812 switch (SHORT2FROMMP(mp1)) {
2813 case CN_COLLAPSETREE:
2814 case CN_EXPANDTREE:
2815 {
2816 PCNRITEM pci = (PCNRITEM) mp2;
2817
2818 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
2819 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
2820 struct
2821 {
2822 ULONG serial;
2823 CHAR volumelength;
2824 CHAR volumelabel[CCHMAXPATH];
2825 }
2826 volser;
2827 APIRET rc;
2828
2829 memset(&volser, 0, sizeof(volser));
2830 DosError(FERR_DISABLEHARDERR);
2831 // fixme?
2832 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2833 FSIL_VOLSER, &volser, sizeof(volser));
2834 if (rc) {
2835 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2836 GetPString(IDS_CANTFINDDIRTEXT),
2837 pci->pszFileName);
2838 if (!fErrorBeepOff)
2839 DosBeep(250,100);
2840 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2841 UnFlesh(hwnd, pci);
2842 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2843 }
2844 else {
2845 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2846 !volser.serial ||
2847 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2848 volser.serial)
2849 UnFlesh(hwnd, pci);
2850 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2851 (!volser.serial ||
2852 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2853 volser.serial)) {
2854 if (Flesh(hwnd, pci) &&
2855 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2856 !dcd->suspendview && fTopDir)
2857 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2858 }
2859 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2860 }
2861 }
2862 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2863 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
2864 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2865 }
2866 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2867 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2868 }
2869 }
2870 break;
2871
2872/*
2873 case CN_PICKUP:
2874 return PickUp(hwnd,dcd->hwndObject,mp2);
2875*/
2876
2877 case CN_CONTEXTMENU:
2878 {
2879 PCNRITEM pci = (PCNRITEM) mp2;
2880
2881 if (pci) {
2882 WinSendMsg(hwnd,
2883 CM_SETRECORDEMPHASIS,
2884 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2885 MarkAll(hwnd, FALSE, FALSE, TRUE);
2886 if (pci->attrFile & FILE_DIRECTORY)
2887 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2888 else
2889 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2890 }
2891 else {
2892 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
2893 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2894 WinSendMsg(hwnd,
2895 CM_SETRECORDEMPHASIS,
2896 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2897 dcd->cnremphasized = TRUE;
2898 }
2899 }
2900 if (dcd->hwndLastMenu) {
2901 if (dcd->hwndLastMenu == DirCnrMenu) {
2902 if (dcd->flWindowAttr & CV_MINI)
2903 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2904 }
2905 if (dcd->hwndLastMenu == DirMenu)
2906 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2907 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2908 if (dcd->cnremphasized) {
2909 WinSendMsg(hwnd,
2910 CM_SETRECORDEMPHASIS,
2911 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2912 dcd->cnremphasized = TRUE;
2913 }
2914 MarkAll(hwnd, TRUE, FALSE, TRUE);
2915 }
2916 }
2917 }
2918 break;
2919
2920 case CN_DROPHELP:
2921 if (mp2) {
2922
2923 PDRAGINFO pDInfo;
2924 PCNRITEM pci;
2925 ULONG numitems;
2926 USHORT usOperation;
2927
2928 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2929 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2930 if (!DrgAccessDraginfo(pDInfo)) {
2931 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2932 GetPString(IDS_DROPERRORTEXT));
2933 }
2934 else {
2935 numitems = DrgQueryDragitemCount(pDInfo);
2936 usOperation = pDInfo->usOperation;
2937 if (usOperation == DO_DEFAULT)
2938 usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
2939 FreeDragInfoData(hwnd, pDInfo);
2940 saymsg(MB_ENTER | MB_ICONASTERISK,
2941 hwnd,
2942 GetPString(IDS_DROPHELPHDRTEXT),
2943 GetPString(IDS_DROPHELPTEXT),
2944 numitems,
2945 &"s"[numitems == 1L],
2946 pci ? NullStr : GetPString(IDS_NOTEXT),
2947 pci ? NullStr : " ",
2948 pci ? pci->pszFileName : NullStr,
2949 pci ? " " : NullStr,
2950 GetPString((usOperation == DO_MOVE) ?
2951 IDS_MOVETEXT :
2952 (usOperation == DO_LINK) ?
2953 IDS_LINKTEXT : IDS_COPYTEXT));
2954 }
2955 }
2956 return 0;
2957
2958 case CN_DRAGLEAVE:
2959 return 0;
2960
2961 case CN_DRAGAFTER:
2962 case CN_DRAGOVER:
2963 if (mp2) {
2964
2965 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2966 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2967 PCNRITEM pci;
2968 USHORT uso;
2969
2970 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2971 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2972 if (!DrgAccessDraginfo(pDInfo)) {
2973 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2974 PCSZ_DRGACCESSDRAGINFO);
2975 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2976 }
2977 if (*dcd->directory &&
2978 (driveflags[toupper(*dcd->directory) - 'A'] &
2979 DRIVE_NOTWRITEABLE)) {
2980 DrgFreeDraginfo(pDInfo);
2981 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
2982 DO_LINK); /* (compare) only */
2983 }
2984 if (pci) {
2985 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2986 DrgFreeDraginfo(pDInfo);
2987 return (MRFROM2SHORT(DOR_NODROP, 0));
2988 }
2989 uso = pDInfo->usOperation;
2990 if (uso == DO_DEFAULT)
2991 uso = fCopyDefault ? DO_COPY : DO_MOVE;
2992 if (!(pci->attrFile & FILE_DIRECTORY)) {
2993 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2994 DrgFreeDraginfo(pDInfo);
2995 return MRFROM2SHORT(DOR_NODROP, 0);
2996 }
2997 if (uso != DO_LINK &&
2998 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2999 DRIVE_NOTWRITEABLE)) {
3000
3001 ARC_TYPE *info = NULL;
3002
3003 if (!fQuickArcFind &&
3004 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
3005 DRIVE_SLOW))
3006 info = find_type(pci->pszFileName, NULL);
3007 else
3008 info = quick_find_type(pci->pszFileName, NULL);
3009 if (!info || ((uso == DO_MOVE && !info->move) ||
3010 (uso == DO_COPY && !info->create))) {
3011 DrgFreeDraginfo(pDInfo);
3012 return MRFROM2SHORT(DOR_NODROP, 0);
3013 }
3014 }
3015 }
3016 }
3017
3018 /* Access DRAGITEM index to DRAGITEM
3019 * Check valid rendering mechanisms and data
3020 */
3021 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
3022 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL) ||
3023 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
3024 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) {
3025 DrgFreeDraginfo(pDInfo);
3026 if (driveflags[toupper(*dcd->directory) - 'A'] &
3027 DRIVE_NOTWRITEABLE)
3028 return MRFROM2SHORT(DOR_DROP, DO_LINK);
3029 if (toupper(*dcd->directory) < 'C')
3030 return MRFROM2SHORT(DOR_DROP, DO_COPY);
3031 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
3032 ((fCopyDefault) ? DO_COPY : DO_MOVE));
3033 }
3034 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
3035 }
3036 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
3037
3038 case CN_INITDRAG:
3039 {
3040 BOOL wasemphasized = FALSE;
3041 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
3042 PCNRITEM pci;
3043
3044 if (pcd) {
3045 pci = (PCNRITEM) pcd->pRecord;
3046 if (pci) {
3047 if ((INT) pci == -1)
3048 pci = NULL;
3049 else if (pci->rc.flRecordAttr & CRA_SELECTED)
3050 wasemphasized = TRUE;
3051 }
3052 else if (!*dcd->directory) {
3053 Runtime_Error(pszSrcFile, __LINE__, NULL);
3054 break;
3055 }
3056 else if (IsRoot(dcd->directory)) {
3057 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
3058 GetPString(IDS_CANTDRAGROOTDIR));
3059 break;
3060 }
3061 if (hwndStatus2) {
3062 if (pci)
3063 WinSetWindowText(hwndStatus2,
3064 GetPString(IDS_DRAGFILEOBJTEXT));
3065 else
3066 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGDIRTEXT));
3067 }
3068 if (DoFileDrag(hwnd,
3069 dcd->hwndObject,
3070 mp2,
3071 NULL,
3072 pci ? NULL : dcd->directory,
3073 pci ? TRUE : FALSE)) {
3074 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
3075 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
3076 }
3077 }
3078 if (hwndStatus2) {
3079 WinSetFocus(HWND_DESKTOP, hwnd);
3080 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3081 }
3082 }
3083 }
3084 return 0;
3085
3086 case CN_DROP:
3087 if (mp2) {
3088
3089 LISTINFO *li;
3090 ULONG action = UM_ACTION;
3091
3092 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
3093 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
3094 if (li) {
3095 if (li->list && li->list[0] && IsRoot(li->list[0]))
3096 li->type = DO_LINK;
3097 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
3098
3099 CHECKLIST cl;
3100
3101 memset(&cl, 0, sizeof(cl));
3102 cl.size = sizeof(cl);
3103 cl.flags = li->type;
3104 cl.list = li->list;
3105 cl.cmd = li->type;
3106 cl.prompt = li->targetpath;
3107 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
3108 DropListProc, FM3ModHandle,
3109 DND_FRAME, MPFROMP(&cl));
3110 if (li->type == DID_ERROR)
3111 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
3112 GetPString(IDS_DRAGDROPDIALOGTEXT));
3113 if (!li->type) {
3114 FreeListInfo(li);
3115 return 0;
3116 }
3117 li->list = cl.list;
3118 if (!li->list || !li->list[0]) {
3119 FreeListInfo(li);
3120 return 0;
3121 }
3122 }
3123 switch (li->type) {
3124 case DND_LAUNCH:
3125 strcat(li->targetpath, " %a");
3126 ExecOnList(dcd->hwndParent, li->targetpath,
3127 PROMPT | WINDOWED, NULL, li->list, NULL,
3128 pszSrcFile, __LINE__);
3129 FreeList(li->list);
3130 li->list = NULL;
3131 break;
3132 case DO_LINK:
3133 if (fLinkSetsIcon) {
3134 li->type = IDM_SETICON;
3135 action = UM_MASSACTION;
3136 }
3137 else
3138 li->type = IDM_COMPARE;
3139 break;
3140 case DND_EXTRACT:
3141 if (*li->targetpath && !IsFile(li->targetpath))
3142 li->type = IDM_EXTRACT;
3143 break;
3144 case DND_MOVE:
3145 li->type = IDM_MOVE;
3146 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3147 action = UM_MASSACTION;
3148 li->type = IDM_ARCHIVEM;
3149 }
3150 break;
3151 case DND_WILDMOVE:
3152 li->type = IDM_WILDMOVE;
3153 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3154 action = UM_MASSACTION;
3155 li->type = IDM_ARCHIVEM;
3156 }
3157 break;
3158 case DND_OBJECT:
3159 li->type = IDM_OBJECT;
3160 action = UM_MASSACTION;
3161 break;
3162 case DND_SHADOW:
3163 li->type = IDM_SHADOW;
3164 action = UM_MASSACTION;
3165 break;
3166 case DND_COMPARE:
3167 li->type = IDM_COMPARE;
3168 break;
3169 case DND_SETICON:
3170 action = UM_MASSACTION;
3171 li->type = IDM_SETICON;
3172 break;
3173 case DND_COPY:
3174 li->type = IDM_COPY;
3175 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3176 action = UM_MASSACTION;
3177 li->type = IDM_ARCHIVE;
3178 }
3179 break;
3180 case DND_WILDCOPY:
3181 li->type = IDM_WILDCOPY;
3182 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3183 action = UM_MASSACTION;
3184 li->type = IDM_ARCHIVE;
3185 }
3186 break;
3187 default:
3188 if (*li->arcname && li->info) {
3189 action = UM_MASSACTION;
3190 li->type =
3191 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
3192 }
3193 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
3194 action = UM_MASSACTION;
3195 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
3196 }
3197 else
3198 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
3199 break;
3200 }
3201 if (!li->list || !li->list[0])
3202 FreeListInfo(li);
3203 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
3204 FreeListInfo(li);
3205 else {
3206
3207 USHORT usop = 0;
3208
3209 switch (li->type) {
3210 case IDM_COPY:
3211 case IDM_WILDCOPY:
3212 usop = DO_COPY;
3213 break;
3214 case IDM_MOVE:
3215 case IDM_WILDMOVE:
3216 case IDM_ARCHIVEM:
3217 usop = DO_MOVE;
3218 break;
3219 }
3220 if (usop)
3221 return MRFROM2SHORT(DOR_DROP, usop);
3222 }
3223 }
3224 }
3225 return 0;
3226
3227 case CN_ENDEDIT:
3228 case CN_BEGINEDIT:
3229 {
3230 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3231 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3232
3233 if (pfi || pci) {
3234
3235 MRESULT mre;
3236
3237 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3238 if (mre != (MRESULT) - 1)
3239 return mre;
3240 }
3241 else if (!pfi && !pci)
3242 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3243 }
3244 return 0;
3245
3246 case CN_REALLOCPSZ:
3247 {
3248 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3249 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3250 HWND hwndMLE;
3251 static CHAR szData[CCHMAXPATH];
3252 CHAR testname[CCHMAXPATH];
3253
3254 if (!pci && !pfi) {
3255 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3256 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
3257 chop_at_crnl(szData);
3258 bstrip(szData);
3259 if (*szData) {
3260 if (!DosQueryPathInfo(szData,
3261 FIL_QUERYFULLNAME,
3262 testname, sizeof(testname))) {
3263 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3264 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3265 }
3266 }
3267 }
3268 }
3269 else {
3270
3271 MRESULT mre;
3272
3273 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3274 if (mre != (MRESULT) - 1)
3275 return mre;
3276 }
3277 }
3278 return 0;
3279
3280 case CN_EMPHASIS:
3281 if (!mp2)
3282 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3283 else {
3284 PNOTIFYRECORDEMPHASIS pre = mp2;
3285 PCNRITEM pci;
3286 CHAR s[CCHMAXPATHCOMP + 91], tb[81], tf[81];
3287
3288 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
3289 if (!pci) {
3290 if (hwndStatus2)
3291 WinSetWindowText(hwndStatus2, NullStr);
3292 if (fMoreButtons) {
3293 WinSetWindowText(hwndName, NullStr);
3294 WinSetWindowText(hwndDate, NullStr);
3295 WinSetWindowText(hwndAttr, NullStr);
3296 }
3297 if (hwndMain)
3298 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3299 break;
3300 }
3301 if (pre->fEmphasisMask & CRA_SELECTED) {
3302 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3303 dcd->selectedbytes += (pci->cbFile + pci->easize);
3304 dcd->selectedfiles++;
3305 }
3306 else if (dcd->selectedfiles) {
3307 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3308 dcd->selectedfiles--;
3309 }
3310 if (!dcd->suspendview) {
3311 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3312 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3313 sprintf(s, "%s / %s", tf, tb);
3314 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3315 }
3316 }
3317 if (!dcd->suspendview && hwndMain &&
3318 (pre->fEmphasisMask & CRA_CURSORED) &&
3319 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3320 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3321 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
3322 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3323 else
3324 WinSendMsg(hwndMain,
3325 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
3326 }
3327 if (!dcd->suspendview &&
3328 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3329 if (pre->fEmphasisMask & CRA_CURSORED) {
3330 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3331 if (fSplitStatus && hwndStatus2) {
3332 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3333 if (!fMoreButtons) {
3334 CHAR date[11];
3335
3336 DateFormat(date, pci->date);
3337 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
3338 tb, date, pci->time.hours, TimeSeparator,
3339 pci->time.minutes, TimeSeparator, pci->time.seconds,
3340 pci->pszDispAttr, pci->pszFileName);
3341 }
3342 else {
3343 *tf = 0;
3344 if (pci->cbFile + pci->easize > 1024) {
3345 CommaFmtULL(tf, sizeof(tf),
3346 pci->cbFile + pci->easize, 'K');
3347 }
3348 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3349 tb,
3350 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3351 }
3352 WinSetWindowText(hwndStatus2, s);
3353 }
3354 if (fMoreButtons) {
3355 CHAR szDate[DATE_BUF_BYTES];
3356
3357 WinSetWindowText(hwndName, pci->pszFileName);
3358 DateFormat(szDate, pci->date);
3359 sprintf(s, "%s %02u%s%02u%s%02u",
3360 szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
3361 TimeSeparator, pci->time.seconds);
3362 WinSetWindowText(hwndDate, s);
3363 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3364 }
3365 }
3366 }
3367 }
3368 }
3369 break;
3370
3371 case CN_ENTER:
3372 if (mp2) {
3373
3374 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3375 FILEFINDBUF3 ffb;
3376 HDIR hDir = HDIR_CREATE;
3377 ULONG nm = 1;
3378 APIRET status = 0;
3379
3380 SetShiftState();
3381 if (pci) {
3382 if (pci->rc.flRecordAttr & CRA_INUSE)
3383 break;
3384 DosError(FERR_DISABLEHARDERR);
3385 status = DosFindFirst(pci->pszFileName,
3386 &hDir,
3387 FILE_NORMAL | FILE_DIRECTORY |
3388 FILE_ARCHIVED | FILE_READONLY |
3389 FILE_HIDDEN | FILE_SYSTEM,
3390 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
3391 priority_bumped();
3392 if (!status) {
3393 DosFindClose(hDir);
3394 if (ffb.attrFile & FILE_DIRECTORY) {
3395 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3396 PostMsg(hwnd,
3397 WM_COMMAND,
3398 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3399 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3400 (KC_CTRL | KC_SHIFT))
3401 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
3402 else if (shiftstate & KC_CTRL)
3403 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
3404 else if (shiftstate & KC_SHIFT) {
3405
3406 HWND hwndDir;
3407
3408 hwndDir = OpenDirCnr((HWND) 0,
3409 dcd->hwndParent,
3410 dcd->hwndFrame,
3411 FALSE, pci->pszFileName);
3412 if (hwndDir) {
3413 if (fMinOnOpen)
3414 WinSetWindowPos(dcd->hwndFrame,
3415 HWND_BOTTOM,
3416 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3417 if (fAutoTile)
3418 TileChildren(dcd->hwndParent, TRUE);
3419 WinSetWindowPos(hwndDir,
3420 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3421 }
3422 }
3423 else {
3424 strcpy(dcd->previous, dcd->directory);
3425 strcpy(dcd->directory, pci->pszFileName);
3426 //DosEnterCritSec(); // GKY 11-27-08
3427 dcd->stopflag++;
3428 //DosExitCritSec();
3429 if (!PostMsg(dcd->hwndObject,
3430 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
3431 //DosEnterCritSec(); // GKY 11-27-08
3432 dcd->stopflag--;
3433 //DosExitCritSec();
3434 }
3435 else if (*dcd->directory) {
3436 if (hwndMain)
3437 WinSendMsg(hwndMain,
3438 UM_SETUSERLISTNAME,
3439 MPFROMP(dcd->directory), MPVOID);
3440 else
3441 add_udir(FALSE, dcd->directory);
3442 }
3443 }
3444 }
3445 else {
3446
3447 SWP swp;
3448
3449 WinQueryWindowPos(dcd->hwndFrame, &swp);
3450 WinSendMsg(hwnd,
3451 CM_SETRECORDEMPHASIS,
3452 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3453 DefaultViewKeys(hwnd,
3454 dcd->hwndFrame,
3455 dcd->hwndParent, &swp, pci->pszFileName);
3456 WinSendMsg(hwnd,
3457 CM_SETRECORDEMPHASIS,
3458 MPFROMP(pci),
3459 MPFROM2SHORT(FALSE,
3460 CRA_INUSE |
3461 ((fUnHilite) ? CRA_SELECTED : 0)));
3462 }
3463 }
3464 else {
3465 if (!*dcd->directory || IsValidDir(dcd->directory)) {
3466 NotifyError(pci->pszFileName, status);
3467 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
3468 if (hwndStatus)
3469 WinSetWindowText(hwndStatus,
3470 GetPString(IDS_RESCANSUGGESTEDTEXT));
3471 }
3472 else {
3473 //DosEnterCritSec(); // GKY 11-27-08
3474 dcd->stopflag++;
3475 //DosExitCritSec();
3476 if (!PostMsg(dcd->hwndObject,
3477 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3478 //DosEnterCritSec(); // GKY 11-27-08
3479 dcd->stopflag--;
3480 //DosExitCritSec();
3481 }
3482 else if (*dcd->directory) {
3483 if (hwndMain)
3484 WinSendMsg(hwndMain,
3485 UM_SETUSERLISTNAME,
3486 MPFROMP(dcd->directory), MPVOID);
3487 else
3488 add_udir(FALSE, dcd->directory);
3489 }
3490 }
3491 }
3492 }
3493 else if (*dcd->directory)
3494 OpenObject(dcd->directory, Default, hwnd);
3495 } // CN_ENTER
3496 break;
3497 } // switch mp1
3498 break;
3499 } // if dcd
3500 return 0;
3501
3502 case UM_LOADFILE:
3503 if (dcd && mp2) {
3504
3505 HWND hwnd;
3506
3507 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
3508 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
3509 (CHAR *)mp2, dcd->hwndFrame);
3510 else
3511 hwnd = StartMLEEditor(dcd->hwndParent,
3512 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
3513 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
3514 return MRFROMLONG(hwnd);
3515 }
3516 return 0;
3517
3518 case WM_SAVEAPPLICATION:
3519 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3520
3521 SWP swp;
3522
3523 WinQueryWindowPos(dcd->hwndFrame, &swp);
3524 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3525 PrfWriteProfileData(fmprof,
3526 appname, "VDirSizePos", &swp, sizeof(swp));
3527 }
3528 break;
3529
3530 case WM_CLOSE:
3531 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3532 if (LastDir == hwnd)
3533 LastDir = (HWND) 0;
3534 if (dcd) {
3535 dcd->stopflag++;
3536 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3537 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3538 if (dcd->hwndObject) {
3539 // Ensure object window destroy does not attempt duplicate clean up
3540 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3541 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3542 Win_Error(dcd->hwndObject, hwnd, pszSrcFile, __LINE__, "hwndObject WinPostMsg failed");
3543 }
3544 if (dcd->hwndRestore)
3545 WinSetWindowPos(dcd->hwndRestore,
3546 HWND_TOP,
3547 0,
3548 0,
3549 0,
3550 0,
3551 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3552 FreeList(dcd->lastselection);
3553 free(dcd);
3554 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3555 DosPostEventSem(CompactSem);
3556 }
3557 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3558 QW_PARENT));
3559 return 0;
3560
3561 case WM_DESTROY:
3562# ifdef FORTIFY
3563 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
3564# endif
3565 if (DirMenu)
3566 WinDestroyWindow(DirMenu);
3567 if (DirCnrMenu)
3568 WinDestroyWindow(DirCnrMenu);
3569 if (FileMenu)
3570 WinDestroyWindow(FileMenu);
3571 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3572 EmptyCnr(hwnd);
3573# ifdef FORTIFY
3574 Fortify_LeaveScope();
3575# endif
3576 break;
3577 } // switch
3578
3579 if (dcd && dcd->oldproc) {
3580 // 11 May 08 SHL fixme debug fortify
3581 if ((ULONG)dcd->oldproc == 0xa9a9a9a9)
3582 DbgMsg(pszSrcFile, __LINE__, "calling oldproc after dcd free msg %x mp1 %x mp2 %x", msg, mp1, mp2);
3583 return dcd->oldproc(hwnd, msg, mp1, mp2);
3584 }
3585 else
3586 return PFNWPCnr(hwnd, msg, mp1, mp2);
3587}
3588
3589HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3590 ULONG flags)
3591{
3592 /* bitmapped flags:
3593 * 0x00000001 = don't close app when window closes
3594 * 0x00000002 = no frame controls
3595 */
3596
3597 HWND hwndFrame = (HWND) 0, hwndClient;
3598 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3599 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3600 USHORT id;
3601 static USHORT idinc = 0;
3602 DIRCNRDATA *dcd;
3603 static BOOL first = FALSE;
3604
3605 if (flags & 2)
3606 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3607 FCF_MINMAX | FCF_ICON));
3608 if (!idinc)
3609 idinc = (rand() % 100);
3610 if (!hwndParent)
3611 hwndParent = HWND_DESKTOP;
3612 if (ParentIsDesktop(hwndParent, hwndParent))
3613 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3614 if (!hwndMain && !first) {
3615 if (DirCnrMenu) {
3616 MENUITEM mi;
3617 memset(&mi, 0, sizeof(mi));
3618 WinSendMsg(DirCnrMenu,
3619 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
3620 mi.iPosition = MIT_END;
3621 mi.afStyle = MIS_TEXT;
3622 mi.id = IDM_DRIVESMENU;
3623 WinSendMsg(DirCnrMenu,
3624 MM_INSERTITEM,
3625 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3626 }
3627 first = TRUE;
3628 }
3629 if (directory) {
3630 hwndFrame = WinCreateStdWindow(hwndParent,
3631 WS_VISIBLE,
3632 &FrameFlags,
3633 WC_DIRCONTAINER,
3634 NULL,
3635 WS_VISIBLE | fwsAnimate,
3636 FM3ModHandle, DIR_FRAME, &hwndClient);
3637 if (hwndFrame && hwndClient) {
3638 id = DIR_FRAME + idinc++;
3639 if (idinc > 99)
3640 idinc = 0;
3641 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3642# ifdef FORTIFY
3643 Fortify_EnterScope();
3644# endif
3645 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3646 if (!dcd) {
3647 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3648 hwndFrame = (HWND) 0;
3649 }
3650 else {
3651 dcd->size = sizeof(DIRCNRDATA);
3652 dcd->id = id;
3653 dcd->type = DIR_FRAME;
3654 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3655 dcd->hwndFrame = hwndFrame;
3656 dcd->hwndClient = hwndClient;
3657 dcd->hwndRestore = hwndRestore;
3658 dcd->dontclose = ((flags & 1) != 0);
3659 dcd->ds.detailslongname = dsDirCnrDefault.detailslongname;
3660 dcd->ds.detailssubject = dsDirCnrDefault.detailssubject;
3661 dcd->ds.detailsea = dsDirCnrDefault.detailsea;
3662 dcd->ds.detailssize = dsDirCnrDefault.detailssize;
3663 dcd->ds.detailsicon = dsDirCnrDefault.detailsicon;
3664 dcd->ds.detailsattr = dsDirCnrDefault.detailsattr;
3665 dcd->ds.detailscrdate = dsDirCnrDefault.detailscrdate;
3666 dcd->ds.detailscrtime = dsDirCnrDefault.detailscrtime;
3667 dcd->ds.detailslwdate = dsDirCnrDefault.detailslwdate;
3668 dcd->ds.detailslwtime = dsDirCnrDefault.detailslwtime;
3669 dcd->ds.detailsladate = dsDirCnrDefault.detailsladate;
3670 dcd->ds.detailslatime = dsDirCnrDefault.detailslatime;
3671 strcpy(dcd->directory, directory);
3672 add_udir(FALSE, directory);
3673 {
3674 PFNWP oldproc;
3675
3676 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3677 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3678 }
3679 dcd->hwndCnr = WinCreateWindow(hwndClient,
3680 WC_CONTAINER,
3681 NULL,
3682 CCS_AUTOPOSITION | CCS_MINIICONS |
3683 CCS_MINIRECORDCORE | ulCnrType, // |
3684 //WS_VISIBLE,
3685 0,
3686 0,
3687 0,
3688 0,
3689 hwndClient,
3690 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3691 if (!dcd->hwndCnr) {
3692 Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
3693 PCSZ_WINCREATEWINDOW);
3694 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3695 free(dcd);
3696 hwndFrame = (HWND) 0;
3697 }
3698 else {
3699# ifdef FORTIFY
3700 Fortify_ChangeScope(dcd, -1);
3701# endif
3702 RestorePresParams(dcd->hwndCnr, PCSZ_DIRCNR);
3703 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3704 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3705 (PFNWP) DirCnrWndProc);
3706 {
3707 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3708 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3709 };
3710
3711 if (!(flags & 2))
3712 ids[6] = 0;
3713 CommonCreateTextChildren(dcd->hwndClient,
3714 WC_DIRSTATUS, ids);
3715 }
3716 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3717 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3718 if (FrameFlags & FCF_TASKLIST) {
3719
3720 SWP swp, swpD;
3721 ULONG size = sizeof(swp);
3722 LONG cxScreen, cyScreen;
3723
3724 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3725 if (PrfQueryProfileData(fmprof,
3726 appname, "VDirSizePos", &swpD, &size)) {
3727 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3728 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3729 if (swp.x + swpD.cx > cxScreen)
3730 swp.x = cxScreen - swpD.cx;
3731 if (swp.y + swpD.cy > cyScreen)
3732 swp.y = cyScreen - swpD.cy;
3733 swp.cx = swpD.cx;
3734 swp.cy = swpD.cy;
3735 }
3736 WinSetWindowPos(hwndFrame,
3737 HWND_TOP,
3738 swp.x,
3739 swp.y,
3740 swp.cx,
3741 swp.cy,
3742 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3743 SWP_ACTIVATE);
3744 }
3745 WinShowWindow(dcd->hwndCnr, TRUE);
3746 }
3747 }
3748# ifdef FORTIFY
3749 Fortify_LeaveScope();
3750# endif
3751 }
3752 }
3753 return hwndFrame;
3754}
3755
3756#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3757#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3758#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.