source: trunk/dll/dircnrs.c@ 1807

Last change on this file since 1807 was 1807, checked in by Gregg Young, 10 years ago

Version update to .def file etc for version 3.23

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