source: trunk/dll/dircnrs.c@ 1785

Last change on this file since 1785 was 1778, checked in by Steven Levine, 11 years ago

Rework dircnrs.c DirObjWndProc UM_RESCAN to avoid hanging FM/2 Lite when
drive tree hidden. Also speeds up startup if Switch Tree on directory change
not enabled.

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