source: trunk/dll/dircnrs.c@ 1756

Last change on this file since 1756 was 1756, checked in by Gregg Young, 12 years ago

Speed up intial drive scans Ticket 528

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