| 1 |
|
|---|
| 2 | /***********************************************************************
|
|---|
| 3 |
|
|---|
| 4 | $Id: collect.c 1799 2015-03-16 22:26:04Z gyoung $
|
|---|
| 5 |
|
|---|
| 6 | Collector
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
|---|
| 9 | Copyright (c) 2003, 2012 Steven H. Levine
|
|---|
| 10 |
|
|---|
| 11 | 15 Oct 02 MK Baseline
|
|---|
| 12 | 10 Jan 04 SHL Avoid -1L byte counts
|
|---|
| 13 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
|---|
| 14 | 23 May 05 SHL Use QWL_USER
|
|---|
| 15 | 24 May 05 SHL Rework Win_Error usage
|
|---|
| 16 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL
|
|---|
| 17 | 25 May 05 SHL Rework for FillInRecordFromFFB
|
|---|
| 18 | 05 Jun 05 SHL Use QWL_USER
|
|---|
| 19 | 06 Jun 05 SHL Indent -i2
|
|---|
| 20 | 06 Jun 05 SHL Make savedSortFlags static to avoid referencing garbage
|
|---|
| 21 | 24 Oct 05 SHL Sanitize handle references
|
|---|
| 22 | 24 Oct 05 SHL CollectorCnrWndProc: avoid excess writes to Status2 window
|
|---|
| 23 | 10 Nov 05 SHL CollectorCnrWndProc: correct missing button window updates
|
|---|
| 24 | 14 Jul 06 SHL Use Runtime_Error
|
|---|
| 25 | 27 Jul 06 SHL Avoid shutdown hang - pre3 typo
|
|---|
| 26 | 29 Jul 06 SHL Use xfgets_bstripcr
|
|---|
| 27 | 15 Aug 06 SHL Don't write garbage to CollectorFilter INI entry
|
|---|
| 28 | 15 Aug 06 SHL Rework SetMask args
|
|---|
| 29 | 18 Aug 06 SHL CollectorCnrWndProc: avoid freeing NULL pointer
|
|---|
| 30 | 31 Aug 06 SHL Disable Utilities->Seek and scan menu while busy
|
|---|
| 31 | 31 Aug 06 SHL Correct stop scan context menu enable/disable
|
|---|
| 32 | 30 Mar 07 GKY Remove GetPString for window class names
|
|---|
| 33 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
|
|---|
| 34 | 06 Apr 07 GKY Add some error checking in drag/drop
|
|---|
| 35 | 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checks.
|
|---|
| 36 | 12 May 07 SHL Use dcd->ulItemsToUnHilite
|
|---|
| 37 | 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
|
|---|
| 38 | 05 Jul 07 SHL CollectorCnrWndProc: just warn if busy
|
|---|
| 39 | 02 Aug 07 SHL Sync with CNRITEM mods
|
|---|
| 40 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
|---|
| 41 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
|---|
| 42 | 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
|
|---|
| 43 | 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
|
|---|
| 44 | 10 Jan 08 SHL Sync with CfgDlgProc mods
|
|---|
| 45 | 10 Feb 08 GKY Implement bubble help for bitmap menu items
|
|---|
| 46 | 15 Feb 08 SHL Sync with settings menu rework
|
|---|
| 47 | 15 Feb 08 GKY Fix attempt to free container items that were never inserted
|
|---|
| 48 | 15 Feb 08 GKY Fix "collect" so it updates recollected files and unhides them if needed
|
|---|
| 49 | 29 Feb 08 GKY Use xfree where appropriate
|
|---|
| 50 | 06 Jul 08 GKY Update delete/undelete to include move to and open XWP trashcan
|
|---|
| 51 | 11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
|
|---|
| 52 | all the details view settings (both the global variables and those in the
|
|---|
| 53 | DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
|
|---|
| 54 | 20 Jul 08 GKY Add save/append filename to clipboard.
|
|---|
| 55 | Change menu wording to make these easier to find
|
|---|
| 56 | 25 Aug 08 GKY Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if
|
|---|
| 57 | less than 10 KiB (It hangs and can't be closed)
|
|---|
| 58 | 10 Dec 08 SHL Integrate exception handler support
|
|---|
| 59 | 26 Dec 08 GKY Fixed DROPHELP to check for copy as default is action is DO_DEFAULT
|
|---|
| 60 | 01 Jan 09 GKY Add Seek and Scan to drives & directory context menus pass drive/dir as search root
|
|---|
| 61 | 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error
|
|---|
| 62 | 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
|
|---|
| 63 | 07 Feb 09 GKY Add *DateFormat functions to format dates based on locale
|
|---|
| 64 | 07 Feb 09 GKY Move repeated strings to PCSZs.
|
|---|
| 65 | 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
|
|---|
| 66 | 08 Mar 09 GKY Additional strings move to PCSZs in init.c
|
|---|
| 67 | 06 Jun 09 GKY Add option to show file system type or drive label in tree
|
|---|
| 68 | 12 Jul 09 GKY Add szFSType to FillInRecordFromFSA use to bypass EA scan and size formatting
|
|---|
| 69 | for tree container
|
|---|
| 70 | 13 Jul 09 GKY Fixed double free of memory buffer in UM_COLLECTFROMFILE
|
|---|
| 71 | 15 Sep 09 SHL Use UM_GREP when passing pathname
|
|---|
| 72 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
|
|---|
| 73 | 23 Oct 10 GKY Add menu items for opening directory cnrs based on path of selected item
|
|---|
| 74 | including the option to use walk directories to select path
|
|---|
| 75 | 28 May 11 GKY Fixed trap caused by passing a nonexistant pci to FillInRecordFromFFB in
|
|---|
| 76 | UM_COLLECT because pci is limited to 65535 files. (nRecord is a USHORT)
|
|---|
| 77 | 29 May 11 SHL Rework UM_COLLECT >65K records logic to not require double loop
|
|---|
| 78 | 29 May 11 SHL Tweak UM_COLLECT to bypass FindCnrRecord when container initially empty
|
|---|
| 79 | 08 Aug 11 SHL Rework UM_COLLECT to avoid spurious container items free
|
|---|
| 80 | 13 Aug 11 GKY Have file count and KIBs update at the same time
|
|---|
| 81 | 04 Aug 12 GKY Changes to use Unlock to unlock files if Unlock.exe is in path both from menu and as part of copy, move and
|
|---|
| 82 | delete operations
|
|---|
| 83 | 05 Sep 12 SHL Correct UM_COLLECTFROMFILE bad list file reporting
|
|---|
| 84 | 13 Dec 13 SHL CollectorCnrWndProc IDM_FILTER: avoid exception on missing fileName
|
|---|
| 85 | 22 Feb 14 GKY Fix warn readonly yes don't ask to work when recursing directories.
|
|---|
| 86 | 16 Mar 15 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
|
|---|
| 87 | a trap when FM2 is shutdown or the container is closed while collector
|
|---|
| 88 | container is still populating
|
|---|
| 89 |
|
|---|
| 90 | ***********************************************************************/
|
|---|
| 91 |
|
|---|
| 92 | #include <stdlib.h>
|
|---|
| 93 | #include <string.h>
|
|---|
| 94 | #include <ctype.h>
|
|---|
| 95 | #include <share.h>
|
|---|
| 96 | #include <limits.h> // USHRT_MAX
|
|---|
| 97 | // #include <process.h> // _beginthread
|
|---|
| 98 |
|
|---|
| 99 | #define INCL_DOS // QSV_MS_COUNT
|
|---|
| 100 | #define INCL_WIN
|
|---|
| 101 | #define INCL_DOSERRORS
|
|---|
| 102 | #define INCL_LONGLONG
|
|---|
| 103 |
|
|---|
| 104 | #include "fm3dll.h"
|
|---|
| 105 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
|---|
| 106 | #include "dircnrs.h" // Data declaration(s)
|
|---|
| 107 | #include "info.h" // Data declaration(s)
|
|---|
| 108 | #include "init.h" // Data declaration(s)
|
|---|
| 109 | #include "fm3dlg.h"
|
|---|
| 110 | #include "fm3str.h"
|
|---|
| 111 | #include "mle.h"
|
|---|
| 112 | #include "grep.h"
|
|---|
| 113 | #include "comp.h"
|
|---|
| 114 | #include "arccnrs.h" // StartArcCnr
|
|---|
| 115 | #include "filldir.h" // EmptyCnr...
|
|---|
| 116 | #include "strutil.h" // GetPString
|
|---|
| 117 | #include "errutil.h" // Runtime_Error
|
|---|
| 118 | #include "tmrsvcs.h" // ITIMER_DESC
|
|---|
| 119 | #include "notebook.h" // CfgDlgProc
|
|---|
| 120 | #include "command.h" // RunCommand
|
|---|
| 121 | #include "worker.h" // Action, MassAction
|
|---|
| 122 | #include "notify.h" // AddNote
|
|---|
| 123 | #include "misc.h" // AdjustCnrColsForPref, AdjustDetailsSwitches, CnrDirectEdit,
|
|---|
| 124 | // LoadDetailsSwitches, OpenEdit, QuickPopup, SayFilter
|
|---|
| 125 | // SaySort, SayView, SetCnrCols, SetDetailsSwitches
|
|---|
| 126 | // SetSortChecks, SetViewMenu, disable_menuitem, CheckMenu
|
|---|
| 127 | // CurrentRecord, DrawTargetEmphasis, IsFm2Window
|
|---|
| 128 | #include "chklist.h" // CenterOverWindow, DropListProc
|
|---|
| 129 | #include "collect.h"
|
|---|
| 130 | #include "common.h" // CommonCnrProc, CommonCreateTextChildren, CommonFrameWndProc
|
|---|
| 131 | // CommonTextPaint
|
|---|
| 132 | #include "select.h" // DeselectAll, HideAll, RemoveAll, SelectAll, SelectList
|
|---|
| 133 | #include "dirsize.h" // DirSizeProc
|
|---|
| 134 | #include "grep2.h" // GrepDlgProc
|
|---|
| 135 | #include "mainwnd.h" // MakeBubble
|
|---|
| 136 | #include "objwin.h" // MakeObjWin
|
|---|
| 137 | #include "saveclip.h" // SaveListDlgProc
|
|---|
| 138 | #include "findrec.h" // ShowCnrRecord
|
|---|
| 139 | #include "sortcnr.h" // SortCollectorCnr
|
|---|
| 140 | #include "seeall.h" // StartSeeAll
|
|---|
| 141 | #include "update.h" // UpdateCnrList, UpdateCnrRecord
|
|---|
| 142 | #include "droplist.h" // CheckPmDrgLimit
|
|---|
| 143 | #include "common.h" // CommonTextButton, CommonTextProc
|
|---|
| 144 | #include "presparm.h" // CopyPresParams
|
|---|
| 145 | #include "defview.h" // DefaultViewKeys
|
|---|
| 146 | #include "draglist.h" // DoFileDrag, FreeDragInfoData
|
|---|
| 147 | #include "systemf.h" // ExecOnList
|
|---|
| 148 | #include "filter.h" // Filter
|
|---|
| 149 | #include "findrec.h" // FindCnrRecord
|
|---|
| 150 | #include "shadow.h" // OpenObject
|
|---|
| 151 | #include "mkdir.h" // PMMkDir
|
|---|
| 152 | #include "valid.h" // ParentIsDesktop
|
|---|
| 153 | #include "viewer.h" // StartMLEEditor
|
|---|
| 154 | #include "newview.h" // StartViewer
|
|---|
| 155 | #include "undel.h" // UndeleteDlgProc
|
|---|
| 156 | #include "i18nutil.h" // commafmt
|
|---|
| 157 | #include "getnames.h" // insert_filename
|
|---|
| 158 | #include "select.h" // InvertAll
|
|---|
| 159 | #include "strips.h" // bstrip
|
|---|
| 160 | #include "wrappers.h" // xDosFindFirst
|
|---|
| 161 | #include "fortify.h"
|
|---|
| 162 | #include "excputil.h" // xbeginthread
|
|---|
| 163 | #include "walkem.h" // WalkAllDlgProc
|
|---|
| 164 | #include "copyf.h" // ignorereadonly
|
|---|
| 165 |
|
|---|
| 166 | // Data definitions
|
|---|
| 167 | #pragma data_seg(GLOBAL1)
|
|---|
| 168 | HWND CollectorCnrMenu;
|
|---|
| 169 | HWND hwndStatus2;
|
|---|
| 170 |
|
|---|
| 171 | #pragma data_seg(GLOBAL2)
|
|---|
| 172 | INT CollectorsortFlags;
|
|---|
| 173 |
|
|---|
| 174 | #pragma data_seg(DATA1)
|
|---|
| 175 | static PSZ pszSrcFile = __FILE__;
|
|---|
| 176 |
|
|---|
| 177 | MRESULT EXPENTRY CollectorFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 178 | MPARAM mp2)
|
|---|
| 179 | {
|
|---|
| 180 | return CommonFrameWndProc(COLLECTOR_CNR, hwnd, msg, mp1, mp2);
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | MRESULT EXPENTRY CollectorTextProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 184 | MPARAM mp2)
|
|---|
| 185 | {
|
|---|
| 186 | DIRCNRDATA *dcd;
|
|---|
| 187 |
|
|---|
| 188 | static BOOL emphasized = FALSE;
|
|---|
| 189 | static HWND hwndButtonPopup = (HWND) 0;
|
|---|
| 190 | static ULONG timestamp = ULONG_MAX;
|
|---|
| 191 | static USHORT lastid = 0;
|
|---|
| 192 |
|
|---|
| 193 | switch (msg) {
|
|---|
| 194 | case WM_CREATE:
|
|---|
| 195 | return CommonTextProc(hwnd, msg, mp1, mp2);
|
|---|
| 196 |
|
|---|
| 197 | case UM_CONTEXTMENU:
|
|---|
| 198 | case WM_CONTEXTMENU:
|
|---|
| 199 | {
|
|---|
| 200 | USHORT id;
|
|---|
| 201 |
|
|---|
| 202 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
|---|
| 203 | switch (id) {
|
|---|
| 204 | case DIR_SELECTED:
|
|---|
| 205 | case DIR_VIEW:
|
|---|
| 206 | case DIR_SORT:
|
|---|
| 207 | {
|
|---|
| 208 | POINTL ptl = { 0, 0 };
|
|---|
| 209 | SWP swp;
|
|---|
| 210 |
|
|---|
| 211 | if (hwndButtonPopup)
|
|---|
| 212 | WinDestroyWindow(hwndButtonPopup);
|
|---|
| 213 | if (id == lastid) {
|
|---|
| 214 | ULONG check;
|
|---|
| 215 |
|
|---|
| 216 | DosQuerySysInfo(QSV_MS_COUNT,
|
|---|
| 217 | QSV_MS_COUNT, &check, sizeof(check));
|
|---|
| 218 | if (check < timestamp + 500) {
|
|---|
| 219 | lastid = 0;
|
|---|
| 220 | goto MenuAbort;
|
|---|
| 221 | }
|
|---|
| 222 | }
|
|---|
| 223 | hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
|
|---|
| 224 | if (hwndButtonPopup) {
|
|---|
| 225 | WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
|
|---|
| 226 | dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
|
|---|
| 227 | QW_PARENT),
|
|---|
| 228 | COLLECTOR_CNR), QWL_USER);
|
|---|
| 229 | if (id == DIR_VIEW) {
|
|---|
| 230 | if (dcd) {
|
|---|
| 231 | SetViewMenu(hwndButtonPopup, dcd->flWindowAttr);
|
|---|
| 232 | SetDetailsSwitches(hwndButtonPopup, &dcd->ds);
|
|---|
| 233 | CopyPresParams(hwndButtonPopup, hwnd);
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | // don't have tree view in collector
|
|---|
| 237 | WinSendMsg(hwndButtonPopup,
|
|---|
| 238 | MM_DELETEITEM,
|
|---|
| 239 | MPFROM2SHORT(IDM_TREEVIEW, FALSE), MPVOID);
|
|---|
| 240 |
|
|---|
| 241 | }
|
|---|
| 242 | else if (id == DIR_SORT) {
|
|---|
| 243 | if (dcd)
|
|---|
| 244 | SetSortChecks(hwndButtonPopup, dcd->sortFlags);
|
|---|
| 245 | }
|
|---|
| 246 | ptl.x = 0;
|
|---|
| 247 | if (WinPopupMenu(HWND_OBJECT,
|
|---|
| 248 | HWND_OBJECT,
|
|---|
| 249 | hwndButtonPopup, -32767, -32767, 0, 0)) {
|
|---|
| 250 | WinQueryWindowPos(hwndButtonPopup, &swp);
|
|---|
| 251 | ptl.y = -(swp.cy + 2);
|
|---|
| 252 | }
|
|---|
| 253 | else {
|
|---|
| 254 | WinQueryWindowPos(hwnd, &swp);
|
|---|
| 255 | ptl.y = swp.cy + 2;
|
|---|
| 256 | }
|
|---|
| 257 | if (WinPopupMenu(hwnd,
|
|---|
| 258 | hwnd,
|
|---|
| 259 | hwndButtonPopup,
|
|---|
| 260 | ptl.x,
|
|---|
| 261 | ptl.y,
|
|---|
| 262 | 0,
|
|---|
| 263 | PU_HCONSTRAIN | PU_VCONSTRAIN |
|
|---|
| 264 | PU_KEYBOARD | PU_MOUSEBUTTON1)) {
|
|---|
| 265 | CenterOverWindow(hwndButtonPopup);
|
|---|
| 266 | PaintRecessedWindow(hwnd, NULLHANDLE, FALSE, FALSE);
|
|---|
| 267 | }
|
|---|
| 268 | }
|
|---|
| 269 | }
|
|---|
| 270 | break;
|
|---|
| 271 | default:
|
|---|
| 272 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 273 | COLLECTOR_CNR),
|
|---|
| 274 | WM_CONTROL,
|
|---|
| 275 | MPFROM2SHORT(COLLECTOR_CNR, CN_CONTEXTMENU), MPVOID);
|
|---|
| 276 | break;
|
|---|
| 277 | }
|
|---|
| 278 | }
|
|---|
| 279 | MenuAbort:
|
|---|
| 280 | if (msg == UM_CONTEXTMENU)
|
|---|
| 281 | return 0;
|
|---|
| 282 | break;
|
|---|
| 283 |
|
|---|
| 284 | case WM_MENUEND:
|
|---|
| 285 | if (hwndButtonPopup == (HWND) mp2) {
|
|---|
| 286 | lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
|
|---|
| 287 | WinDestroyWindow(hwndButtonPopup);
|
|---|
| 288 | hwndButtonPopup = (HWND) 0;
|
|---|
| 289 | DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, ×tamp,
|
|---|
| 290 | sizeof(timestamp));
|
|---|
| 291 | switch (lastid) {
|
|---|
| 292 | case DIR_SELECTED:
|
|---|
| 293 | case DIR_VIEW:
|
|---|
| 294 | case DIR_SORT:
|
|---|
| 295 | PaintRecessedWindow(hwnd, NULLHANDLE, TRUE, FALSE);
|
|---|
| 296 | break;
|
|---|
| 297 | }
|
|---|
| 298 | }
|
|---|
| 299 | break;
|
|---|
| 300 |
|
|---|
| 301 | case WM_COMMAND:
|
|---|
| 302 | {
|
|---|
| 303 | DIRCNRDATA *dcd;
|
|---|
| 304 | MRESULT mr;
|
|---|
| 305 |
|
|---|
| 306 | mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
|
|---|
| 307 | QW_PARENT),
|
|---|
| 308 | COLLECTOR_CNR), msg, mp1, mp2);
|
|---|
| 309 | if (hwndButtonPopup &&
|
|---|
| 310 | SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
|
|---|
| 311 | SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
|
|---|
| 312 | dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
|
|---|
| 313 | QW_PARENT),
|
|---|
| 314 | COLLECTOR_CNR), QWL_USER);
|
|---|
| 315 | if (dcd)
|
|---|
| 316 | SetDetailsSwitches(hwndButtonPopup, &dcd->ds);
|
|---|
| 317 | }
|
|---|
| 318 | return mr;
|
|---|
| 319 | }
|
|---|
| 320 |
|
|---|
| 321 | case WM_MOUSEMOVE:
|
|---|
| 322 | {
|
|---|
| 323 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
|---|
| 324 | PCSZ s = NULL;
|
|---|
| 325 |
|
|---|
| 326 | if (fOtherHelp) {
|
|---|
| 327 | if ((!hwndBubble ||
|
|---|
| 328 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
|
|---|
| 329 | !WinQueryCapture(HWND_DESKTOP)) {
|
|---|
| 330 | switch (id) {
|
|---|
| 331 | case DIR_SELECTED:
|
|---|
| 332 | s = GetPString(IDS_COLSELECTEDHELP);
|
|---|
| 333 | break;
|
|---|
| 334 | case DIR_TOTALS:
|
|---|
| 335 | s = GetPString(IDS_COLTOTALSHELP);
|
|---|
| 336 | break;
|
|---|
| 337 | case DIR_VIEW:
|
|---|
| 338 | s = GetPString(IDS_DIRCNRVIEWHELP);
|
|---|
| 339 | break;
|
|---|
| 340 | case DIR_SORT:
|
|---|
| 341 | s = GetPString(IDS_DIRCNRSORTHELP);
|
|---|
| 342 | break;
|
|---|
| 343 | case DIR_FILTER:
|
|---|
| 344 | s = GetPString(IDS_DIRCNRFILTERHELP);
|
|---|
| 345 | break;
|
|---|
| 346 | default:
|
|---|
| 347 | break;
|
|---|
| 348 | }
|
|---|
| 349 | if (s)
|
|---|
| 350 | MakeBubble(hwnd, TRUE, s);
|
|---|
| 351 | else if (hwndBubble)
|
|---|
| 352 | WinDestroyWindow(hwndBubble);
|
|---|
| 353 | }
|
|---|
| 354 | }
|
|---|
| 355 | switch (id) {
|
|---|
| 356 | case DIR_FILTER:
|
|---|
| 357 | case DIR_SORT:
|
|---|
| 358 | case DIR_VIEW:
|
|---|
| 359 | case DIR_SELECTED:
|
|---|
| 360 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
|---|
| 361 | }
|
|---|
| 362 | }
|
|---|
| 363 | break;
|
|---|
| 364 |
|
|---|
| 365 | case WM_BUTTON3UP:
|
|---|
| 366 | case WM_BUTTON1UP:
|
|---|
| 367 | case WM_BUTTON3DOWN:
|
|---|
| 368 | case WM_BUTTON1DOWN:
|
|---|
| 369 | {
|
|---|
| 370 | USHORT id;
|
|---|
| 371 |
|
|---|
| 372 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
|---|
| 373 | switch (id) {
|
|---|
| 374 | case DIR_FILTER:
|
|---|
| 375 | case DIR_SORT:
|
|---|
| 376 | case DIR_VIEW:
|
|---|
| 377 | case DIR_SELECTED:
|
|---|
| 378 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
|---|
| 379 | }
|
|---|
| 380 | }
|
|---|
| 381 | break;
|
|---|
| 382 |
|
|---|
| 383 | case UM_CLICKED:
|
|---|
| 384 | case UM_CLICKED3:
|
|---|
| 385 | {
|
|---|
| 386 | USHORT id, cmd = 0;
|
|---|
| 387 |
|
|---|
| 388 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
|---|
| 389 | switch (id) {
|
|---|
| 390 | case DIR_VIEW:
|
|---|
| 391 | case DIR_SORT:
|
|---|
| 392 | case DIR_SELECTED:
|
|---|
| 393 | PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
|
|---|
| 394 | break;
|
|---|
| 395 | case DIR_FILTER:
|
|---|
| 396 | cmd = IDM_FILTER;
|
|---|
| 397 | break;
|
|---|
| 398 | default:
|
|---|
| 399 | break;
|
|---|
| 400 | }
|
|---|
| 401 | if (cmd)
|
|---|
| 402 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 403 | COLLECTOR_CNR),
|
|---|
| 404 | WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
|
|---|
| 405 | }
|
|---|
| 406 | return 0;
|
|---|
| 407 |
|
|---|
| 408 | case DM_DROP:
|
|---|
| 409 | case DM_DRAGOVER:
|
|---|
| 410 | case DM_DRAGLEAVE:
|
|---|
| 411 | case DM_DROPHELP:
|
|---|
| 412 | if (msg == DM_DRAGOVER) {
|
|---|
| 413 | if (!emphasized) {
|
|---|
| 414 | emphasized = TRUE;
|
|---|
| 415 | DrawTargetEmphasis(hwnd, emphasized);
|
|---|
| 416 | }
|
|---|
| 417 | }
|
|---|
| 418 | else {
|
|---|
| 419 | if (emphasized) {
|
|---|
| 420 | emphasized = FALSE;
|
|---|
| 421 | DrawTargetEmphasis(hwnd, emphasized);
|
|---|
| 422 | }
|
|---|
| 423 | }
|
|---|
| 424 | {
|
|---|
| 425 | CNRDRAGINFO cnd;
|
|---|
| 426 | USHORT dcmd;
|
|---|
| 427 |
|
|---|
| 428 | switch (msg) {
|
|---|
| 429 | case DM_DROP:
|
|---|
| 430 | dcmd = CN_DROP;
|
|---|
| 431 | break;
|
|---|
| 432 | case DM_DRAGOVER:
|
|---|
| 433 | dcmd = CN_DRAGOVER;
|
|---|
| 434 | break;
|
|---|
| 435 | case DM_DRAGLEAVE:
|
|---|
| 436 | dcmd = CN_DRAGLEAVE;
|
|---|
| 437 | break;
|
|---|
| 438 | case DM_DROPHELP:
|
|---|
| 439 | dcmd = CN_DROPHELP;
|
|---|
| 440 | break;
|
|---|
| 441 | }
|
|---|
| 442 | memset(&cnd, 0, sizeof(cnd));
|
|---|
| 443 | cnd.pDragInfo = (PDRAGINFO) mp1;
|
|---|
| 444 | cnd.pRecord = NULL;
|
|---|
| 445 | return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_CONTROL,
|
|---|
| 446 | MPFROM2SHORT(COLLECTOR_CNR, dcmd), MPFROMP(&cnd));
|
|---|
| 447 | }
|
|---|
| 448 | }
|
|---|
| 449 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
|---|
| 450 | }
|
|---|
| 451 |
|
|---|
| 452 | MRESULT EXPENTRY CollectorClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 453 | MPARAM mp2)
|
|---|
| 454 | {
|
|---|
| 455 | switch (msg) {
|
|---|
| 456 | case UM_CONTAINERHWND:
|
|---|
| 457 | return MRFROMLONG(WinWindowFromID(hwnd, COLLECTOR_CNR));
|
|---|
| 458 |
|
|---|
| 459 | case UM_VIEWSMENU:
|
|---|
| 460 | return MRFROMLONG(CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP));
|
|---|
| 461 |
|
|---|
| 462 | case MM_PORTHOLEINIT:
|
|---|
| 463 | case WM_INITMENU:
|
|---|
| 464 | case UM_INITMENU:
|
|---|
| 465 | case UM_CONTAINER_FILLED:
|
|---|
| 466 | case UM_FILESMENU:
|
|---|
| 467 | case UM_UPDATERECORD:
|
|---|
| 468 | case UM_UPDATERECORDLIST:
|
|---|
| 469 | return WinSendMsg(WinWindowFromID(hwnd, COLLECTOR_CNR), msg, mp1, mp2);
|
|---|
| 470 |
|
|---|
| 471 | case WM_PSETFOCUS:
|
|---|
| 472 | case WM_SETFOCUS:
|
|---|
| 473 | if (mp2)
|
|---|
| 474 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
|---|
| 475 | break;
|
|---|
| 476 |
|
|---|
| 477 | case UM_FOCUSME:
|
|---|
| 478 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, COLLECTOR_CNR));
|
|---|
| 479 | break;
|
|---|
| 480 |
|
|---|
| 481 | case WM_PAINT:
|
|---|
| 482 | {
|
|---|
| 483 | HPS hps;
|
|---|
| 484 | RECTL rcl;
|
|---|
| 485 |
|
|---|
| 486 | hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
|
|---|
| 487 | if (hps) {
|
|---|
| 488 | WinQueryWindowRect(hwnd, &rcl);
|
|---|
| 489 | WinFillRect(hps, &rcl, CLR_PALEGRAY);
|
|---|
| 490 | CommonTextPaint(hwnd, hps);
|
|---|
| 491 | WinEndPaint(hps);
|
|---|
| 492 | }
|
|---|
| 493 | }
|
|---|
| 494 | break;
|
|---|
| 495 |
|
|---|
| 496 | case UM_SIZE:
|
|---|
| 497 | case WM_SIZE:
|
|---|
| 498 | if (msg == UM_SIZE) {
|
|---|
| 499 | SWP swp;
|
|---|
| 500 |
|
|---|
| 501 | WinQueryWindowPos(hwnd, &swp);
|
|---|
| 502 | mp1 = MPFROM2SHORT(swp.cx, swp.cy);
|
|---|
| 503 | mp2 = MPFROM2SHORT(swp.cx, swp.cy);
|
|---|
| 504 | }
|
|---|
| 505 | {
|
|---|
| 506 | USHORT cx, cy, bx;
|
|---|
| 507 |
|
|---|
| 508 | cx = SHORT1FROMMP(mp2);
|
|---|
| 509 | cy = SHORT2FROMMP(mp2);
|
|---|
| 510 | WinSetWindowPos(WinWindowFromID(hwnd, COLLECTOR_CNR), HWND_TOP,
|
|---|
| 511 | 0, 0, cx, cy - 24, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
|---|
| 512 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
|
|---|
| 513 | 2,
|
|---|
| 514 | cy - 22,
|
|---|
| 515 | (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
|---|
| 516 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
|
|---|
| 517 | 2 + (cx / 3) + 2,
|
|---|
| 518 | cy - 22,
|
|---|
| 519 | (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
|---|
| 520 | bx = (cx - (2 + (((cx / 3) + 2) * 2))) / 3;
|
|---|
| 521 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
|
|---|
| 522 | 2 + (((cx / 3) + 2) * 2),
|
|---|
| 523 | cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
|---|
| 524 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
|
|---|
| 525 | 2 + (((cx / 3) + 2) * 2) + bx,
|
|---|
| 526 | cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
|---|
| 527 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
|
|---|
| 528 | 2 + (((cx / 3) + 2) * 2) + (bx * 2),
|
|---|
| 529 | cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
|---|
| 530 | }
|
|---|
| 531 | CommonTextPaint(hwnd, NULLHANDLE);
|
|---|
| 532 | if (msg == UM_SIZE) {
|
|---|
| 533 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
|
|---|
| 534 | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
|
|---|
| 535 | return 0;
|
|---|
| 536 | }
|
|---|
| 537 | break;
|
|---|
| 538 |
|
|---|
| 539 | case UM_COMMAND:
|
|---|
| 540 | case WM_COMMAND:
|
|---|
| 541 | case WM_CONTROL:
|
|---|
| 542 | case WM_CLOSE:
|
|---|
| 543 | return WinSendMsg(WinWindowFromID(hwnd, COLLECTOR_CNR), msg, mp1, mp2);
|
|---|
| 544 | }
|
|---|
| 545 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 | MRESULT EXPENTRY CollectorObjWndProc(HWND hwnd, ULONG msg,
|
|---|
| 549 | MPARAM mp1, MPARAM mp2)
|
|---|
| 550 | {
|
|---|
| 551 | ULONG size;
|
|---|
| 552 | DIRCNRDATA *dcd;
|
|---|
| 553 |
|
|---|
| 554 | switch (msg) {
|
|---|
| 555 | case WM_CREATE:
|
|---|
| 556 | // 18 Jul 08 SHL fixme to doc why messsage gets lost
|
|---|
| 557 | DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2); // 18 Jul 08 SHL fixme
|
|---|
| 558 | break;
|
|---|
| 559 |
|
|---|
| 560 | case DM_PRINTOBJECT:
|
|---|
| 561 | return MRFROMLONG(DRR_TARGET);
|
|---|
| 562 |
|
|---|
| 563 | case DM_DISCARDOBJECT:
|
|---|
| 564 | dcd = INSTDATA(hwnd);
|
|---|
| 565 | if (fFM2Deletes && dcd) {
|
|---|
| 566 | LISTINFO *li;
|
|---|
| 567 | CNRDRAGINFO cni;
|
|---|
| 568 |
|
|---|
| 569 | cni.pRecord = NULL;
|
|---|
| 570 | cni.pDragInfo = (PDRAGINFO) mp1;
|
|---|
| 571 | li = DoFileDrop(dcd->hwndCnr, NULL, FALSE, MPVOID, MPFROMP(&cni));
|
|---|
| 572 | CheckPmDrgLimit(cni.pDragInfo);
|
|---|
| 573 | if (li) {
|
|---|
| 574 | li->type = fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE;
|
|---|
| 575 | if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
|
|---|
| 576 | FreeListInfo(li);
|
|---|
| 577 | else
|
|---|
| 578 | return MRFROMLONG(DRR_SOURCE);
|
|---|
| 579 | }
|
|---|
| 580 | }
|
|---|
| 581 | return MRFROMLONG(DRR_TARGET);
|
|---|
| 582 |
|
|---|
| 583 | case UM_UPDATERECORDLIST:
|
|---|
| 584 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 585 | if (dcd && mp1) {
|
|---|
| 586 | INT numentries = 0;
|
|---|
| 587 | CHAR **list = (CHAR **) mp1;
|
|---|
| 588 |
|
|---|
| 589 | while (list[numentries])
|
|---|
| 590 | numentries++;
|
|---|
| 591 | if (numentries)
|
|---|
| 592 | UpdateCnrList(dcd->hwndCnr, list, numentries, FALSE, dcd);
|
|---|
| 593 | }
|
|---|
| 594 | return 0;
|
|---|
| 595 |
|
|---|
| 596 | case UM_SETUP:
|
|---|
| 597 | # ifdef FORTIFY
|
|---|
| 598 | Fortify_EnterScope();
|
|---|
| 599 | # endif
|
|---|
| 600 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 601 | if (dcd) {
|
|---|
| 602 | # ifdef FORTIFY
|
|---|
| 603 | Fortify_BecomeOwner(dcd);
|
|---|
| 604 | # endif
|
|---|
| 605 | // set unique id
|
|---|
| 606 | WinSetWindowUShort(hwnd,
|
|---|
| 607 | QWS_ID,
|
|---|
| 608 | COLLECTOROBJ_FRAME + (COLLECTOR_FRAME - dcd->id));
|
|---|
| 609 | dcd->hwndObject = hwnd;
|
|---|
| 610 | // 09 Feb 08 SHL fixme to be sure applet does not really need this
|
|---|
| 611 | // if (ParentIsDesktop(hwnd, dcd->hwndParent))
|
|---|
| 612 | // DosSleep(100); //05 Aug 07 GKY 250
|
|---|
| 613 | }
|
|---|
| 614 | else
|
|---|
| 615 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
|---|
| 616 | return 0;
|
|---|
| 617 |
|
|---|
| 618 | case UM_COMMAND:
|
|---|
| 619 | if (mp1) {
|
|---|
| 620 | LISTINFO *li = (LISTINFO *) mp1;
|
|---|
| 621 |
|
|---|
| 622 | switch (li->type) {
|
|---|
| 623 | case IDM_DOITYOURSELF:
|
|---|
| 624 | case IDM_APPENDTOCLIP:
|
|---|
| 625 | case IDM_APPENDTOCLIPFILENAME:
|
|---|
| 626 | case IDM_SAVETOCLIP:
|
|---|
| 627 | case IDM_ARCHIVE:
|
|---|
| 628 | case IDM_ARCHIVEM:
|
|---|
| 629 | case IDM_VIEW:
|
|---|
| 630 | case IDM_VIEWTEXT:
|
|---|
| 631 | case IDM_VIEWBINARY:
|
|---|
| 632 | case IDM_VIEWARCHIVE:
|
|---|
| 633 | case IDM_EDIT:
|
|---|
| 634 | case IDM_EDITTEXT:
|
|---|
| 635 | case IDM_EDITBINARY:
|
|---|
| 636 | case IDM_OBJECT:
|
|---|
| 637 | case IDM_SHADOW:
|
|---|
| 638 | case IDM_SHADOW2:
|
|---|
| 639 | case IDM_PRINT:
|
|---|
| 640 | case IDM_ATTRS:
|
|---|
| 641 | case IDM_DELETE:
|
|---|
| 642 | case IDM_PERMDELETE:
|
|---|
| 643 | case IDM_FAKEEXTRACT:
|
|---|
| 644 | case IDM_FAKEEXTRACTM:
|
|---|
| 645 | case IDM_MCIPLAY:
|
|---|
| 646 | case IDM_UPDATE:
|
|---|
| 647 | if (li->type == IDM_DELETE)
|
|---|
| 648 | ignorereadonly = FALSE;
|
|---|
| 649 | if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
|
|---|
| 650 | return (MRESULT) TRUE;
|
|---|
| 651 | break;
|
|---|
| 652 | default:
|
|---|
| 653 | if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
|
|---|
| 654 | return (MRESULT) TRUE;
|
|---|
| 655 | }
|
|---|
| 656 | }
|
|---|
| 657 | return 0;
|
|---|
| 658 |
|
|---|
| 659 | case UM_COLLECT:
|
|---|
| 660 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 661 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 662 | if (dcd) {
|
|---|
| 663 | LISTINFO *li = (LISTINFO *) mp1;
|
|---|
| 664 | INT x;
|
|---|
| 665 | FILEFINDBUF4L fb4;
|
|---|
| 666 | HDIR hdir;
|
|---|
| 667 | ULONG ulMaxFiles;
|
|---|
| 668 | CHAR fullname[CCHMAXPATH];
|
|---|
| 669 |
|
|---|
| 670 | if (!hwndStatus) {
|
|---|
| 671 | WinSetWindowText(WinWindowFromID(dcd->hwndClient, DIR_SELECTED),
|
|---|
| 672 | (CHAR *) GetPString(IDS_COLLECTINGTEXT));
|
|---|
| 673 | }
|
|---|
| 674 | else {
|
|---|
| 675 | if (WinQueryFocus(HWND_DESKTOP) == dcd->hwndCnr)
|
|---|
| 676 | WinSetWindowText(hwndStatus, (CHAR *) GetPString(IDS_COLLECTINGTEXT));
|
|---|
| 677 | }
|
|---|
| 678 |
|
|---|
| 679 | for (ulMaxFiles = 0; li->list[ulMaxFiles]; ulMaxFiles++) ; // Count
|
|---|
| 680 |
|
|---|
| 681 | if (ulMaxFiles) {
|
|---|
| 682 | PCNRITEM pci = NULL;
|
|---|
| 683 | PCNRITEM pciFirst = NULL;
|
|---|
| 684 | PCNRITEM pciPrev;
|
|---|
| 685 | ULONG nm;
|
|---|
| 686 | ULONG ulRecsAtStart;
|
|---|
| 687 | ULONG ulRecsToInsert;
|
|---|
| 688 | ULONG ulRecsInserted = 0;
|
|---|
| 689 | ULONGLONG ullTotalBytes = 0;
|
|---|
| 690 | BOOL checkToInsert = FALSE;
|
|---|
| 691 | CNRINFO cnri;
|
|---|
| 692 | RECORDINSERT ri;
|
|---|
| 693 | ITIMER_DESC itdSleep = { 0 }; // 06 Feb 08 SHL
|
|---|
| 694 |
|
|---|
| 695 | InitITimer(&itdSleep, 500); // Sleep every 500 mSec
|
|---|
| 696 |
|
|---|
| 697 | // Query initial count
|
|---|
| 698 | // 2011-05-29 SHL fixme to be utility
|
|---|
| 699 | memset(&cnri, 0, sizeof(CNRINFO));
|
|---|
| 700 | cnri.cb = sizeof(CNRINFO);
|
|---|
| 701 | if (WinSendMsg(dcd->hwndCnr, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
|---|
| 702 | MPFROMLONG(sizeof(CNRINFO)))) {
|
|---|
| 703 | ulRecsAtStart = cnri.cRecords;
|
|---|
| 704 | }
|
|---|
| 705 | else {
|
|---|
| 706 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, PCSZ_QUERYCNRINFO);
|
|---|
| 707 | ulRecsAtStart = 0;
|
|---|
| 708 | }
|
|---|
| 709 |
|
|---|
| 710 | for (x = 0; li->list[x]; x++) {
|
|---|
| 711 |
|
|---|
| 712 | // Allocate more container items if needed
|
|---|
| 713 | if (!pci) {
|
|---|
| 714 | ulRecsToInsert = ulMaxFiles - ulRecsInserted; // Left to do
|
|---|
| 715 | if (ulRecsToInsert > USHRT_MAX)
|
|---|
| 716 | ulRecsToInsert = USHRT_MAX; // Avoid USHORT overflows
|
|---|
| 717 | pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
|
|---|
| 718 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
|---|
| 719 | MPFROMLONG(ulRecsToInsert));
|
|---|
| 720 | pciFirst = pci;
|
|---|
| 721 | pciPrev = NULL;
|
|---|
| 722 | if (!pci) {
|
|---|
| 723 | Runtime_Error(pszSrcFile, __LINE__, PCSZ_CM_ALLOCRECORD);
|
|---|
| 724 | break;
|
|---|
| 725 | }
|
|---|
| 726 | } // if need allocate
|
|---|
| 727 |
|
|---|
| 728 | nm = 1;
|
|---|
| 729 | hdir = HDIR_CREATE;
|
|---|
| 730 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 731 | // If started with records in container, check if updating existing record
|
|---|
| 732 | if (ulRecsAtStart &&
|
|---|
| 733 | FindCnrRecord(dcd->hwndCnr,
|
|---|
| 734 | li->list[x],
|
|---|
| 735 | NULL,
|
|---|
| 736 | FALSE,
|
|---|
| 737 | FALSE,
|
|---|
| 738 | TRUE))
|
|---|
| 739 | {
|
|---|
| 740 | // Updating existing record
|
|---|
| 741 | PCNRITEM pciUpd = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
|
|---|
| 742 | if (!pciUpd) {
|
|---|
| 743 | // file has disappeared
|
|---|
| 744 | Runtime_Error(pszSrcFile, __LINE__, "pci NULL for list[%u]", x);
|
|---|
| 745 | }
|
|---|
| 746 | else {
|
|---|
| 747 | // Update OK
|
|---|
| 748 | if (Filter((PMINIRECORDCORE) pciUpd, (PVOID) & dcd->mask)) {
|
|---|
| 749 | pciUpd->rc.flRecordAttr &= ~CRA_FILTERED; // Ensure visible
|
|---|
| 750 | // 2011-05-29 SHL fixme to check fail
|
|---|
| 751 | WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
|
|---|
| 752 | MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
|
|---|
| 753 | }
|
|---|
| 754 | }
|
|---|
| 755 | ulMaxFiles--; // No insert needed
|
|---|
| 756 | checkToInsert = TRUE;
|
|---|
| 757 | }
|
|---|
| 758 | // Add new entry maybe
|
|---|
| 759 | else if (*li->list[x] &&
|
|---|
| 760 | !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
|
|---|
| 761 | fullname, sizeof(fullname)) &&
|
|---|
| 762 | !IsRoot(fullname) &&
|
|---|
| 763 | !xDosFindFirst(fullname,
|
|---|
| 764 | &hdir,
|
|---|
| 765 | FILE_NORMAL | FILE_DIRECTORY |
|
|---|
| 766 | FILE_ARCHIVED | FILE_SYSTEM |
|
|---|
| 767 | FILE_HIDDEN | FILE_READONLY,
|
|---|
| 768 | &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL))
|
|---|
| 769 | {
|
|---|
| 770 | // OK to add
|
|---|
| 771 | DosFindClose(hdir);
|
|---|
| 772 | priority_normal();
|
|---|
| 773 | *fb4.achName = 0;
|
|---|
| 774 | ullTotalBytes += FillInRecordFromFFB(dcd->hwndCnr,
|
|---|
| 775 | pci,
|
|---|
| 776 | fullname, &fb4, FALSE, dcd);
|
|---|
| 777 | pciPrev = pci;
|
|---|
| 778 | pci = (PCNRITEM) pci->rc.preccNextRecord;
|
|---|
| 779 | }
|
|---|
| 780 | else {
|
|---|
| 781 | // DosQueryPathInfo etc. failed - try to recover
|
|---|
| 782 | Runtime_Error(pszSrcFile, __LINE__, "DosQueryPathInfo failed for %s", fullname);
|
|---|
| 783 | ulMaxFiles--; // Nothing to insert
|
|---|
| 784 | checkToInsert = TRUE;
|
|---|
| 785 | }
|
|---|
| 786 |
|
|---|
| 787 | if (checkToInsert) {
|
|---|
| 788 | checkToInsert = FALSE;
|
|---|
| 789 | // Remove extra records from chain
|
|---|
| 790 | while (ulRecsInserted + ulRecsToInsert > ulMaxFiles) {
|
|---|
| 791 | PCNRITEM pciNext = (PCNRITEM)pci->rc.preccNextRecord;
|
|---|
| 792 | if (pciPrev)
|
|---|
| 793 | pciPrev->rc.preccNextRecord = (PMINIRECORDCORE)pciNext;
|
|---|
| 794 | else
|
|---|
| 795 | pciFirst = pciNext;
|
|---|
| 796 | pci->pszFileName = NullStr; // Avoid spurious complaints
|
|---|
| 797 | FreeCnrItem(dcd->hwndCnr, pci);
|
|---|
| 798 | pci = pciNext;
|
|---|
| 799 | ulRecsToInsert--; // Remember gone
|
|---|
| 800 | }
|
|---|
| 801 | }
|
|---|
| 802 |
|
|---|
| 803 | // Check if time to insert
|
|---|
| 804 | if (!pci) {
|
|---|
| 805 | // All allocated CNRITEMs filled
|
|---|
| 806 | if (ulRecsToInsert) {
|
|---|
| 807 | // Have CNRITEMs to insert
|
|---|
| 808 | memset(&ri, 0, sizeof(RECORDINSERT));
|
|---|
| 809 | ri.cb = sizeof(RECORDINSERT);
|
|---|
| 810 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
|---|
| 811 | ri.pRecordParent = (PRECORDCORE) 0;
|
|---|
| 812 | ri.zOrder = (ULONG) CMA_TOP;
|
|---|
| 813 | ri.cRecordsInsert = ulRecsToInsert;
|
|---|
| 814 | ri.fInvalidateRecord = TRUE;
|
|---|
| 815 | WinSendMsg(dcd->hwndCnr,
|
|---|
| 816 | CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
|
|---|
| 817 | // 2011-05-29 SHL fixme to complain on failure
|
|---|
| 818 | PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 819 | ulRecsInserted += ulRecsToInsert;
|
|---|
| 820 | dcd->ullTotalBytes = ullTotalBytes;
|
|---|
| 821 | pciFirst = NULL;
|
|---|
| 822 | ulRecsToInsert = 0;
|
|---|
| 823 | }
|
|---|
| 824 | } // if need CM_INSERTRECORD
|
|---|
| 825 | SleepIfNeeded(&itdSleep, 1); // 09 Feb 08 SHL
|
|---|
| 826 | } // for
|
|---|
| 827 |
|
|---|
| 828 | // Clean up in case stopped early by error
|
|---|
| 829 | if (pci)
|
|---|
| 830 | Runtime_Error(pszSrcFile, __LINE__, "pci not NULL");
|
|---|
| 831 |
|
|---|
| 832 | if (pciFirst) {
|
|---|
| 833 | Runtime_Error(pszSrcFile, __LINE__, "pciFirst not NULL");
|
|---|
| 834 | // 2011-08-08 SHL fixme to initialze pszFileName to prevent spurious complaints
|
|---|
| 835 | FreeCnrItemList(dcd->hwndCnr, pciFirst);
|
|---|
| 836 | }
|
|---|
| 837 |
|
|---|
| 838 | } // if have files
|
|---|
| 839 |
|
|---|
| 840 | if (dcd->flWindowAttr & CV_DETAIL)
|
|---|
| 841 | WinSendDlgItemMsg(hwnd,
|
|---|
| 842 | COLLECTOR_CNR,
|
|---|
| 843 | CM_INVALIDATERECORD,
|
|---|
| 844 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
|---|
| 845 | } // if dcd
|
|---|
| 846 | return 0;
|
|---|
| 847 |
|
|---|
| 848 | case UM_COLLECTFROMFILE:
|
|---|
| 849 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 850 | # ifdef FORTIFY
|
|---|
| 851 | Fortify_EnterScope();
|
|---|
| 852 | # endif
|
|---|
| 853 |
|
|---|
| 854 | if (dcd && mp1) {
|
|---|
| 855 | // mp1 is pszFileName, mp2 is unused
|
|---|
| 856 | FILESTATUS4L fs4;
|
|---|
| 857 | PCNRITEM pci;
|
|---|
| 858 | RECORDINSERT ri;
|
|---|
| 859 | CHAR fullname[1024], *p;
|
|---|
| 860 | FILE *fp;
|
|---|
| 861 | ULONG errs = 0;
|
|---|
| 862 | BOOL first = TRUE; // 2012-09-05 SHL
|
|---|
| 863 | size_t c;
|
|---|
| 864 | CHAR *moder = "r";
|
|---|
| 865 |
|
|---|
| 866 | # ifdef FORTIFY
|
|---|
| 867 | Fortify_BecomeOwner(mp1);
|
|---|
| 868 | # endif
|
|---|
| 869 |
|
|---|
| 870 | fp = xfsopen((CHAR *)mp1, moder, SH_DENYNO, pszSrcFile, __LINE__, TRUE);
|
|---|
| 871 | if (fp) {
|
|---|
| 872 | while (!feof(fp)) {
|
|---|
| 873 | // Avoid too much noise if collecting from binary file - oops
|
|---|
| 874 | if (!fgets(fullname, sizeof(fullname), fp)) {
|
|---|
| 875 | if (ferror(fp))
|
|---|
| 876 | Runtime_Error(pszSrcFile, __LINE__, "fgets");
|
|---|
| 877 | break;
|
|---|
| 878 | }
|
|---|
| 879 |
|
|---|
| 880 | c = strlen(fullname);
|
|---|
| 881 | if (c + 1 >= sizeof(fullname))
|
|---|
| 882 | errs++; // Name too long
|
|---|
| 883 | else if (!c || (fullname[c - 1] != '\n' && fullname[c - 1] != '\r'))
|
|---|
| 884 | errs++; // Probably reading a binary file
|
|---|
| 885 | else {
|
|---|
| 886 | bstripcr(fullname);
|
|---|
| 887 |
|
|---|
| 888 | if (*fullname == '\"') {
|
|---|
| 889 | // Strip quotes
|
|---|
| 890 | memmove(fullname, fullname + 1, strlen(fullname) + 1);
|
|---|
| 891 | lstrip(fullname);
|
|---|
| 892 | p = strchr(fullname, '\"');
|
|---|
| 893 | if (p)
|
|---|
| 894 | *p = 0;
|
|---|
| 895 | rstrip(fullname);
|
|---|
| 896 | }
|
|---|
| 897 | else {
|
|---|
| 898 | // Strip trailing spaces
|
|---|
| 899 | p = strchr(fullname, ' ');
|
|---|
| 900 | if (p)
|
|---|
| 901 | *p = 0;
|
|---|
| 902 | }
|
|---|
| 903 | // fullname now contains name of file to collect
|
|---|
| 904 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 905 | if (FindCnrRecord(dcd->hwndCnr,
|
|---|
| 906 | fullname,
|
|---|
| 907 | NULL,
|
|---|
| 908 | FALSE,
|
|---|
| 909 | FALSE,
|
|---|
| 910 | TRUE)) {
|
|---|
| 911 | // Already in container
|
|---|
| 912 | pci = UpdateCnrRecord(dcd->hwndCnr, fullname, FALSE, dcd);
|
|---|
| 913 | if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
|
|---|
| 914 | pci->rc.flRecordAttr &= ~CRA_FILTERED;
|
|---|
| 915 | WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
|
|---|
| 916 | MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
|
|---|
| 917 | }
|
|---|
| 918 | }
|
|---|
| 919 | else if (IsFullName(fullname) &&
|
|---|
| 920 | !IsRoot(fullname) &&
|
|---|
| 921 | !DosQueryPathInfo(fullname,
|
|---|
| 922 | FIL_QUERYEASIZEL,
|
|---|
| 923 | &fs4,
|
|---|
| 924 | sizeof(fs4))) {
|
|---|
| 925 | // Add to collector containter
|
|---|
| 926 | pci = WinSendMsg(dcd->hwndCnr,
|
|---|
| 927 | CM_ALLOCRECORD,
|
|---|
| 928 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
|---|
| 929 | MPFROMLONG(1));
|
|---|
| 930 | if (pci) {
|
|---|
| 931 | dcd->ullTotalBytes += FillInRecordFromFSA(dcd->hwndCnr, pci,
|
|---|
| 932 | fullname,
|
|---|
| 933 | &fs4, FALSE, NULL, dcd);
|
|---|
| 934 | memset(&ri, 0, sizeof(RECORDINSERT));
|
|---|
| 935 | ri.cb = sizeof(RECORDINSERT);
|
|---|
| 936 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
|---|
| 937 | ri.pRecordParent = (PRECORDCORE) 0;
|
|---|
| 938 | ri.zOrder = (ULONG) CMA_TOP;
|
|---|
| 939 | ri.cRecordsInsert = 1;
|
|---|
| 940 | ri.fInvalidateRecord = TRUE;
|
|---|
| 941 | WinSendMsg(dcd->hwndCnr, CM_INSERTRECORD,
|
|---|
| 942 | MPFROMP(pci), MPFROMP(&ri));
|
|---|
| 943 | }
|
|---|
| 944 | }
|
|---|
| 945 | else
|
|---|
| 946 | errs++; // Something wrong with filename or file
|
|---|
| 947 | }
|
|---|
| 948 | if (errs > (first ? 0 : 50)) {
|
|---|
| 949 | // prevent runaway on bad file
|
|---|
| 950 | APIRET ret = saymsg(MB_YESNO, dcd->hwndCnr,
|
|---|
| 951 | GetPString(IDS_COLLECTNOLISTHDRTEXT),
|
|---|
| 952 | GetPString(IDS_COLLECTNOLISTTEXT),
|
|---|
| 953 | (CHAR *)mp1);
|
|---|
| 954 |
|
|---|
| 955 | if (ret == MBID_NO)
|
|---|
| 956 | break; // Give up
|
|---|
| 957 | if (!first)
|
|---|
| 958 | errs = 0;
|
|---|
| 959 | else
|
|---|
| 960 | first = FALSE;
|
|---|
| 961 | }
|
|---|
| 962 | } // while not eof
|
|---|
| 963 | fclose(fp);
|
|---|
| 964 | } // if file opened
|
|---|
| 965 | free(mp1);
|
|---|
| 966 | }
|
|---|
| 967 | # ifdef FORTIFY
|
|---|
| 968 | Fortify_LeaveScope();
|
|---|
| 969 | # endif
|
|---|
| 970 | return 0;
|
|---|
| 971 |
|
|---|
| 972 | case UM_SELECT:
|
|---|
| 973 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 974 | if (dcd) {
|
|---|
| 975 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 976 | case IDM_SELECTLIST:
|
|---|
| 977 | {
|
|---|
| 978 | CHAR filename[CCHMAXPATH], *p, *pp;
|
|---|
| 979 |
|
|---|
| 980 | strcpy(filename, PCSZ_STARDOTLST);
|
|---|
| 981 | size = CCHMAXPATH;
|
|---|
| 982 | PrfQueryProfileData(fmprof, appname, "SaveToListName", filename,
|
|---|
| 983 | &size);
|
|---|
| 984 | pp = strrchr(filename, '\\');
|
|---|
| 985 | if (!pp)
|
|---|
| 986 | pp = filename;
|
|---|
| 987 | p = strrchr(pp, '.');
|
|---|
| 988 | if (p && *(p + 1) && p > pp + 1) {
|
|---|
| 989 | if (pp > filename)
|
|---|
| 990 | pp++;
|
|---|
| 991 | *pp = '*';
|
|---|
| 992 | pp++;
|
|---|
| 993 | if (p > pp)
|
|---|
| 994 | memmove(pp, p, strlen(p) + 1);
|
|---|
| 995 | }
|
|---|
| 996 | if (insert_filename(hwnd, filename, FALSE, FALSE))
|
|---|
| 997 | SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
|
|---|
| 998 | NULL);
|
|---|
| 999 | }
|
|---|
| 1000 | break;
|
|---|
| 1001 | case IDM_SELECTALL:
|
|---|
| 1002 | SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
|
|---|
| 1003 | break;
|
|---|
| 1004 | case IDM_DESELECTALL:
|
|---|
| 1005 | DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
|
|---|
| 1006 | break;
|
|---|
| 1007 | case IDM_SELECTALLFILES:
|
|---|
| 1008 | SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
|
|---|
| 1009 | break;
|
|---|
| 1010 | case IDM_DESELECTALLFILES:
|
|---|
| 1011 | DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
|
|---|
| 1012 | break;
|
|---|
| 1013 | case IDM_SELECTALLDIRS:
|
|---|
| 1014 | SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
|
|---|
| 1015 | break;
|
|---|
| 1016 | case IDM_DESELECTALLDIRS:
|
|---|
| 1017 | DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
|
|---|
| 1018 | break;
|
|---|
| 1019 | case IDM_DESELECTMASK:
|
|---|
| 1020 | case IDM_SELECTMASK:
|
|---|
| 1021 | {
|
|---|
| 1022 | MASK mask;
|
|---|
| 1023 | PCNRITEM pci = (PCNRITEM) mp2;
|
|---|
| 1024 |
|
|---|
| 1025 | memset(&mask, 0, sizeof(MASK));
|
|---|
| 1026 | mask.fNoAttribs = TRUE;
|
|---|
| 1027 | mask.fNoDirs = TRUE;
|
|---|
| 1028 | mask.fText = TRUE;
|
|---|
| 1029 | strcpy(mask.prompt,
|
|---|
| 1030 | GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
|
|---|
| 1031 | IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
|
|---|
| 1032 | if (pci && (INT) pci != -1)
|
|---|
| 1033 | strcpy(mask.szMask, pci->pszFileName);
|
|---|
| 1034 | if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
|
|---|
| 1035 | FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
|
|---|
| 1036 | if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
|
|---|
| 1037 | SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
|
|---|
| 1038 | FALSE);
|
|---|
| 1039 | else
|
|---|
| 1040 | DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
|
|---|
| 1041 | FALSE);
|
|---|
| 1042 | }
|
|---|
| 1043 | }
|
|---|
| 1044 |
|
|---|
| 1045 | case IDM_DESELECTCLIP:
|
|---|
| 1046 | case IDM_SELECTCLIP:
|
|---|
| 1047 | {
|
|---|
| 1048 | CHAR **list;
|
|---|
| 1049 |
|
|---|
| 1050 | list = ListFromClipboard(hwnd);
|
|---|
| 1051 | if (list) {
|
|---|
| 1052 | SelectList(dcd->hwndCnr, TRUE, FALSE,
|
|---|
| 1053 | (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
|
|---|
| 1054 | NULL, NULL, list);
|
|---|
| 1055 | FreeList(list);
|
|---|
| 1056 | }
|
|---|
| 1057 | }
|
|---|
| 1058 | break;
|
|---|
| 1059 |
|
|---|
| 1060 | case IDM_INVERT:
|
|---|
| 1061 | InvertAll(dcd->hwndCnr);
|
|---|
| 1062 | break;
|
|---|
| 1063 | }
|
|---|
| 1064 | }
|
|---|
| 1065 | return 0;
|
|---|
| 1066 |
|
|---|
| 1067 | case UM_MASSACTION:
|
|---|
| 1068 | # ifdef FORTIFY
|
|---|
| 1069 | Fortify_EnterScope();
|
|---|
| 1070 | # endif
|
|---|
| 1071 | if (mp1) {
|
|---|
| 1072 | # ifdef FORTIFY
|
|---|
| 1073 | Fortify_BecomeOwner(mp1);
|
|---|
| 1074 | # endif
|
|---|
| 1075 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 1076 | if (dcd) {
|
|---|
| 1077 | WORKER *wk;
|
|---|
| 1078 | wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
|
|---|
| 1079 | if (!wk)
|
|---|
| 1080 | FreeListInfo((LISTINFO *) mp1);
|
|---|
| 1081 | else {
|
|---|
| 1082 | wk->size = sizeof(WORKER);
|
|---|
| 1083 | wk->hwndCnr = dcd->hwndCnr;
|
|---|
| 1084 | wk->hwndParent = dcd->hwndParent;
|
|---|
| 1085 | wk->hwndFrame = dcd->hwndFrame;
|
|---|
| 1086 | wk->hwndClient = dcd->hwndClient;
|
|---|
| 1087 | wk->li = (LISTINFO *) mp1;
|
|---|
| 1088 | strcpy(wk->directory, dcd->directory);
|
|---|
| 1089 | if (xbeginthread(MassAction,
|
|---|
| 1090 | 122880,
|
|---|
| 1091 | wk,
|
|---|
| 1092 | pszSrcFile,
|
|---|
| 1093 | __LINE__) == -1)
|
|---|
| 1094 | {
|
|---|
| 1095 | free(wk);
|
|---|
| 1096 | FreeListInfo((LISTINFO *) mp1);
|
|---|
| 1097 | }
|
|---|
| 1098 | }
|
|---|
| 1099 | }
|
|---|
| 1100 | }
|
|---|
| 1101 | # ifdef FORTIFY
|
|---|
| 1102 | DosSleep(1); // Let receiver take ownership
|
|---|
| 1103 | Fortify_LeaveScope();
|
|---|
| 1104 | # endif
|
|---|
| 1105 | return 0;
|
|---|
| 1106 |
|
|---|
| 1107 | case UM_ACTION:
|
|---|
| 1108 | # ifdef FORTIFY
|
|---|
| 1109 | Fortify_EnterScope();
|
|---|
| 1110 | # endif
|
|---|
| 1111 | if (mp1) {
|
|---|
| 1112 | # ifdef FORTIFY
|
|---|
| 1113 | Fortify_BecomeOwner(mp1);
|
|---|
| 1114 | # endif
|
|---|
| 1115 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 1116 | if (dcd) {
|
|---|
| 1117 | WORKER *wk;
|
|---|
| 1118 | wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
|
|---|
| 1119 | if (!wk)
|
|---|
| 1120 | FreeListInfo((LISTINFO *) mp1);
|
|---|
| 1121 | else {
|
|---|
| 1122 | wk->size = sizeof(WORKER);
|
|---|
| 1123 | wk->hwndCnr = dcd->hwndCnr;
|
|---|
| 1124 | wk->hwndParent = dcd->hwndParent;
|
|---|
| 1125 | wk->hwndFrame = dcd->hwndFrame;
|
|---|
| 1126 | wk->hwndClient = dcd->hwndClient;
|
|---|
| 1127 | wk->li = (LISTINFO *) mp1;
|
|---|
| 1128 | strcpy(wk->directory, dcd->directory);
|
|---|
| 1129 | if (xbeginthread(Action,
|
|---|
| 1130 | 122880,
|
|---|
| 1131 | wk,
|
|---|
| 1132 | pszSrcFile,
|
|---|
| 1133 | __LINE__) == -1)
|
|---|
| 1134 | {
|
|---|
| 1135 | free(wk);
|
|---|
| 1136 | FreeListInfo((LISTINFO *) mp1);
|
|---|
| 1137 | }
|
|---|
| 1138 | }
|
|---|
| 1139 | }
|
|---|
| 1140 | }
|
|---|
| 1141 | # ifdef FORTIFY
|
|---|
| 1142 | DosSleep(1); // Let receiver take ownership
|
|---|
| 1143 | Fortify_LeaveScope();
|
|---|
| 1144 | # endif
|
|---|
| 1145 | return 0;
|
|---|
| 1146 |
|
|---|
| 1147 | case WM_CLOSE:
|
|---|
| 1148 | WinDestroyWindow(hwnd);
|
|---|
| 1149 | break;
|
|---|
| 1150 |
|
|---|
| 1151 | case WM_DESTROY:
|
|---|
| 1152 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 1153 | if (dcd) {
|
|---|
| 1154 | INT x;
|
|---|
| 1155 |
|
|---|
| 1156 | dcd->stopflag = 1;
|
|---|
| 1157 | // Allow other threads to honor stop request
|
|---|
| 1158 | for (x = 0; x < 100 && dcd->amextracted; x++)
|
|---|
| 1159 | DosSleep(10);
|
|---|
| 1160 | if (dcd->amextracted)
|
|---|
| 1161 | Runtime_Error(pszSrcFile, __LINE__, "still busy");
|
|---|
| 1162 | WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
|
|---|
| 1163 | FreeList(dcd->lastselection);
|
|---|
| 1164 | WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL); // 13 Apr 10 SHL Set NULL before freeing dcd
|
|---|
| 1165 | DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
|
|---|
| 1166 | free(dcd);
|
|---|
| 1167 | DosReleaseMutexSem(hmtxFiltering);
|
|---|
| 1168 | # ifdef FORTIFY
|
|---|
| 1169 | Fortify_LeaveScope();
|
|---|
| 1170 | # endif
|
|---|
| 1171 | }
|
|---|
| 1172 | DosPostEventSem(CompactSem);
|
|---|
| 1173 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
|---|
| 1174 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
|---|
| 1175 | break;
|
|---|
| 1176 | }
|
|---|
| 1177 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 1178 | }
|
|---|
| 1179 |
|
|---|
| 1180 | MRESULT EXPENTRY CollectorCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 1181 | MPARAM mp2)
|
|---|
| 1182 | {
|
|---|
| 1183 | DIRCNRDATA *dcd = INSTDATA(hwnd);
|
|---|
| 1184 | ULONG size;
|
|---|
| 1185 |
|
|---|
| 1186 | static INT savedSortFlags;
|
|---|
| 1187 |
|
|---|
| 1188 | switch (msg) {
|
|---|
| 1189 | case DM_PRINTOBJECT:
|
|---|
| 1190 | return MRFROMLONG(DRR_TARGET);
|
|---|
| 1191 |
|
|---|
| 1192 | case DM_DISCARDOBJECT:
|
|---|
| 1193 | if (dcd)
|
|---|
| 1194 | return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
|
|---|
| 1195 | else
|
|---|
| 1196 | return MRFROMLONG(DRR_TARGET);
|
|---|
| 1197 |
|
|---|
| 1198 | case WM_CHAR:
|
|---|
| 1199 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
|---|
| 1200 | if (SHORT1FROMMP(mp1) & KC_KEYUP)
|
|---|
| 1201 | return (MRESULT) TRUE;
|
|---|
| 1202 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
|
|---|
| 1203 | switch (SHORT2FROMMP(mp2)) {
|
|---|
| 1204 | case VK_DELETE:
|
|---|
| 1205 | if ((shiftstate & KC_CTRL) == KC_CTRL)
|
|---|
| 1206 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
|
|---|
| 1207 | else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
|
|---|
| 1208 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
|
|---|
| 1209 | else
|
|---|
| 1210 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
|
|---|
| 1211 | break;
|
|---|
| 1212 | }
|
|---|
| 1213 | }
|
|---|
| 1214 | if (shiftstate || fNoSearch)
|
|---|
| 1215 | break;
|
|---|
| 1216 | if (SHORT1FROMMP(mp1) & KC_CHAR) {
|
|---|
| 1217 | ULONG thistime, len;
|
|---|
| 1218 | SEARCHSTRING srch;
|
|---|
| 1219 | PCNRITEM pci;
|
|---|
| 1220 |
|
|---|
| 1221 | if (!dcd)
|
|---|
| 1222 | break;
|
|---|
| 1223 | switch (SHORT1FROMMP(mp2)) {
|
|---|
| 1224 | case '\x1b':
|
|---|
| 1225 | case '\r':
|
|---|
| 1226 | case '\n':
|
|---|
| 1227 | dcd->lasttime = 0;
|
|---|
| 1228 | *dcd->szCommonName = 0;
|
|---|
| 1229 | break;
|
|---|
| 1230 | default:
|
|---|
| 1231 | thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
|
|---|
| 1232 | if (thistime > dcd->lasttime + 1250)
|
|---|
| 1233 | *dcd->szCommonName = 0;
|
|---|
| 1234 | dcd->lasttime = thistime;
|
|---|
| 1235 | if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
|
|---|
| 1236 | break;
|
|---|
| 1237 | KbdRetry:
|
|---|
| 1238 | len = strlen(dcd->szCommonName);
|
|---|
| 1239 | if (len >= CCHMAXPATH - 1) {
|
|---|
| 1240 | *dcd->szCommonName = 0;
|
|---|
| 1241 | len = 0;
|
|---|
| 1242 | }
|
|---|
| 1243 | dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
|
|---|
| 1244 | dcd->szCommonName[len + 1] = 0;
|
|---|
| 1245 | memset(&srch, 0, sizeof(SEARCHSTRING));
|
|---|
| 1246 | srch.cb = sizeof(SEARCHSTRING);
|
|---|
| 1247 | srch.pszSearch = dcd->szCommonName;
|
|---|
| 1248 | srch.fsPrefix = TRUE;
|
|---|
| 1249 | srch.fsCaseSensitive = FALSE;
|
|---|
| 1250 | srch.usView = CV_ICON;
|
|---|
| 1251 | pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
|
|---|
| 1252 | MPFROMLONG(CMA_FIRST));
|
|---|
| 1253 | if (pci && (INT) pci != -1) {
|
|---|
| 1254 | USHORT attrib = CRA_CURSORED;
|
|---|
| 1255 |
|
|---|
| 1256 | // make found item current item
|
|---|
| 1257 | if (!stricmp(pci->pszFileName, dcd->szCommonName))
|
|---|
| 1258 | attrib |= CRA_SELECTED;
|
|---|
| 1259 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
|---|
| 1260 | MPFROM2SHORT(TRUE, attrib));
|
|---|
| 1261 | // make sure that record shows in viewport
|
|---|
| 1262 | ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
|
|---|
| 1263 | return (MRESULT) TRUE;
|
|---|
| 1264 | }
|
|---|
| 1265 | else {
|
|---|
| 1266 | if (SHORT1FROMMP(mp2) == ' ') {
|
|---|
| 1267 | dcd->szCommonName[len] = 0;
|
|---|
| 1268 | break;
|
|---|
| 1269 | }
|
|---|
| 1270 | *dcd->szCommonName = 0;
|
|---|
| 1271 | dcd->lasttime = 0;
|
|---|
| 1272 | if (len) // retry as first letter if no match
|
|---|
| 1273 |
|
|---|
| 1274 | goto KbdRetry;
|
|---|
| 1275 | }
|
|---|
| 1276 | break;
|
|---|
| 1277 | }
|
|---|
| 1278 | }
|
|---|
| 1279 | break;
|
|---|
| 1280 |
|
|---|
| 1281 | case WM_MOUSEMOVE:
|
|---|
| 1282 | case WM_BUTTON1UP:
|
|---|
| 1283 | case WM_BUTTON2UP:
|
|---|
| 1284 | case WM_BUTTON3UP:
|
|---|
| 1285 | case WM_CHORD:
|
|---|
| 1286 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
|---|
| 1287 | break;
|
|---|
| 1288 |
|
|---|
| 1289 | case WM_BUTTON1MOTIONEND:
|
|---|
| 1290 | {
|
|---|
| 1291 | CNRINFO cnri;
|
|---|
| 1292 |
|
|---|
| 1293 | memset(&cnri, 0, sizeof(CNRINFO));
|
|---|
| 1294 | cnri.cb = sizeof(CNRINFO);
|
|---|
| 1295 | if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
|---|
| 1296 | MPFROMLONG(sizeof(CNRINFO)))) {
|
|---|
| 1297 | if (cnri.flWindowAttr & CV_DETAIL)
|
|---|
| 1298 | PrfWriteProfileData(fmprof, appname, "CollectorCnrSplitBar",
|
|---|
| 1299 | (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
|
|---|
| 1300 | }
|
|---|
| 1301 | }
|
|---|
| 1302 | break;
|
|---|
| 1303 |
|
|---|
| 1304 | case WM_PRESPARAMCHANGED:
|
|---|
| 1305 | PresParamChanged(hwnd, PCSZ_COLLECTOR, mp1, mp2);
|
|---|
| 1306 | break;
|
|---|
| 1307 |
|
|---|
| 1308 | case UM_COMPARE:
|
|---|
| 1309 | if (dcd && mp1 && mp2) {
|
|---|
| 1310 | COMPARE *cmp;
|
|---|
| 1311 | CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
|
|---|
| 1312 |
|
|---|
| 1313 | if (!IsFile(leftdir) && !IsFile(rightdir)) {
|
|---|
| 1314 | cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
|
|---|
| 1315 | if (cmp) {
|
|---|
| 1316 | cmp->size = sizeof(COMPARE);
|
|---|
| 1317 | strcpy(cmp->leftdir, leftdir);
|
|---|
| 1318 | strcpy(cmp->rightdir, rightdir);
|
|---|
| 1319 | cmp->hwndParent = dcd->hwndParent;
|
|---|
| 1320 | cmp->dcd.hwndParent = dcd->hwndParent;
|
|---|
| 1321 | WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, CompareDlgProc,
|
|---|
| 1322 | FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
|
|---|
| 1323 | }
|
|---|
| 1324 | }
|
|---|
| 1325 | }
|
|---|
| 1326 | return 0;
|
|---|
| 1327 |
|
|---|
| 1328 | case UM_UPDATERECORDLIST:
|
|---|
| 1329 | if (dcd && mp1)
|
|---|
| 1330 | WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
|
|---|
| 1331 | return 0;
|
|---|
| 1332 |
|
|---|
| 1333 | case UM_UPDATERECORD:
|
|---|
| 1334 | if (dcd && mp1) {
|
|---|
| 1335 | CHAR *filename;
|
|---|
| 1336 |
|
|---|
| 1337 | filename = mp1;
|
|---|
| 1338 | if (filename)
|
|---|
| 1339 | UpdateCnrRecord(hwnd, filename, TRUE, dcd);
|
|---|
| 1340 | }
|
|---|
| 1341 | return 0;
|
|---|
| 1342 |
|
|---|
| 1343 | case WM_SETFOCUS:
|
|---|
| 1344 | // put name of our window on status line
|
|---|
| 1345 | if (dcd && hwndStatus && mp2) {
|
|---|
| 1346 | PCNRITEM pci = NULL;
|
|---|
| 1347 |
|
|---|
| 1348 | if (fAutoView && hwndMain) {
|
|---|
| 1349 | pci = WinSendMsg(hwnd,
|
|---|
| 1350 | CM_QUERYRECORDEMPHASIS,
|
|---|
| 1351 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
|---|
| 1352 | if (pci && (INT) pci != -1 &&
|
|---|
| 1353 | (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
|
|---|
| 1354 | WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
|
|---|
| 1355 | else
|
|---|
| 1356 | WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
|
|---|
| 1357 | }
|
|---|
| 1358 | if (dcd->amextracted)
|
|---|
| 1359 | WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_INSEEKSCANTEXT)); // Say working
|
|---|
| 1360 | WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 1361 | }
|
|---|
| 1362 | break;
|
|---|
| 1363 |
|
|---|
| 1364 | case UM_RESCAN:
|
|---|
| 1365 | if (dcd) {
|
|---|
| 1366 | CNRINFO cnri;
|
|---|
| 1367 | CHAR s[CCHMAXPATH + 69], tb[81], tf[81], szDate[DATE_BUF_BYTES] *p;
|
|---|
| 1368 | PCNRITEM pci = NULL;
|
|---|
| 1369 |
|
|---|
| 1370 | memset(&cnri, 0, sizeof(CNRINFO));
|
|---|
| 1371 | cnri.cb = sizeof(CNRINFO);
|
|---|
| 1372 | WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
|---|
| 1373 | MPFROMLONG(sizeof(CNRINFO)));
|
|---|
| 1374 | dcd->totalfiles = cnri.cRecords;
|
|---|
| 1375 | commafmt(tf, sizeof(tf), dcd->totalfiles);
|
|---|
| 1376 | CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
|
|---|
| 1377 | sprintf(s, "%s / %s", tf, tb);
|
|---|
| 1378 | WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
|
|---|
| 1379 |
|
|---|
| 1380 | commafmt(tf, sizeof(tf), dcd->selectedfiles);
|
|---|
| 1381 | CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
|
|---|
| 1382 | sprintf(s, "%s / %s", tf, tb);
|
|---|
| 1383 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
|
|---|
| 1384 |
|
|---|
| 1385 | if (hwndStatus &&
|
|---|
| 1386 | dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
|
|---|
| 1387 | if (hwndMain) {
|
|---|
| 1388 | pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
|
|---|
| 1389 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
|---|
| 1390 | if (pci && (INT) pci != -1)
|
|---|
| 1391 | PostMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
|
|---|
| 1392 | else
|
|---|
| 1393 | PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
|
|---|
| 1394 | }
|
|---|
| 1395 | if (!dcd->amextracted) {
|
|---|
| 1396 | if (!fMoreButtons) {
|
|---|
| 1397 | sprintf(s, " %s%s%s%s",
|
|---|
| 1398 | GetPString(IDS_COLLECTORTEXT),
|
|---|
| 1399 | *dcd->mask.szMask || dcd->mask.antiattr ||
|
|---|
| 1400 | dcd->mask.attrFile != ALLATTRS ? " (" : NullStr,
|
|---|
| 1401 | *dcd->mask.szMask ?
|
|---|
| 1402 | dcd->mask.szMask :
|
|---|
| 1403 | dcd->mask.antiattr ||
|
|---|
| 1404 | dcd->mask.attrFile != ALLATTRS ?
|
|---|
| 1405 | GetPString(IDS_ATTRTEXT) : NullStr,
|
|---|
| 1406 | *dcd->mask.szMask || dcd->mask.antiattr ||
|
|---|
| 1407 | dcd->mask.attrFile != ALLATTRS ?
|
|---|
| 1408 | ")" : NullStr);
|
|---|
| 1409 | }
|
|---|
| 1410 | else
|
|---|
| 1411 | strcpy(s, GetPString(IDS_COLLECTORTEXT));
|
|---|
| 1412 | WinSetWindowText(hwndStatus, s);
|
|---|
| 1413 | }
|
|---|
| 1414 | if (!pci)
|
|---|
| 1415 | pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
|
|---|
| 1416 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
|---|
| 1417 | if (pci && (INT) pci != -1) {
|
|---|
| 1418 | BOOL fStatus2Used = FALSE;
|
|---|
| 1419 |
|
|---|
| 1420 | if (fSplitStatus && hwndStatus2) {
|
|---|
| 1421 | if (pci->attrFile & FILE_DIRECTORY)
|
|---|
| 1422 | p = pci->pszFileName;
|
|---|
| 1423 | else {
|
|---|
| 1424 | if (!pci->pszFileName)
|
|---|
| 1425 | Runtime_Error(pszSrcFile, __LINE__, "pci->pszFileName NULL for %p", pci);
|
|---|
| 1426 | p = strrchr(pci->pszFileName, '\\');
|
|---|
| 1427 | if (p) {
|
|---|
| 1428 | if (*(p + 1))
|
|---|
| 1429 | p++;
|
|---|
| 1430 | else
|
|---|
| 1431 | p = pci->pszFileName;
|
|---|
| 1432 | }
|
|---|
| 1433 | else
|
|---|
| 1434 | p = pci->pszFileName;
|
|---|
| 1435 | }
|
|---|
| 1436 | CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
|
|---|
| 1437 | if (!fMoreButtons) {
|
|---|
| 1438 | DateFormat(szDate, pci->date);
|
|---|
| 1439 | sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
|
|---|
| 1440 | tb, szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
|
|---|
| 1441 | TimeSeparator, pci->time.seconds, pci->pszDispAttr, p);
|
|---|
| 1442 | }
|
|---|
| 1443 | else {
|
|---|
| 1444 | if (pci->cbFile + pci->easize > 1024)
|
|---|
| 1445 | CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
|
|---|
| 1446 | else
|
|---|
| 1447 | *tf = 0;
|
|---|
| 1448 | sprintf(s, GetPString(IDS_STATUSSIZETEXT),
|
|---|
| 1449 | tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
|
|---|
| 1450 | }
|
|---|
| 1451 | WinSetWindowText(hwndStatus2, s);
|
|---|
| 1452 | fStatus2Used = TRUE;
|
|---|
| 1453 | }
|
|---|
| 1454 | if (fMoreButtons) {
|
|---|
| 1455 | WinSetWindowText(hwndName, pci->pszFileName);
|
|---|
| 1456 | DateFormat(szDate, pci->date);
|
|---|
| 1457 | sprintf(s, "%s %02u%s%02u%s%02u",
|
|---|
| 1458 | szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
|
|---|
| 1459 | TimeSeparator, pci->time.seconds);
|
|---|
| 1460 | WinSetWindowText(hwndDate, s);
|
|---|
| 1461 | WinSetWindowText(hwndAttr, pci->pszDispAttr);
|
|---|
| 1462 | }
|
|---|
| 1463 | if (dcd->amextracted && hwndStatus2 && !fStatus2Used)
|
|---|
| 1464 | WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_INSEEKSCANTEXT)); // Say working
|
|---|
| 1465 | }
|
|---|
| 1466 | else {
|
|---|
| 1467 | if (hwndStatus2) {
|
|---|
| 1468 | if (dcd->amextracted)
|
|---|
| 1469 | WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_INSEEKSCANTEXT)); // Say working
|
|---|
| 1470 | else
|
|---|
| 1471 | WinSetWindowText(hwndStatus2, NullStr);
|
|---|
| 1472 | }
|
|---|
| 1473 | if (fMoreButtons) {
|
|---|
| 1474 | WinSetWindowText(hwndName, NullStr);
|
|---|
| 1475 | WinSetWindowText(hwndDate, NullStr);
|
|---|
| 1476 | WinSetWindowText(hwndAttr, NullStr);
|
|---|
| 1477 | }
|
|---|
| 1478 | }
|
|---|
| 1479 | }
|
|---|
| 1480 | }
|
|---|
| 1481 | return 0;
|
|---|
| 1482 |
|
|---|
| 1483 | case UM_CONTAINER_FILLED:
|
|---|
| 1484 | if (!fAlertBeepOff)
|
|---|
| 1485 | DosBeep(1000, 50); // Wake up user?
|
|---|
| 1486 | WinSendMsg(hwnd,
|
|---|
| 1487 | CM_INVALIDATERECORD,
|
|---|
| 1488 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
|---|
| 1489 | disable_menuitem(WinWindowFromID(WinQueryWindow(hwndMain, QW_PARENT),
|
|---|
| 1490 | FID_MENU), IDM_GREP, FALSE);
|
|---|
| 1491 | disable_menuitem(TreeMenu, IDM_GREP, FALSE);
|
|---|
| 1492 | disable_menuitem(DirMenu, IDM_GREP, FALSE);
|
|---|
| 1493 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 1494 | if (dcd) {
|
|---|
| 1495 | dcd->stopflag = 0;
|
|---|
| 1496 | dcd->amextracted = FALSE; // Say not busy
|
|---|
| 1497 | if (dcd->namecanchange) {
|
|---|
| 1498 | if (!PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID))
|
|---|
| 1499 | WinSendMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
|---|
| 1500 | }
|
|---|
| 1501 | else
|
|---|
| 1502 | WinSetWindowPos(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1503 | QW_PARENT),
|
|---|
| 1504 | HWND_TOP,
|
|---|
| 1505 | 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
|
|---|
| 1506 | }
|
|---|
| 1507 | return 0;
|
|---|
| 1508 |
|
|---|
| 1509 | case UM_SETUP:
|
|---|
| 1510 | if (dcd) {
|
|---|
| 1511 | if (!dcd->hwndObject) {
|
|---|
| 1512 | // first time through -- set things up
|
|---|
| 1513 |
|
|---|
| 1514 | CNRINFO cnri;
|
|---|
| 1515 |
|
|---|
| 1516 | RestorePresParams(hwnd, PCSZ_COLLECTOR);
|
|---|
| 1517 | LoadDetailsSwitches(PCSZ_COLLECTOR, &dcd->ds, FALSE);
|
|---|
| 1518 |
|
|---|
| 1519 | dcd->amextracted = FALSE; // Say not busy
|
|---|
| 1520 | dcd->stopflag = 0;
|
|---|
| 1521 | memset(&cnri, 0, sizeof(CNRINFO));
|
|---|
| 1522 | cnri.cb = sizeof(CNRINFO);
|
|---|
| 1523 | WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
|---|
| 1524 | MPFROMLONG(sizeof(CNRINFO)));
|
|---|
| 1525 | cnri.cyLineSpacing = 0;
|
|---|
| 1526 | cnri.cxTreeIndent = 12;
|
|---|
| 1527 |
|
|---|
| 1528 | cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_DETAIL));
|
|---|
| 1529 | cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES |
|
|---|
| 1530 | CV_MINI | CV_FLOW);
|
|---|
| 1531 | cnri.pSortRecord = (PVOID) SortCollectorCnr;
|
|---|
| 1532 |
|
|---|
| 1533 | size = sizeof(ULONG);
|
|---|
| 1534 | PrfQueryProfileData(fmprof, appname, "CollectorflWindowAttr",
|
|---|
| 1535 | (PVOID) & cnri.flWindowAttr, &size);
|
|---|
| 1536 | size = sizeof(MASK);
|
|---|
| 1537 | if (PrfQueryProfileSize(fmprof, appname, "CollectorFilter", &size) &&
|
|---|
| 1538 | size) {
|
|---|
| 1539 | PrfQueryProfileData(fmprof, appname, "CollectorFilter", &dcd->mask,
|
|---|
| 1540 | &size);
|
|---|
| 1541 | SetMask(NULL, &dcd->mask);
|
|---|
| 1542 | }
|
|---|
| 1543 | else {
|
|---|
| 1544 | dcd->mask.attrFile = (FILE_NORMAL | FILE_READONLY |
|
|---|
| 1545 | FILE_DIRECTORY | FILE_HIDDEN |
|
|---|
| 1546 | FILE_SYSTEM | FILE_ARCHIVED);
|
|---|
| 1547 | dcd->mask.antiattr = 0;
|
|---|
| 1548 | }
|
|---|
| 1549 |
|
|---|
| 1550 | *(dcd->mask.prompt) = 0;
|
|---|
| 1551 |
|
|---|
| 1552 | cnri.flWindowAttr |= CV_FLOW;
|
|---|
| 1553 | cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
|
|---|
| 1554 | dcd->flWindowAttr = cnri.flWindowAttr;
|
|---|
| 1555 | WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
|
|---|
| 1556 | MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
|
|---|
| 1557 | CMA_CXTREEINDENT | CMA_PSORTRECORD));
|
|---|
| 1558 | SetCnrCols(hwnd, FALSE);
|
|---|
| 1559 | AdjustCnrColsForPref(hwnd, NULL, &dcd->ds, FALSE);
|
|---|
| 1560 |
|
|---|
| 1561 | // fix splitbar for collector container
|
|---|
| 1562 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
|
|---|
| 1563 | size = sizeof(LONG);
|
|---|
| 1564 | PrfQueryProfileData(fmprof, appname, "CollectorCnrSplitBar",
|
|---|
| 1565 | &cnri.xVertSplitbar, &size);
|
|---|
| 1566 | if (cnri.xVertSplitbar <= 0)
|
|---|
| 1567 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
|
|---|
| 1568 | WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
|
|---|
| 1569 | MPFROMLONG(CMA_XVERTSPLITBAR));
|
|---|
| 1570 |
|
|---|
| 1571 | if (xbeginthread(MakeObjWin,
|
|---|
| 1572 | 245760,
|
|---|
| 1573 | dcd,
|
|---|
| 1574 | pszSrcFile,
|
|---|
| 1575 | __LINE__) == -1)
|
|---|
| 1576 | {
|
|---|
| 1577 | Runtime_Error(pszSrcFile, __LINE__,
|
|---|
| 1578 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
|---|
| 1579 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
|---|
| 1580 | return 0;
|
|---|
| 1581 | }
|
|---|
| 1582 | else
|
|---|
| 1583 | DosSleep(32); // Let object window get started
|
|---|
| 1584 | }
|
|---|
| 1585 | SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1586 | DIR_FILTER), &dcd->mask, FALSE);
|
|---|
| 1587 | SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1588 | DIR_SORT), CollectorsortFlags, FALSE);
|
|---|
| 1589 | SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1590 | DIR_VIEW), dcd->flWindowAttr);
|
|---|
| 1591 | }
|
|---|
| 1592 | else {
|
|---|
| 1593 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
|---|
| 1594 | return 0;
|
|---|
| 1595 | }
|
|---|
| 1596 | return 0;
|
|---|
| 1597 |
|
|---|
| 1598 | case WM_MENUEND:
|
|---|
| 1599 | if (dcd) {
|
|---|
| 1600 | HWND hwndMenu = (HWND) mp2;
|
|---|
| 1601 |
|
|---|
| 1602 | if (hwndMenu == CollectorCnrMenu || hwndMenu == CollectorFileMenu ||
|
|---|
| 1603 | hwndMenu == CollectorDirMenu) {
|
|---|
| 1604 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
|---|
| 1605 | if (dcd->cnremphasized) {
|
|---|
| 1606 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
|---|
| 1607 | MPFROM2SHORT(FALSE, CRA_SOURCE));
|
|---|
| 1608 | dcd->cnremphasized = FALSE;
|
|---|
| 1609 | }
|
|---|
| 1610 | }
|
|---|
| 1611 | }
|
|---|
| 1612 | break;
|
|---|
| 1613 |
|
|---|
| 1614 | case UM_OPENWINDOWFORME:
|
|---|
| 1615 | if (dcd) {
|
|---|
| 1616 | if (mp1 && !IsFile((CHAR *)mp1))
|
|---|
| 1617 | OpenDirCnr(HWND_DESKTOP, hwndMain, dcd->hwndFrame, FALSE, (PSZ) mp1);
|
|---|
| 1618 | else if (mp1 && IsFile(mp1) == 1 &&
|
|---|
| 1619 | CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2)
|
|---|
| 1620 | StartArcCnr(HWND_DESKTOP,
|
|---|
| 1621 | dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
|
|---|
| 1622 | }
|
|---|
| 1623 | return 0;
|
|---|
| 1624 |
|
|---|
| 1625 | case MM_PORTHOLEINIT:
|
|---|
| 1626 | if (dcd) {
|
|---|
| 1627 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1628 | case 0:
|
|---|
| 1629 | case 1:
|
|---|
| 1630 | {
|
|---|
| 1631 | ULONG wmsg;
|
|---|
| 1632 |
|
|---|
| 1633 | wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
|
|---|
| 1634 | PortholeInit((HWND) WinSendMsg(dcd->hwndClient, wmsg, MPVOID,
|
|---|
| 1635 | MPVOID), mp1, mp2);
|
|---|
| 1636 | }
|
|---|
| 1637 | break;
|
|---|
| 1638 | }
|
|---|
| 1639 | }
|
|---|
| 1640 | break;
|
|---|
| 1641 |
|
|---|
| 1642 | case UM_INITMENU:
|
|---|
| 1643 | case WM_INITMENU:
|
|---|
| 1644 | if (dcd) {
|
|---|
| 1645 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1646 | case IDM_VIEWSMENU:
|
|---|
| 1647 | SetViewMenu((HWND) mp2, dcd->flWindowAttr);
|
|---|
| 1648 | WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
|
|---|
| 1649 | (dcd->lastselection != NULL));
|
|---|
| 1650 | CopyPresParams((HWND) mp2, hwnd);
|
|---|
| 1651 | break;
|
|---|
| 1652 |
|
|---|
| 1653 | case IDM_DETAILSSETUP:
|
|---|
| 1654 | SetDetailsSwitches((HWND) mp2, &dcd->ds);
|
|---|
| 1655 | break;
|
|---|
| 1656 |
|
|---|
| 1657 | case IDM_COMMANDSMENU:
|
|---|
| 1658 | SetupCommandMenu((HWND) mp2, hwnd);
|
|---|
| 1659 | break;
|
|---|
| 1660 |
|
|---|
| 1661 | case IDM_SORTSUBMENU:
|
|---|
| 1662 | SetSortChecks((HWND) mp2, CollectorsortFlags);
|
|---|
| 1663 | break;
|
|---|
| 1664 | }
|
|---|
| 1665 | dcd->hwndLastMenu = (HWND) mp2;
|
|---|
| 1666 | }
|
|---|
| 1667 | if (msg == WM_INITMENU)
|
|---|
| 1668 | break;
|
|---|
| 1669 | return 0;
|
|---|
| 1670 |
|
|---|
| 1671 | case UM_COLLECTFROMFILE:
|
|---|
| 1672 | if (mp1) {
|
|---|
| 1673 | # ifdef FORTIFY
|
|---|
| 1674 | Fortify_EnterScope();
|
|---|
| 1675 | Fortify_BecomeOwner(mp1);
|
|---|
| 1676 | # endif
|
|---|
| 1677 | if (!dcd) {
|
|---|
| 1678 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
|---|
| 1679 | free(mp1);
|
|---|
| 1680 | }
|
|---|
| 1681 | else {
|
|---|
| 1682 | if (!PostMsg(dcd->hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) {
|
|---|
| 1683 | Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
|
|---|
| 1684 | free(mp1);
|
|---|
| 1685 | }
|
|---|
| 1686 | }
|
|---|
| 1687 | # ifdef FORTIFY
|
|---|
| 1688 | DosSleep(1); // Let receiver take ownership
|
|---|
| 1689 | Fortify_LeaveScope();
|
|---|
| 1690 | # endif
|
|---|
| 1691 | }
|
|---|
| 1692 | return 0;
|
|---|
| 1693 |
|
|---|
| 1694 | case UM_COMMAND:
|
|---|
| 1695 | if (mp1) {
|
|---|
| 1696 | if (dcd) {
|
|---|
| 1697 | if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
|
|---|
| 1698 | Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
|
|---|
| 1699 | FreeListInfo((LISTINFO *) mp1);
|
|---|
| 1700 | }
|
|---|
| 1701 | else
|
|---|
| 1702 | return (MRESULT) TRUE;
|
|---|
| 1703 | }
|
|---|
| 1704 | else
|
|---|
| 1705 | FreeListInfo((LISTINFO *) mp1);
|
|---|
| 1706 | }
|
|---|
| 1707 | return 0;
|
|---|
| 1708 |
|
|---|
| 1709 | case UM_NOTIFY:
|
|---|
| 1710 | if (mp2)
|
|---|
| 1711 | AddNote((CHAR *)mp2);
|
|---|
| 1712 | return 0;
|
|---|
| 1713 |
|
|---|
| 1714 | case WM_COMMAND:
|
|---|
| 1715 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1716 | if (dcd) {
|
|---|
| 1717 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1718 | case IDM_SETTARGET:
|
|---|
| 1719 | SetTargetDir(hwnd, FALSE, NULL);
|
|---|
| 1720 | break;
|
|---|
| 1721 |
|
|---|
| 1722 | case IDM_CONTEXTMENU:
|
|---|
| 1723 | {
|
|---|
| 1724 | PCNRITEM pci;
|
|---|
| 1725 |
|
|---|
| 1726 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
|---|
| 1727 | PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(COLLECTOR_CNR,
|
|---|
| 1728 | CN_CONTEXTMENU),
|
|---|
| 1729 | MPFROMP(pci));
|
|---|
| 1730 | }
|
|---|
| 1731 | break;
|
|---|
| 1732 |
|
|---|
| 1733 | case IDM_SHOWALLFILES:
|
|---|
| 1734 | {
|
|---|
| 1735 | PCNRITEM pci;
|
|---|
| 1736 |
|
|---|
| 1737 | pci = WinSendMsg(hwnd,
|
|---|
| 1738 | CM_QUERYRECORDEMPHASIS,
|
|---|
| 1739 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
|---|
| 1740 | if (pci && (INT) pci != -1) {
|
|---|
| 1741 | static CHAR dirname[CCHMAXPATH];
|
|---|
| 1742 |
|
|---|
| 1743 | strcpy(dirname, pci->pszFileName);
|
|---|
| 1744 | MakeValidDir(dirname);
|
|---|
| 1745 | StartSeeAll(HWND_DESKTOP, FALSE, dirname);
|
|---|
| 1746 | }
|
|---|
| 1747 | }
|
|---|
| 1748 | break;
|
|---|
| 1749 |
|
|---|
| 1750 | case IDM_BEGINEDIT:
|
|---|
| 1751 | OpenEdit(hwnd);
|
|---|
| 1752 | break;
|
|---|
| 1753 |
|
|---|
| 1754 | case IDM_ENDEDIT:
|
|---|
| 1755 | WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
|
|---|
| 1756 | break;
|
|---|
| 1757 |
|
|---|
| 1758 | case IDM_SHOWSELECT:
|
|---|
| 1759 | QuickPopup(hwnd, dcd,
|
|---|
| 1760 | CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
|
|---|
| 1761 | IDM_SELECTSUBMENU);
|
|---|
| 1762 | break;
|
|---|
| 1763 |
|
|---|
| 1764 | case IDM_SHOWSORT:
|
|---|
| 1765 | QuickPopup(hwnd, dcd,
|
|---|
| 1766 | CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
|
|---|
| 1767 | IDM_SORTSUBMENU);
|
|---|
| 1768 | break;
|
|---|
| 1769 |
|
|---|
| 1770 | case IDM_VIEWORARC:
|
|---|
| 1771 | {
|
|---|
| 1772 | SWP swp;
|
|---|
| 1773 | PCNRITEM pci;
|
|---|
| 1774 |
|
|---|
| 1775 | pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
|
|---|
| 1776 | MPFROMLONG(CMA_FIRST),
|
|---|
| 1777 | MPFROMSHORT(CRA_CURSORED));
|
|---|
| 1778 | if (pci && (INT) pci != -1) {
|
|---|
| 1779 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
|---|
| 1780 | DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp,
|
|---|
| 1781 | pci->pszFileName);
|
|---|
| 1782 | }
|
|---|
| 1783 | }
|
|---|
| 1784 | break;
|
|---|
| 1785 |
|
|---|
| 1786 | case IDM_SEEALL:
|
|---|
| 1787 | StartSeeAll(HWND_DESKTOP, FALSE, NULL);
|
|---|
| 1788 | break;
|
|---|
| 1789 |
|
|---|
| 1790 | case IDM_COLLECTSELECT:
|
|---|
| 1791 | {
|
|---|
| 1792 | CHAR filename[CCHMAXPATH], *p, *pp;
|
|---|
| 1793 |
|
|---|
| 1794 | strcpy(filename, PCSZ_STARDOTLST);
|
|---|
| 1795 | size = CCHMAXPATH;
|
|---|
| 1796 | PrfQueryProfileData(fmprof, appname, "SaveToListName",
|
|---|
| 1797 | filename, &size);
|
|---|
| 1798 | pp = strrchr(filename, '\\');
|
|---|
| 1799 | if (!pp)
|
|---|
| 1800 | pp = filename;
|
|---|
| 1801 | p = strrchr(pp, '.');
|
|---|
| 1802 | if (p && *(p + 1) && p > pp + 1) {
|
|---|
| 1803 | if (pp > filename)
|
|---|
| 1804 | pp++;
|
|---|
| 1805 | *pp = '*';
|
|---|
| 1806 | pp++;
|
|---|
| 1807 | if (p > pp)
|
|---|
| 1808 | memmove(pp, p, strlen(p) + 1);
|
|---|
| 1809 | }
|
|---|
| 1810 | if (insert_filename(hwnd, filename, FALSE, FALSE)) {
|
|---|
| 1811 | # ifdef FORTIFY
|
|---|
| 1812 | Fortify_EnterScope();
|
|---|
| 1813 | # endif
|
|---|
| 1814 | p = xstrdup(filename, pszSrcFile, __LINE__);
|
|---|
| 1815 | if (p) {
|
|---|
| 1816 | if (!PostMsg(hwnd, UM_COLLECTFROMFILE, MPFROMP(p), MPVOID))
|
|---|
| 1817 | free(p);
|
|---|
| 1818 | }
|
|---|
| 1819 | # ifdef FORTIFY
|
|---|
| 1820 | DosSleep(1); // Let receiver take ownership
|
|---|
| 1821 | Fortify_LeaveScope();
|
|---|
| 1822 | # endif
|
|---|
| 1823 | }
|
|---|
| 1824 | }
|
|---|
| 1825 | break;
|
|---|
| 1826 |
|
|---|
| 1827 | case IDM_COLLECTORVIEWSETTINGS:
|
|---|
| 1828 | if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
|
|---|
| 1829 | PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_COLLECTORVIEWSETTINGS), mp2);
|
|---|
| 1830 | else {
|
|---|
| 1831 | WinDlgBox(HWND_DESKTOP,
|
|---|
| 1832 | hwnd,
|
|---|
| 1833 | CfgDlgProc,
|
|---|
| 1834 | FM3ModHandle,
|
|---|
| 1835 | CFG_FRAME,
|
|---|
| 1836 | MPFROMLONG(IDM_COLLECTORVIEWSETTINGS));
|
|---|
| 1837 | }
|
|---|
| 1838 | break;
|
|---|
| 1839 |
|
|---|
| 1840 | case IDM_RESELECT:
|
|---|
| 1841 | SelectList(hwnd, FALSE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
|
|---|
| 1842 | break;
|
|---|
| 1843 |
|
|---|
| 1844 | case IDM_WALKDIR:
|
|---|
| 1845 | case IDM_OPENDIRWINDOW:
|
|---|
| 1846 | case IDM_OPENDIRICON:
|
|---|
| 1847 | case IDM_OPENDIRDETAILS:
|
|---|
| 1848 | case IDM_OPENDIRTREE:
|
|---|
| 1849 | {
|
|---|
| 1850 | CHAR newpath[CCHMAXPATH];
|
|---|
| 1851 | PCNRITEM pci;
|
|---|
| 1852 |
|
|---|
| 1853 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
|---|
| 1854 | if (pci && (INT) pci != -1) {
|
|---|
| 1855 | strcpy(newpath, pci->pszFileName);
|
|---|
| 1856 | MakeValidDir(newpath);
|
|---|
| 1857 | }
|
|---|
| 1858 | else
|
|---|
| 1859 | strcpy(newpath, pFM2SaveDirectory);
|
|---|
| 1860 | if (*newpath) {
|
|---|
| 1861 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1862 | case IDM_WALKDIR:
|
|---|
| 1863 | WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkAllDlgProc,
|
|---|
| 1864 | FM3ModHandle, WALK_FRAME, MPFROMP(newpath));
|
|---|
| 1865 | break;
|
|---|
| 1866 | case IDM_OPENDIRWINDOW:
|
|---|
| 1867 | WinSendMsg(hwnd, UM_OPENWINDOWFORME, MPFROMP(newpath), MPVOID);
|
|---|
| 1868 | break;
|
|---|
| 1869 | case IDM_OPENDIRICON:
|
|---|
| 1870 | OpenObject(newpath, PCSZ_ICON, hwnd);
|
|---|
| 1871 | break;
|
|---|
| 1872 | case IDM_OPENDIRDETAILS:
|
|---|
| 1873 | OpenObject(newpath, Details, hwnd);
|
|---|
| 1874 | break;
|
|---|
| 1875 | case IDM_OPENDIRTREE:
|
|---|
| 1876 | OpenObject(newpath, PCSZ_TREE, hwnd);
|
|---|
| 1877 | break;
|
|---|
| 1878 | default:
|
|---|
| 1879 | break;
|
|---|
| 1880 | }
|
|---|
| 1881 | }
|
|---|
| 1882 | }
|
|---|
| 1883 | break;
|
|---|
| 1884 |
|
|---|
| 1885 | case IDM_HELP:
|
|---|
| 1886 | if (hwndHelp)
|
|---|
| 1887 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
|---|
| 1888 | MPFROM2SHORT(HELP_COLLECT, 0),
|
|---|
| 1889 | MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 1890 | break;
|
|---|
| 1891 |
|
|---|
| 1892 | case IDM_SORTNONE:
|
|---|
| 1893 | case IDM_SORTSMARTNAME:
|
|---|
| 1894 | case IDM_SORTNAME:
|
|---|
| 1895 | case IDM_SORTFILENAME:
|
|---|
| 1896 | case IDM_SORTSIZE:
|
|---|
| 1897 | case IDM_SORTEASIZE:
|
|---|
| 1898 | case IDM_SORTFIRST:
|
|---|
| 1899 | case IDM_SORTLAST:
|
|---|
| 1900 | case IDM_SORTLWDATE:
|
|---|
| 1901 | case IDM_SORTLADATE:
|
|---|
| 1902 | case IDM_SORTCRDATE:
|
|---|
| 1903 | case IDM_SORTSUBJECT:
|
|---|
| 1904 | savedSortFlags = CollectorsortFlags;
|
|---|
| 1905 | CollectorsortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
|
|---|
| 1906 | case IDM_SORTDIRSFIRST:
|
|---|
| 1907 | case IDM_SORTDIRSLAST:
|
|---|
| 1908 | case IDM_SORTREVERSE:
|
|---|
| 1909 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1910 | case IDM_SORTSUBJECT:
|
|---|
| 1911 | CollectorsortFlags |= SORT_SUBJECT;
|
|---|
| 1912 | break;
|
|---|
| 1913 | case IDM_SORTNONE:
|
|---|
| 1914 | CollectorsortFlags |= SORT_NOSORT;
|
|---|
| 1915 | break;
|
|---|
| 1916 | case IDM_SORTSMARTNAME:
|
|---|
| 1917 | if (~savedSortFlags & SORT_FILENAME)
|
|---|
| 1918 | CollectorsortFlags |= SORT_FILENAME;
|
|---|
| 1919 | break;
|
|---|
| 1920 | case IDM_SORTFILENAME:
|
|---|
| 1921 | CollectorsortFlags |= SORT_FILENAME;
|
|---|
| 1922 | break;
|
|---|
| 1923 | case IDM_SORTSIZE:
|
|---|
| 1924 | CollectorsortFlags |= SORT_SIZE;
|
|---|
| 1925 | break;
|
|---|
| 1926 | case IDM_SORTEASIZE:
|
|---|
| 1927 | CollectorsortFlags |= SORT_EASIZE;
|
|---|
| 1928 | break;
|
|---|
| 1929 | case IDM_SORTFIRST:
|
|---|
| 1930 | CollectorsortFlags |= SORT_FIRSTEXTENSION;
|
|---|
| 1931 | break;
|
|---|
| 1932 | case IDM_SORTLAST:
|
|---|
| 1933 | CollectorsortFlags |= SORT_LASTEXTENSION;
|
|---|
| 1934 | break;
|
|---|
| 1935 | case IDM_SORTLWDATE:
|
|---|
| 1936 | CollectorsortFlags |= SORT_LWDATE;
|
|---|
| 1937 | break;
|
|---|
| 1938 | case IDM_SORTLADATE:
|
|---|
| 1939 | CollectorsortFlags |= SORT_LADATE;
|
|---|
| 1940 | break;
|
|---|
| 1941 | case IDM_SORTCRDATE:
|
|---|
| 1942 | CollectorsortFlags |= SORT_CRDATE;
|
|---|
| 1943 | break;
|
|---|
| 1944 | case IDM_SORTDIRSFIRST:
|
|---|
| 1945 | if (CollectorsortFlags & SORT_DIRSFIRST)
|
|---|
| 1946 | CollectorsortFlags &= (~SORT_DIRSFIRST);
|
|---|
| 1947 | else {
|
|---|
| 1948 | CollectorsortFlags |= SORT_DIRSFIRST;
|
|---|
| 1949 | CollectorsortFlags &= (~SORT_DIRSLAST);
|
|---|
| 1950 | }
|
|---|
| 1951 | break;
|
|---|
| 1952 | case IDM_SORTDIRSLAST:
|
|---|
| 1953 | if (CollectorsortFlags & SORT_DIRSLAST)
|
|---|
| 1954 | CollectorsortFlags &= (~SORT_DIRSLAST);
|
|---|
| 1955 | else {
|
|---|
| 1956 | CollectorsortFlags |= SORT_DIRSLAST;
|
|---|
| 1957 | CollectorsortFlags &= (~SORT_DIRSFIRST);
|
|---|
| 1958 | }
|
|---|
| 1959 | break;
|
|---|
| 1960 | case IDM_SORTREVERSE:
|
|---|
| 1961 | if (CollectorsortFlags & SORT_REVERSE)
|
|---|
| 1962 | CollectorsortFlags &= (~SORT_REVERSE);
|
|---|
| 1963 | else
|
|---|
| 1964 | CollectorsortFlags |= SORT_REVERSE;
|
|---|
| 1965 | break;
|
|---|
| 1966 | }
|
|---|
| 1967 | PrfWriteProfileData(fmprof, appname, "CollectorSort",
|
|---|
| 1968 | &CollectorsortFlags, sizeof(INT));
|
|---|
| 1969 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
|
|---|
| 1970 | SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1971 | DIR_SORT), CollectorsortFlags, FALSE);
|
|---|
| 1972 | break;
|
|---|
| 1973 |
|
|---|
| 1974 | case IDM_COLLECTFROMCLIP:
|
|---|
| 1975 | {
|
|---|
| 1976 | LISTINFO *li;
|
|---|
| 1977 | # ifdef FORTIFY
|
|---|
| 1978 | Fortify_EnterScope();
|
|---|
| 1979 | # endif
|
|---|
| 1980 | li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
|
|---|
| 1981 | if (li) {
|
|---|
| 1982 | li->list = ListFromClipboard(hwnd);
|
|---|
| 1983 | if (!li->list || !li->list[0])
|
|---|
| 1984 | FreeListInfo(li);
|
|---|
| 1985 | else {
|
|---|
| 1986 | li->type = IDM_COLLECT;
|
|---|
| 1987 | if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
|
|---|
| 1988 | FreeListInfo(li);
|
|---|
| 1989 | }
|
|---|
| 1990 | }
|
|---|
| 1991 | # ifdef FORTIFY
|
|---|
| 1992 | DosSleep(1); // Let receiver take ownership
|
|---|
| 1993 | Fortify_LeaveScope();
|
|---|
| 1994 | # endif
|
|---|
| 1995 | }
|
|---|
| 1996 | break;
|
|---|
| 1997 |
|
|---|
| 1998 | case IDM_REMOVE:
|
|---|
| 1999 | if (fAutoView && hwndMain)
|
|---|
| 2000 | PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
|
|---|
| 2001 | dcd->suspendview = 1;
|
|---|
| 2002 | RemoveAll(hwnd, &dcd->ullTotalBytes, &dcd->totalfiles);
|
|---|
| 2003 | dcd->suspendview = 0;
|
|---|
| 2004 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 2005 | break;
|
|---|
| 2006 |
|
|---|
| 2007 | case IDM_CLEARCNR:
|
|---|
| 2008 | {
|
|---|
| 2009 | PCNRITEM pci;
|
|---|
| 2010 |
|
|---|
| 2011 | pci = (PCNRITEM) WinSendMsg(hwnd,
|
|---|
| 2012 | CM_QUERYRECORD,
|
|---|
| 2013 | MPVOID,
|
|---|
| 2014 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
|---|
| 2015 | if (pci && (INT) pci != -1) {
|
|---|
| 2016 | RemoveCnrItems(hwnd, NULL, 0, CMA_FREE | CMA_INVALIDATE);
|
|---|
| 2017 | dcd->ullTotalBytes = dcd->selectedbytes = dcd->selectedfiles =
|
|---|
| 2018 | dcd->totalfiles = 0;
|
|---|
| 2019 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 2020 | }
|
|---|
| 2021 | }
|
|---|
| 2022 | break;
|
|---|
| 2023 |
|
|---|
| 2024 | case DID_CANCEL:
|
|---|
| 2025 | if (dcd->amextracted)
|
|---|
| 2026 | dcd->stopflag = 1; // Request cancel
|
|---|
| 2027 | break;
|
|---|
| 2028 |
|
|---|
| 2029 | case IDM_COLLECTOR:
|
|---|
| 2030 | if (mp2) {
|
|---|
| 2031 | LISTINFO *li;
|
|---|
| 2032 | # ifdef FORTIFY
|
|---|
| 2033 | Fortify_EnterScope();
|
|---|
| 2034 | # endif
|
|---|
| 2035 | li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
|
|---|
| 2036 | if (li) {
|
|---|
| 2037 | li->list = mp2;
|
|---|
| 2038 | if (!li->list || !li->list[0])
|
|---|
| 2039 | FreeListInfo(li);
|
|---|
| 2040 | else {
|
|---|
| 2041 | li->type = IDM_COLLECT;
|
|---|
| 2042 | if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
|
|---|
| 2043 | FreeListInfo(li);
|
|---|
| 2044 | }
|
|---|
| 2045 | }
|
|---|
| 2046 | else
|
|---|
| 2047 | FreeList(mp2);
|
|---|
| 2048 | # ifdef FORTIFY
|
|---|
| 2049 | DosSleep(1); // Let receiver take ownership
|
|---|
| 2050 | Fortify_LeaveScope();
|
|---|
| 2051 | # endif
|
|---|
| 2052 | }
|
|---|
| 2053 | break;
|
|---|
| 2054 |
|
|---|
| 2055 | case IDM_UNDELETE:
|
|---|
| 2056 | {
|
|---|
| 2057 | PCNRITEM pci;
|
|---|
| 2058 | CHAR path[CCHMAXPATH];
|
|---|
| 2059 | HOBJECT hObject;
|
|---|
| 2060 | HWND hwndDesktop;
|
|---|
| 2061 |
|
|---|
| 2062 | hObject = WinQueryObject("<XWP_TRASHCAN>");
|
|---|
| 2063 | if (hObject != NULLHANDLE && fTrashCan) {
|
|---|
| 2064 | hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
|
|---|
| 2065 | WinSetFocus(HWND_DESKTOP, hwndDesktop);
|
|---|
| 2066 | WinOpenObject(hObject, 0, TRUE);
|
|---|
| 2067 | }
|
|---|
| 2068 | else {
|
|---|
| 2069 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
|---|
| 2070 | if (pci && (INT) pci != -1) {
|
|---|
| 2071 | strcpy(path, pci->pszFileName);
|
|---|
| 2072 | MakeValidDir(path);
|
|---|
| 2073 | WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
|
|---|
| 2074 | UNDEL_FRAME, MPFROMP(path));
|
|---|
| 2075 | }
|
|---|
| 2076 | }
|
|---|
| 2077 | }
|
|---|
| 2078 | break;
|
|---|
| 2079 |
|
|---|
| 2080 | case IDM_GREP:
|
|---|
| 2081 | case UM_GREP:
|
|---|
| 2082 | if (dcd->amextracted) {
|
|---|
| 2083 | saymsg(MB_OK | MB_ICONASTERISK,
|
|---|
| 2084 | hwnd,
|
|---|
| 2085 | GetPString(IDS_WARNINGTEXT),
|
|---|
| 2086 | "Collector busy - please try again later");
|
|---|
| 2087 | }
|
|---|
| 2088 | else {
|
|---|
| 2089 | GREPINFO *GrepInfo;
|
|---|
| 2090 |
|
|---|
| 2091 | GrepInfo = xmallocz(sizeof(GREPINFO), pszSrcFile, __LINE__);
|
|---|
| 2092 | if (GrepInfo) {
|
|---|
| 2093 | GrepInfo->hwnd = &hwnd;
|
|---|
| 2094 | if (msg == UM_GREP && mp2)
|
|---|
| 2095 | GrepInfo->szGrepPath = mp2;
|
|---|
| 2096 | if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc,
|
|---|
| 2097 | FM3ModHandle, GREP_FRAME, (PVOID) GrepInfo)) {
|
|---|
| 2098 | free(GrepInfo);
|
|---|
| 2099 | dcd->amextracted = TRUE; // Say busy scanning
|
|---|
| 2100 | disable_menuitem(WinWindowFromID
|
|---|
| 2101 | (WinQueryWindow(hwndMain, QW_PARENT), FID_MENU),
|
|---|
| 2102 | IDM_GREP, TRUE);
|
|---|
| 2103 | disable_menuitem(TreeMenu, IDM_GREP, TRUE);
|
|---|
| 2104 | disable_menuitem(DirMenu, IDM_GREP, TRUE);
|
|---|
| 2105 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 2106 | }
|
|---|
| 2107 | else
|
|---|
| 2108 | free(GrepInfo);
|
|---|
| 2109 | }
|
|---|
| 2110 | }
|
|---|
| 2111 | break;
|
|---|
| 2112 |
|
|---|
| 2113 | case IDM_RESORT:
|
|---|
| 2114 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
|
|---|
| 2115 | break;
|
|---|
| 2116 |
|
|---|
| 2117 | case IDM_FILTER:
|
|---|
| 2118 | {
|
|---|
| 2119 | BOOL empty = FALSE;
|
|---|
| 2120 | PCNRITEM pci;
|
|---|
| 2121 | CHAR *p;
|
|---|
| 2122 |
|
|---|
| 2123 | if (!*dcd->mask.szMask) {
|
|---|
| 2124 | empty = TRUE;
|
|---|
| 2125 | // 2013-12-13 SHL Allow nul pszFileName
|
|---|
| 2126 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
|---|
| 2127 | if (pci && pci->pszFileName && ~pci->attrFile & FILE_DIRECTORY) {
|
|---|
| 2128 | p = strrchr(pci->pszFileName, '\\');
|
|---|
| 2129 | if (p) {
|
|---|
| 2130 | p++;
|
|---|
| 2131 | strcpy(dcd->mask.szMask, p);
|
|---|
| 2132 | }
|
|---|
| 2133 | }
|
|---|
| 2134 | }
|
|---|
| 2135 | *(dcd->mask.prompt) = 0;
|
|---|
| 2136 |
|
|---|
| 2137 | if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
|
|---|
| 2138 | FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
|
|---|
| 2139 | size = sizeof(MASK);
|
|---|
| 2140 | PrfWriteProfileData(fmprof, appname, "CollectorFilter",
|
|---|
| 2141 | &dcd->mask, size);
|
|---|
| 2142 | dcd->suspendview = 1;
|
|---|
| 2143 | WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
|
|---|
| 2144 | dcd->suspendview = 0;
|
|---|
| 2145 | if (fAutoView && hwndMain) {
|
|---|
| 2146 | pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
|
|---|
| 2147 | MPFROMLONG(CMA_FIRST),
|
|---|
| 2148 | MPFROMSHORT(CRA_CURSORED));
|
|---|
| 2149 | if (pci && (INT) pci != -1 &&
|
|---|
| 2150 | (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
|
|---|
| 2151 | DRIVE_SLOW)))
|
|---|
| 2152 | WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName),
|
|---|
| 2153 | MPVOID);
|
|---|
| 2154 | else
|
|---|
| 2155 | WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
|
|---|
| 2156 | }
|
|---|
| 2157 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 2158 | }
|
|---|
| 2159 | else if (empty)
|
|---|
| 2160 | *dcd->mask.szMask = 0;
|
|---|
| 2161 | SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 2162 | DIR_FILTER), &dcd->mask, FALSE);
|
|---|
| 2163 | }
|
|---|
| 2164 | break;
|
|---|
| 2165 |
|
|---|
| 2166 | case IDM_UNHIDEALL:
|
|---|
| 2167 | WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
|
|---|
| 2168 | break;
|
|---|
| 2169 |
|
|---|
| 2170 | case IDM_HIDEALL:
|
|---|
| 2171 | if (fAutoView && hwndMain)
|
|---|
| 2172 | PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
|
|---|
| 2173 | dcd->suspendview = 1;
|
|---|
| 2174 | HideAll(hwnd);
|
|---|
| 2175 | dcd->suspendview = 0;
|
|---|
| 2176 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 2177 | break;
|
|---|
| 2178 |
|
|---|
| 2179 | case IDM_SELECTLIST:
|
|---|
| 2180 | case IDM_SELECTALL:
|
|---|
| 2181 | case IDM_DESELECTALL:
|
|---|
| 2182 | case IDM_SELECTALLFILES:
|
|---|
| 2183 | case IDM_DESELECTALLFILES:
|
|---|
| 2184 | case IDM_SELECTALLDIRS:
|
|---|
| 2185 | case IDM_DESELECTALLDIRS:
|
|---|
| 2186 | case IDM_SELECTMASK:
|
|---|
| 2187 | case IDM_DESELECTMASK:
|
|---|
| 2188 | case IDM_INVERT:
|
|---|
| 2189 | case IDM_SELECTCLIP:
|
|---|
| 2190 | case IDM_DESELECTCLIP:
|
|---|
| 2191 | {
|
|---|
| 2192 | PCNRITEM pci;
|
|---|
| 2193 |
|
|---|
| 2194 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
|---|
| 2195 | if ((INT) pci == -1)
|
|---|
| 2196 | pci = NULL;
|
|---|
| 2197 | if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
|
|---|
| 2198 | if (pci) {
|
|---|
| 2199 | if (!(pci->rc.flRecordAttr & CRA_SELECTED))
|
|---|
| 2200 | pci->rc.flRecordAttr |= CRA_FILTERED;
|
|---|
| 2201 | WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
|
|---|
| 2202 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
|
|---|
| 2203 | break;
|
|---|
| 2204 | }
|
|---|
| 2205 | }
|
|---|
| 2206 | PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
|
|---|
| 2207 | }
|
|---|
| 2208 | break;
|
|---|
| 2209 |
|
|---|
| 2210 | case IDM_RESCAN:
|
|---|
| 2211 | PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 2212 | break;
|
|---|
| 2213 |
|
|---|
| 2214 | case IDM_SHOWLNAMES:
|
|---|
| 2215 | case IDM_SHOWSUBJECT:
|
|---|
| 2216 | case IDM_SHOWEAS:
|
|---|
| 2217 | case IDM_SHOWSIZE:
|
|---|
| 2218 | case IDM_SHOWICON:
|
|---|
| 2219 | case IDM_SHOWLWDATE:
|
|---|
| 2220 | case IDM_SHOWLWTIME:
|
|---|
| 2221 | case IDM_SHOWLADATE:
|
|---|
| 2222 | case IDM_SHOWLATIME:
|
|---|
| 2223 | case IDM_SHOWCRDATE:
|
|---|
| 2224 | case IDM_SHOWCRTIME:
|
|---|
| 2225 | case IDM_SHOWATTR:
|
|---|
| 2226 | AdjustDetailsSwitches(hwnd, dcd->hwndLastMenu,
|
|---|
| 2227 | SHORT1FROMMP(mp1), NULL,
|
|---|
| 2228 | PCSZ_COLLECTOR, &dcd->ds, FALSE);
|
|---|
| 2229 | break;
|
|---|
| 2230 |
|
|---|
| 2231 | case IDM_ICON:
|
|---|
| 2232 | case IDM_TEXT:
|
|---|
| 2233 | case IDM_DETAILS:
|
|---|
| 2234 | case IDM_NAME:
|
|---|
| 2235 | case IDM_MINIICONS:
|
|---|
| 2236 | case IDM_DETAILSTITLES:
|
|---|
| 2237 | {
|
|---|
| 2238 | CNRINFO cnri;
|
|---|
| 2239 |
|
|---|
| 2240 | memset(&cnri, 0, sizeof(CNRINFO));
|
|---|
| 2241 | cnri.cb = sizeof(CNRINFO);
|
|---|
| 2242 | WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
|
|---|
| 2243 | MPFROMLONG(sizeof(CNRINFO)));
|
|---|
| 2244 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 2245 | case IDM_ICON:
|
|---|
| 2246 | cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
|
|---|
| 2247 | CV_DETAIL | CV_NAME));
|
|---|
| 2248 | cnri.flWindowAttr |= CV_ICON;
|
|---|
| 2249 | break;
|
|---|
| 2250 | case IDM_NAME:
|
|---|
| 2251 | cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
|
|---|
| 2252 | CV_DETAIL | CV_NAME));
|
|---|
| 2253 | cnri.flWindowAttr |= CV_NAME;
|
|---|
| 2254 | break;
|
|---|
| 2255 | case IDM_TEXT:
|
|---|
| 2256 | cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
|
|---|
| 2257 | CV_DETAIL | CV_NAME));
|
|---|
| 2258 | cnri.flWindowAttr |= CV_TEXT;
|
|---|
| 2259 | break;
|
|---|
| 2260 | case IDM_DETAILS:
|
|---|
| 2261 | cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
|
|---|
| 2262 | CV_DETAIL | CV_NAME));
|
|---|
| 2263 | cnri.flWindowAttr |= CV_DETAIL;
|
|---|
| 2264 | break;
|
|---|
| 2265 | case IDM_MINIICONS:
|
|---|
| 2266 | if (cnri.flWindowAttr & CV_MINI)
|
|---|
| 2267 | cnri.flWindowAttr &= (~CV_MINI);
|
|---|
| 2268 | else
|
|---|
| 2269 | cnri.flWindowAttr |= CV_MINI;
|
|---|
| 2270 | break;
|
|---|
| 2271 | case IDM_DETAILSTITLES:
|
|---|
| 2272 | if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
|
|---|
| 2273 | cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
|
|---|
| 2274 | else
|
|---|
| 2275 | cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
|
|---|
| 2276 | break;
|
|---|
| 2277 | }
|
|---|
| 2278 | cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
|
|---|
| 2279 | cnri.flWindowAttr |= CV_FLOW;
|
|---|
| 2280 | dcd->flWindowAttr = cnri.flWindowAttr;
|
|---|
| 2281 | PrfWriteProfileData(fmprof, appname, "CollectorflWindowAttr",
|
|---|
| 2282 | &cnri.flWindowAttr, sizeof(ULONG));
|
|---|
| 2283 | WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
|
|---|
| 2284 | MPFROMLONG(CMA_FLWINDOWATTR));
|
|---|
| 2285 | WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
|
|---|
| 2286 | MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
|---|
| 2287 | SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 2288 | DIR_VIEW), dcd->flWindowAttr);
|
|---|
| 2289 | }
|
|---|
| 2290 | break;
|
|---|
| 2291 |
|
|---|
| 2292 | case IDM_SAVETOLIST:
|
|---|
| 2293 | WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
|
|---|
| 2294 | SAV_FRAME, MPFROMP(&hwnd));
|
|---|
| 2295 | break;
|
|---|
| 2296 |
|
|---|
| 2297 | case IDM_SIZES:
|
|---|
| 2298 | {
|
|---|
| 2299 | PCNRITEM pci;
|
|---|
| 2300 |
|
|---|
| 2301 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
|---|
| 2302 | if (pci && (INT) pci != -1)
|
|---|
| 2303 | WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DirSizeProc, FM3ModHandle,
|
|---|
| 2304 | DSZ_FRAME, pci->pszFileName);
|
|---|
| 2305 | }
|
|---|
| 2306 | break;
|
|---|
| 2307 |
|
|---|
| 2308 | case IDM_MKDIR:
|
|---|
| 2309 | {
|
|---|
| 2310 | PCNRITEM pci;
|
|---|
| 2311 |
|
|---|
| 2312 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
|---|
| 2313 | PMMkDir(dcd->hwndParent, (pci && (INT) pci != -1) ?
|
|---|
| 2314 | pci->pszFileName : NULL, FALSE);
|
|---|
| 2315 | }
|
|---|
| 2316 | break;
|
|---|
| 2317 |
|
|---|
| 2318 | case IDM_DOITYOURSELF:
|
|---|
| 2319 | case IDM_UPDATE:
|
|---|
| 2320 | case IDM_COLLECTFROMFILE:
|
|---|
| 2321 | case IDM_OPENWINDOW:
|
|---|
| 2322 | case IDM_OPENSETTINGS:
|
|---|
| 2323 | case IDM_OPENDEFAULT:
|
|---|
| 2324 | case IDM_OPENICON:
|
|---|
| 2325 | case IDM_OPENDETAILS:
|
|---|
| 2326 | case IDM_OPENTREE:
|
|---|
| 2327 | case IDM_OBJECT:
|
|---|
| 2328 | case IDM_SHADOW:
|
|---|
| 2329 | case IDM_SHADOW2:
|
|---|
| 2330 | case IDM_DELETE:
|
|---|
| 2331 | case IDM_PERMDELETE:
|
|---|
| 2332 | case IDM_PRINT:
|
|---|
| 2333 | case IDM_ATTRS:
|
|---|
| 2334 | case IDM_INFO:
|
|---|
| 2335 | case IDM_COPY:
|
|---|
| 2336 | case IDM_MOVE:
|
|---|
| 2337 | case IDM_WPSCOPY:
|
|---|
| 2338 | case IDM_WPSMOVE:
|
|---|
| 2339 | case IDM_COPYPRESERVE:
|
|---|
| 2340 | case IDM_MOVEPRESERVE:
|
|---|
| 2341 | case IDM_WILDCOPY:
|
|---|
| 2342 | case IDM_WILDMOVE:
|
|---|
| 2343 | case IDM_RENAME:
|
|---|
| 2344 | case IDM_COMPARE:
|
|---|
| 2345 | case IDM_EAS:
|
|---|
| 2346 | case IDM_SUBJECT:
|
|---|
| 2347 | case IDM_VIEW:
|
|---|
| 2348 | case IDM_VIEWTEXT:
|
|---|
| 2349 | case IDM_VIEWBINARY:
|
|---|
| 2350 | case IDM_VIEWARCHIVE:
|
|---|
| 2351 | case IDM_EDIT:
|
|---|
| 2352 | case IDM_EDITTEXT:
|
|---|
| 2353 | case IDM_EDITBINARY:
|
|---|
| 2354 | case IDM_SAVETOCLIP:
|
|---|
| 2355 | case IDM_SAVETOCLIPFILENAME:
|
|---|
| 2356 | case IDM_APPENDTOCLIP:
|
|---|
| 2357 | case IDM_APPENDTOCLIPFILENAME:
|
|---|
| 2358 | case IDM_ARCHIVE:
|
|---|
| 2359 | case IDM_ARCHIVEM:
|
|---|
| 2360 | case IDM_EXTRACT:
|
|---|
| 2361 | case IDM_MCIPLAY:
|
|---|
| 2362 | case IDM_UUDECODE:
|
|---|
| 2363 | case IDM_UNLOCKFILE:
|
|---|
| 2364 | case IDM_MERGE:
|
|---|
| 2365 | {
|
|---|
| 2366 | LISTINFO *li;
|
|---|
| 2367 | ULONG action = UM_ACTION;
|
|---|
| 2368 | # ifdef FORTIFY
|
|---|
| 2369 | Fortify_EnterScope();
|
|---|
| 2370 | # endif
|
|---|
| 2371 | li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
|
|---|
| 2372 | if (li) {
|
|---|
| 2373 | li->type = SHORT1FROMMP(mp1);
|
|---|
| 2374 | li->hwnd = hwnd;
|
|---|
| 2375 | li->list = BuildList(hwnd);
|
|---|
| 2376 | if (li->list) {
|
|---|
| 2377 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 2378 | case IDM_DOITYOURSELF:
|
|---|
| 2379 | case IDM_APPENDTOCLIP:
|
|---|
| 2380 | case IDM_APPENDTOCLIPFILENAME:
|
|---|
| 2381 | case IDM_SAVETOCLIP:
|
|---|
| 2382 | case IDM_SAVETOCLIPFILENAME:
|
|---|
| 2383 | case IDM_ARCHIVE:
|
|---|
| 2384 | case IDM_ARCHIVEM:
|
|---|
| 2385 | case IDM_DELETE:
|
|---|
| 2386 | case IDM_PERMDELETE:
|
|---|
| 2387 | case IDM_ATTRS:
|
|---|
| 2388 | case IDM_PRINT:
|
|---|
| 2389 | case IDM_SHADOW:
|
|---|
| 2390 | case IDM_SHADOW2:
|
|---|
| 2391 | case IDM_OBJECT:
|
|---|
| 2392 | case IDM_VIEW:
|
|---|
| 2393 | case IDM_VIEWTEXT:
|
|---|
| 2394 | case IDM_VIEWBINARY:
|
|---|
| 2395 | case IDM_EDIT:
|
|---|
| 2396 | case IDM_EDITTEXT:
|
|---|
| 2397 | case IDM_EDITBINARY:
|
|---|
| 2398 | case IDM_MCIPLAY:
|
|---|
| 2399 | case IDM_UPDATE:
|
|---|
| 2400 | case IDM_INFO:
|
|---|
| 2401 | case IDM_EAS:
|
|---|
| 2402 | action = UM_MASSACTION;
|
|---|
| 2403 | break;
|
|---|
| 2404 | }
|
|---|
| 2405 | if (li->type == IDM_DELETE)
|
|---|
| 2406 | ignorereadonly = FALSE;
|
|---|
| 2407 | if (li->type == IDM_SHADOW || li->type == IDM_OBJECT ||
|
|---|
| 2408 | li->type == IDM_SHADOW2)
|
|---|
| 2409 | *li->targetpath = 0;
|
|---|
| 2410 | if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
|
|---|
| 2411 | Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
|
|---|
| 2412 | FreeListInfo(li);
|
|---|
| 2413 | }
|
|---|
| 2414 | else if (fUnHilite)
|
|---|
| 2415 | UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
|
|---|
| 2416 | }
|
|---|
| 2417 | else
|
|---|
| 2418 | free(li);
|
|---|
| 2419 | }
|
|---|
| 2420 | # ifdef FORTIFY
|
|---|
| 2421 | Fortify_LeaveScope();
|
|---|
| 2422 | # endif
|
|---|
| 2423 | }
|
|---|
| 2424 | break;
|
|---|
| 2425 |
|
|---|
| 2426 | default:
|
|---|
| 2427 | if (!cmdloaded)
|
|---|
| 2428 | load_commands();
|
|---|
| 2429 | if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
|
|---|
| 2430 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
|
|---|
| 2431 | INT x;
|
|---|
| 2432 |
|
|---|
| 2433 | x = SHORT1FROMMP(mp1); // - IDM_COMMANDSTART;
|
|---|
| 2434 | if (x >= 0) {
|
|---|
| 2435 | //x++;
|
|---|
| 2436 | RunCommand(hwnd, x);
|
|---|
| 2437 | if (fUnHilite)
|
|---|
| 2438 | UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
|
|---|
| 2439 | }
|
|---|
| 2440 | }
|
|---|
| 2441 | break;
|
|---|
| 2442 | }
|
|---|
| 2443 | }
|
|---|
| 2444 | return 0;
|
|---|
| 2445 |
|
|---|
| 2446 | case UM_FIXCNRMLE:
|
|---|
| 2447 | case UM_FIXEDITNAME:
|
|---|
| 2448 | return CommonCnrProc(hwnd, msg, mp1, mp2);
|
|---|
| 2449 |
|
|---|
| 2450 | case UM_FILESMENU:
|
|---|
| 2451 | {
|
|---|
| 2452 | PCNRITEM pci;
|
|---|
| 2453 | HWND menuHwnd = (HWND) 0;
|
|---|
| 2454 |
|
|---|
| 2455 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
|---|
| 2456 | if (pci && (INT) pci != -1) {
|
|---|
| 2457 | if (pci->attrFile & FILE_DIRECTORY)
|
|---|
| 2458 | menuHwnd = CheckMenu(hwnd, &CollectorDirMenu, COLLECTORDIR_POPUP);
|
|---|
| 2459 | else
|
|---|
| 2460 | menuHwnd = CheckMenu(hwnd, &CollectorFileMenu, COLLECTORFILE_POPUP);
|
|---|
| 2461 | }
|
|---|
| 2462 | return MRFROMLONG(menuHwnd);
|
|---|
| 2463 | }
|
|---|
| 2464 |
|
|---|
| 2465 | case WM_CONTROL:
|
|---|
| 2466 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 2467 | if (dcd) {
|
|---|
| 2468 | switch (SHORT2FROMMP(mp1)) {
|
|---|
| 2469 | case CN_CONTEXTMENU:
|
|---|
| 2470 | {
|
|---|
| 2471 | PCNRITEM pci = (PCNRITEM) mp2;
|
|---|
| 2472 |
|
|---|
| 2473 | if (pci) {
|
|---|
| 2474 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
|---|
| 2475 | MPFROM2SHORT(TRUE, CRA_CURSORED));
|
|---|
| 2476 | MarkAll(hwnd, FALSE, FALSE, TRUE);
|
|---|
| 2477 | if (pci->attrFile & FILE_DIRECTORY)
|
|---|
| 2478 | dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorDirMenu,
|
|---|
| 2479 | COLLECTORDIR_POPUP);
|
|---|
| 2480 | else
|
|---|
| 2481 | dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorFileMenu,
|
|---|
| 2482 | COLLECTORFILE_POPUP);
|
|---|
| 2483 | }
|
|---|
| 2484 | else {
|
|---|
| 2485 | dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorCnrMenu,
|
|---|
| 2486 | COLLECTORCNR_POPUP);
|
|---|
| 2487 | if (dcd->hwndLastMenu && !dcd->cnremphasized) {
|
|---|
| 2488 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
|---|
| 2489 | MPFROM2SHORT(TRUE, CRA_SOURCE));
|
|---|
| 2490 | dcd->cnremphasized = TRUE;
|
|---|
| 2491 | }
|
|---|
| 2492 | }
|
|---|
| 2493 | if (dcd->hwndLastMenu) {
|
|---|
| 2494 | if (dcd->hwndLastMenu == CollectorCnrMenu) {
|
|---|
| 2495 | SetViewMenu(dcd->hwndLastMenu, dcd->flWindowAttr);
|
|---|
| 2496 | SetDetailsSwitches(dcd->hwndLastMenu, &dcd->ds);
|
|---|
| 2497 | CopyPresParams(dcd->hwndLastMenu, hwnd);
|
|---|
| 2498 | if (dcd->flWindowAttr & CV_MINI)
|
|---|
| 2499 | WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
|
|---|
| 2500 | disable_menuitem(dcd->hwndLastMenu, DID_CANCEL,
|
|---|
| 2501 | !dcd->amextracted);
|
|---|
| 2502 | disable_menuitem(dcd->hwndLastMenu, IDM_GREP, dcd->amextracted);
|
|---|
| 2503 | }
|
|---|
| 2504 | if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
|
|---|
| 2505 | if (dcd->cnremphasized) {
|
|---|
| 2506 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
|---|
| 2507 | MPFROM2SHORT(FALSE, CRA_SOURCE));
|
|---|
| 2508 | dcd->cnremphasized = TRUE;
|
|---|
| 2509 | }
|
|---|
| 2510 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
|---|
| 2511 | }
|
|---|
| 2512 | }
|
|---|
| 2513 | }
|
|---|
| 2514 | break;
|
|---|
| 2515 |
|
|---|
| 2516 | case CN_DROPHELP:
|
|---|
| 2517 | if (mp2) {
|
|---|
| 2518 | PDRAGINFO pDInfo;
|
|---|
| 2519 | PCNRITEM pci;
|
|---|
| 2520 | ULONG numitems;
|
|---|
| 2521 | USHORT usOperation;
|
|---|
| 2522 |
|
|---|
| 2523 | pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
|
|---|
| 2524 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
|---|
| 2525 | if (!DrgAccessDraginfo(pDInfo)) {
|
|---|
| 2526 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
|---|
| 2527 | PCSZ_DRGACCESSDRAGINFO);
|
|---|
| 2528 | return 0;
|
|---|
| 2529 | }
|
|---|
| 2530 | numitems = DrgQueryDragitemCount(pDInfo);
|
|---|
| 2531 | usOperation = pDInfo->usOperation;
|
|---|
| 2532 | if (usOperation == DO_DEFAULT)
|
|---|
| 2533 | usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
|
|---|
| 2534 | FreeDragInfoData(hwnd, pDInfo);
|
|---|
| 2535 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
|---|
| 2536 | hwnd,
|
|---|
| 2537 | GetPString(IDS_DROPHELPHDRTEXT),
|
|---|
| 2538 | GetPString(IDS_DROPHELPTEXT),
|
|---|
| 2539 | numitems,
|
|---|
| 2540 | &"s"[numitems == 1],
|
|---|
| 2541 | (pci) ? NullStr : GetPString(IDS_NOTEXT),
|
|---|
| 2542 | (pci) ? NullStr : " ",
|
|---|
| 2543 | (pci) ? pci->pszFileName : NullStr,
|
|---|
| 2544 | (pci) ? " " : NullStr,
|
|---|
| 2545 | GetPString((usOperation == DO_COPY) ?
|
|---|
| 2546 | IDS_COPYTEXT :
|
|---|
| 2547 | (usOperation == DO_LINK) ?
|
|---|
| 2548 | IDS_LINKTEXT : IDS_MOVETEXT));
|
|---|
| 2549 | }
|
|---|
| 2550 | return 0;
|
|---|
| 2551 |
|
|---|
| 2552 | case CN_DRAGLEAVE:
|
|---|
| 2553 | if (mp2) {
|
|---|
| 2554 | PDRAGINFO pDInfo;
|
|---|
| 2555 |
|
|---|
| 2556 | // fixme to know why needed
|
|---|
| 2557 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
|---|
| 2558 | DrgAccessDraginfo(pDInfo); // Access DRAGINFO
|
|---|
| 2559 | DrgFreeDraginfo(pDInfo); // Free DRAGINFO
|
|---|
| 2560 | }
|
|---|
| 2561 | return 0;
|
|---|
| 2562 |
|
|---|
| 2563 | case CN_DRAGAFTER:
|
|---|
| 2564 | case CN_DRAGOVER:
|
|---|
| 2565 | if (mp2) {
|
|---|
| 2566 | PDRAGITEM pDItem; // Pointer to DRAGITEM
|
|---|
| 2567 | PDRAGINFO pDInfo; // Pointer to DRAGINFO
|
|---|
| 2568 | PCNRITEM pci;
|
|---|
| 2569 | USHORT uso;
|
|---|
| 2570 |
|
|---|
| 2571 | pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
|
|---|
| 2572 | // if(SHORT1FROMMP(mp1) == CN_DRAGAFTER)
|
|---|
| 2573 | // pci = NULL;
|
|---|
| 2574 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
|---|
| 2575 | if (!DrgAccessDraginfo(pDInfo)) {
|
|---|
| 2576 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
|---|
| 2577 | PCSZ_DRGACCESSDRAGINFO);
|
|---|
| 2578 | return (MRFROM2SHORT(DOR_NODROP, 0)); // Drop not valid
|
|---|
| 2579 | }
|
|---|
| 2580 | if (pci) {
|
|---|
| 2581 | if (pci->rc.flRecordAttr & CRA_SOURCE) {
|
|---|
| 2582 | DrgFreeDraginfo(pDInfo);
|
|---|
| 2583 | return (MRFROM2SHORT(DOR_NODROP, 0));
|
|---|
| 2584 | }
|
|---|
| 2585 | uso = pDInfo->usOperation;
|
|---|
| 2586 | if (uso == DO_DEFAULT)
|
|---|
| 2587 | uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
|
|---|
| 2588 | if (!(pci->attrFile & FILE_DIRECTORY)) {
|
|---|
| 2589 | if (uso != DO_LINK && uso != DO_MOVE && uso != DO_COPY) {
|
|---|
| 2590 | DrgFreeDraginfo(pDInfo);
|
|---|
| 2591 | return MRFROM2SHORT(DOR_NODROP, 0);
|
|---|
| 2592 | }
|
|---|
| 2593 | if (uso != DO_LINK &&
|
|---|
| 2594 | !(driveflags[toupper(*pci->pszFileName) - 'A'] &
|
|---|
| 2595 | DRIVE_NOTWRITEABLE)) {
|
|---|
| 2596 | ARC_TYPE *info = NULL;
|
|---|
| 2597 |
|
|---|
| 2598 | if (!fQuickArcFind &&
|
|---|
| 2599 | !(driveflags[toupper(*pci->pszFileName) - 'A'] &
|
|---|
| 2600 | DRIVE_SLOW))
|
|---|
| 2601 | info = find_type(pci->pszFileName, NULL);
|
|---|
| 2602 | else
|
|---|
| 2603 | info = quick_find_type(pci->pszFileName, NULL);
|
|---|
| 2604 | if (!info || ((uso == DO_MOVE && !info->move) ||
|
|---|
| 2605 | (uso == DO_COPY && !info->create))) {
|
|---|
| 2606 | DrgFreeDraginfo(pDInfo);
|
|---|
| 2607 | return MRFROM2SHORT(DOR_NODROP, 0);
|
|---|
| 2608 | }
|
|---|
| 2609 | }
|
|---|
| 2610 | }
|
|---|
| 2611 | }
|
|---|
| 2612 | pDItem = DrgQueryDragitemPtr(pDInfo, // Access DRAGITEM
|
|---|
| 2613 | 0); // Index to DRAGITEM
|
|---|
| 2614 | if (DrgVerifyRMF(pDItem, // Check valid rendering
|
|---|
| 2615 | (CHAR *) DRM_OS2FILE, // mechanisms and data
|
|---|
| 2616 | NULL)) {
|
|---|
| 2617 | DrgFreeDraginfo(pDInfo); // Free DRAGINFO
|
|---|
| 2618 | if (pci) {
|
|---|
| 2619 | if (driveflags[toupper(*pci->pszFileName) - 'A'] &
|
|---|
| 2620 | DRIVE_NOTWRITEABLE)
|
|---|
| 2621 | return MRFROM2SHORT(DOR_DROP, DO_LINK);
|
|---|
| 2622 | if (toupper(*pci->pszFileName) < 'C')
|
|---|
| 2623 | return MRFROM2SHORT(DOR_DROP, DO_COPY);
|
|---|
| 2624 | return MRFROM2SHORT(DOR_DROP, // Return okay to drop
|
|---|
| 2625 | ((fCopyDefault) ? DO_COPY : DO_MOVE));
|
|---|
| 2626 | }
|
|---|
| 2627 | else
|
|---|
| 2628 | return MRFROM2SHORT(DOR_DROP, // Return okay to drop
|
|---|
| 2629 | DO_COPY);
|
|---|
| 2630 | }
|
|---|
| 2631 | DrgFreeDraginfo(pDInfo); // Free DRAGINFO
|
|---|
| 2632 | }
|
|---|
| 2633 | return (MRFROM2SHORT(DOR_NODROP, 0)); // Drop not valid
|
|---|
| 2634 |
|
|---|
| 2635 | case CN_INITDRAG:
|
|---|
| 2636 | if (mp2) {
|
|---|
| 2637 | BOOL wasemphasized = FALSE;
|
|---|
| 2638 | PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
|
|---|
| 2639 | PCNRITEM pci;
|
|---|
| 2640 |
|
|---|
| 2641 | if (pcd) {
|
|---|
| 2642 | pci = (PCNRITEM) pcd->pRecord;
|
|---|
| 2643 | if (pci) {
|
|---|
| 2644 | if (pci->rc.flRecordAttr & CRA_SELECTED)
|
|---|
| 2645 | wasemphasized = TRUE;
|
|---|
| 2646 | if (IsRoot(pci->pszFileName))
|
|---|
| 2647 | break;
|
|---|
| 2648 | if (hwndStatus2)
|
|---|
| 2649 | WinSetWindowText(hwndStatus2,
|
|---|
| 2650 | (CHAR *) GetPString(IDS_DRAGFILEOBJTEXT));
|
|---|
| 2651 | if (DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE)) {
|
|---|
| 2652 | if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
|
|---|
| 2653 | UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
|
|---|
| 2654 | }
|
|---|
| 2655 | if (hwndStatus2)
|
|---|
| 2656 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
|---|
| 2657 | }
|
|---|
| 2658 | }
|
|---|
| 2659 | }
|
|---|
| 2660 | return 0;
|
|---|
| 2661 |
|
|---|
| 2662 | case CN_DROP:
|
|---|
| 2663 | if (mp2) {
|
|---|
| 2664 | LISTINFO *li;
|
|---|
| 2665 | ULONG action = UM_ACTION;
|
|---|
| 2666 |
|
|---|
| 2667 | li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
|
|---|
| 2668 | CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
|
|---|
| 2669 | if (li) {
|
|---|
| 2670 | if (!*li->targetpath) {
|
|---|
| 2671 | li->type = IDM_COLLECT;
|
|---|
| 2672 | action = UM_COLLECT;
|
|---|
| 2673 | }
|
|---|
| 2674 | else {
|
|---|
| 2675 | if (li->list && li->list[0] && IsRoot(li->list[0]))
|
|---|
| 2676 | li->type = DO_LINK;
|
|---|
| 2677 | else if (fDragndropDlg && (!*li->arcname || !li->info)) {
|
|---|
| 2678 | CHECKLIST cl;
|
|---|
| 2679 |
|
|---|
| 2680 | memset(&cl, 0, sizeof(cl));
|
|---|
| 2681 | cl.size = sizeof(cl);
|
|---|
| 2682 | cl.flags = li->type;
|
|---|
| 2683 | cl.list = li->list;
|
|---|
| 2684 | cl.cmd = li->type;
|
|---|
| 2685 | cl.prompt = li->targetpath;
|
|---|
| 2686 | li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
|
|---|
| 2687 | DropListProc, FM3ModHandle,
|
|---|
| 2688 | DND_FRAME, MPFROMP(&cl));
|
|---|
| 2689 | if (li->type == DID_ERROR)
|
|---|
| 2690 | Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
|
|---|
| 2691 | GetPString(IDS_DRAGDROPDIALOGTEXT));
|
|---|
| 2692 | if (!li->type) {
|
|---|
| 2693 | FreeListInfo(li);
|
|---|
| 2694 | return 0;
|
|---|
| 2695 | }
|
|---|
| 2696 | li->list = cl.list;
|
|---|
| 2697 | if (!li->list || !li->list[0]) {
|
|---|
| 2698 | FreeListInfo(li);
|
|---|
| 2699 | return 0;
|
|---|
| 2700 | }
|
|---|
| 2701 | }
|
|---|
| 2702 | switch (li->type) {
|
|---|
| 2703 | case DND_LAUNCH:
|
|---|
| 2704 | strcat(li->targetpath, " %a");
|
|---|
| 2705 | ExecOnList(dcd->hwndParent, li->targetpath,
|
|---|
| 2706 | PROMPT | WINDOWED, NULL, NULL, li->list, NULL,
|
|---|
| 2707 | pszSrcFile, __LINE__);
|
|---|
| 2708 | FreeList(li->list);
|
|---|
| 2709 | li->list = NULL;
|
|---|
| 2710 | break;
|
|---|
| 2711 | case DO_LINK:
|
|---|
| 2712 | if (fLinkSetsIcon) {
|
|---|
| 2713 | li->type = IDM_SETICON;
|
|---|
| 2714 | action = UM_MASSACTION;
|
|---|
| 2715 | }
|
|---|
| 2716 | else
|
|---|
| 2717 | li->type = IDM_COMPARE;
|
|---|
| 2718 | break;
|
|---|
| 2719 | case DND_EXTRACT:
|
|---|
| 2720 | if (*li->targetpath && !IsFile(li->targetpath))
|
|---|
| 2721 | li->type = IDM_EXTRACT;
|
|---|
| 2722 | break;
|
|---|
| 2723 | case DND_MOVE:
|
|---|
| 2724 | li->type = IDM_MOVE;
|
|---|
| 2725 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
|---|
| 2726 | action = UM_MASSACTION;
|
|---|
| 2727 | li->type = IDM_ARCHIVEM;
|
|---|
| 2728 | }
|
|---|
| 2729 | break;
|
|---|
| 2730 | case DND_WILDMOVE:
|
|---|
| 2731 | li->type = IDM_WILDMOVE;
|
|---|
| 2732 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
|---|
| 2733 | action = UM_MASSACTION;
|
|---|
| 2734 | li->type = IDM_ARCHIVEM;
|
|---|
| 2735 | }
|
|---|
| 2736 | break;
|
|---|
| 2737 | case DND_OBJECT:
|
|---|
| 2738 | li->type = IDM_OBJECT;
|
|---|
| 2739 | action = UM_MASSACTION;
|
|---|
| 2740 | break;
|
|---|
| 2741 | case DND_SHADOW:
|
|---|
| 2742 | li->type = IDM_SHADOW;
|
|---|
| 2743 | action = UM_MASSACTION;
|
|---|
| 2744 | break;
|
|---|
| 2745 | case DND_COMPARE:
|
|---|
| 2746 | li->type = IDM_COMPARE;
|
|---|
| 2747 | break;
|
|---|
| 2748 | case DND_SETICON:
|
|---|
| 2749 | action = UM_MASSACTION;
|
|---|
| 2750 | li->type = IDM_SETICON;
|
|---|
| 2751 | break;
|
|---|
| 2752 | case DND_WILDCOPY:
|
|---|
| 2753 | li->type = IDM_WILDCOPY;
|
|---|
| 2754 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
|---|
| 2755 | action = UM_MASSACTION;
|
|---|
| 2756 | li->type = IDM_ARCHIVE;
|
|---|
| 2757 | }
|
|---|
| 2758 | break;
|
|---|
| 2759 | case DND_COPY:
|
|---|
| 2760 | li->type = IDM_COPY;
|
|---|
| 2761 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
|---|
| 2762 | action = UM_MASSACTION;
|
|---|
| 2763 | li->type = IDM_ARCHIVE;
|
|---|
| 2764 | }
|
|---|
| 2765 | break;
|
|---|
| 2766 | default:
|
|---|
| 2767 | if (*li->arcname && li->info) {
|
|---|
| 2768 | action = UM_MASSACTION;
|
|---|
| 2769 | li->type =
|
|---|
| 2770 | (li->type ==
|
|---|
| 2771 | DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
|
|---|
| 2772 | }
|
|---|
| 2773 | else if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
|---|
| 2774 | action = UM_MASSACTION;
|
|---|
| 2775 | li->type =
|
|---|
| 2776 | (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
|
|---|
| 2777 | }
|
|---|
| 2778 | else
|
|---|
| 2779 | li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
|
|---|
| 2780 | break;
|
|---|
| 2781 | } // switch
|
|---|
| 2782 | } // if !collect
|
|---|
| 2783 | if (!li->list || !li->list[0])
|
|---|
| 2784 | FreeListInfo(li);
|
|---|
| 2785 | else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
|
|---|
| 2786 | FreeListInfo(li);
|
|---|
| 2787 | else {
|
|---|
| 2788 | USHORT usop = 0;
|
|---|
| 2789 |
|
|---|
| 2790 | switch (li->type) {
|
|---|
| 2791 | case IDM_COPY:
|
|---|
| 2792 | case IDM_WILDCOPY:
|
|---|
| 2793 | usop = DO_COPY;
|
|---|
| 2794 | break;
|
|---|
| 2795 | case IDM_MOVE:
|
|---|
| 2796 | case IDM_WILDMOVE:
|
|---|
| 2797 | case IDM_ARCHIVEM:
|
|---|
| 2798 | usop = DO_MOVE;
|
|---|
| 2799 | break;
|
|---|
| 2800 | }
|
|---|
| 2801 | if (usop)
|
|---|
| 2802 | return MRFROM2SHORT(DOR_DROP, usop);
|
|---|
| 2803 | }
|
|---|
| 2804 | }
|
|---|
| 2805 | }
|
|---|
| 2806 | return 0;
|
|---|
| 2807 |
|
|---|
| 2808 | case CN_BEGINEDIT:
|
|---|
| 2809 | case CN_REALLOCPSZ:
|
|---|
| 2810 | case CN_ENDEDIT:
|
|---|
| 2811 | {
|
|---|
| 2812 | MRESULT mre;
|
|---|
| 2813 |
|
|---|
| 2814 | mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
|
|---|
| 2815 | if (mre != (MRESULT) - 1)
|
|---|
| 2816 | return mre;
|
|---|
| 2817 | }
|
|---|
| 2818 | break;
|
|---|
| 2819 |
|
|---|
| 2820 | case CN_EMPHASIS:
|
|---|
| 2821 | if (mp2) {
|
|---|
| 2822 | PNOTIFYRECORDEMPHASIS pre = mp2;
|
|---|
| 2823 | PCNRITEM pci;
|
|---|
| 2824 | CHAR s[CCHMAXPATH + 91], tb[81], tf[81], szDate[DATE_BUF_BYTES], *p;
|
|---|
| 2825 |
|
|---|
| 2826 | pci = (PCNRITEM) ((pre) ? pre->pRecord : NULL);
|
|---|
| 2827 | if (!pci) {
|
|---|
| 2828 | if (hwndStatus2)
|
|---|
| 2829 | WinSetWindowText(hwndStatus2, NullStr);
|
|---|
| 2830 | if (fMoreButtons) {
|
|---|
| 2831 | WinSetWindowText(hwndName, NullStr);
|
|---|
| 2832 | WinSetWindowText(hwndDate, NullStr);
|
|---|
| 2833 | WinSetWindowText(hwndAttr, NullStr);
|
|---|
| 2834 | }
|
|---|
| 2835 | if (hwndMain)
|
|---|
| 2836 | WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
|
|---|
| 2837 | break;
|
|---|
| 2838 | }
|
|---|
| 2839 | if (pre->fEmphasisMask & CRA_SELECTED) {
|
|---|
| 2840 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
|---|
| 2841 | dcd->selectedbytes += (pci->cbFile + pci->easize);
|
|---|
| 2842 | dcd->selectedfiles++;
|
|---|
| 2843 | }
|
|---|
| 2844 | else if (dcd->selectedfiles) {
|
|---|
| 2845 | dcd->selectedbytes -= (pci->cbFile + pci->easize);
|
|---|
| 2846 | dcd->selectedfiles--;
|
|---|
| 2847 | }
|
|---|
| 2848 | if (!dcd->suspendview) {
|
|---|
| 2849 | commafmt(tf, sizeof(tf), dcd->selectedfiles);
|
|---|
| 2850 | CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
|
|---|
| 2851 | sprintf(s, "%s / %s", tf, tb);
|
|---|
| 2852 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
|
|---|
| 2853 | }
|
|---|
| 2854 | }
|
|---|
| 2855 | if (!dcd->suspendview &&
|
|---|
| 2856 | WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
|
|---|
| 2857 | if (pre->fEmphasisMask & CRA_CURSORED) {
|
|---|
| 2858 | if (pci->rc.flRecordAttr & CRA_CURSORED) {
|
|---|
| 2859 | if (fSplitStatus && hwndStatus2) {
|
|---|
| 2860 | if (pci->attrFile & FILE_DIRECTORY)
|
|---|
| 2861 | p = pci->pszFileName;
|
|---|
| 2862 | else {
|
|---|
| 2863 | p = strrchr(pci->pszFileName, '\\');
|
|---|
| 2864 | if (p) {
|
|---|
| 2865 | if (*(p + 1))
|
|---|
| 2866 | p++;
|
|---|
| 2867 | else
|
|---|
| 2868 | p = pci->pszFileName;
|
|---|
| 2869 | }
|
|---|
| 2870 | else
|
|---|
| 2871 | p = pci->pszFileName;
|
|---|
| 2872 | }
|
|---|
| 2873 | CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
|
|---|
| 2874 | if (!fMoreButtons) {
|
|---|
| 2875 | DateFormat(szDate, pci->date);
|
|---|
| 2876 | sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
|
|---|
| 2877 | tb, szDate, pci->time.hours, TimeSeparator,
|
|---|
| 2878 | pci->time.minutes, TimeSeparator, pci->time.seconds,
|
|---|
| 2879 | pci->pszDispAttr, p);
|
|---|
| 2880 | }
|
|---|
| 2881 | else {
|
|---|
| 2882 | if (pci->cbFile + pci->easize > 1024)
|
|---|
| 2883 | CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize,
|
|---|
| 2884 | ' ');
|
|---|
| 2885 | else
|
|---|
| 2886 | *tf = 0;
|
|---|
| 2887 | sprintf(s, GetPString(IDS_STATUSSIZETEXT),
|
|---|
| 2888 | tb,
|
|---|
| 2889 | *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
|
|---|
| 2890 | }
|
|---|
| 2891 | WinSetWindowText(hwndStatus2, s);
|
|---|
| 2892 | }
|
|---|
| 2893 | if (fMoreButtons) {
|
|---|
| 2894 | WinSetWindowText(hwndName, pci->pszFileName);
|
|---|
| 2895 | DateFormat(szDate, pci->date);
|
|---|
| 2896 | sprintf(s, "%s %02u%s%02u%s%02u",
|
|---|
| 2897 | szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
|
|---|
| 2898 | TimeSeparator, pci->time.seconds);
|
|---|
| 2899 | WinSetWindowText(hwndDate, s);
|
|---|
| 2900 | WinSetWindowText(hwndAttr, pci->pszDispAttr);
|
|---|
| 2901 | }
|
|---|
| 2902 | }
|
|---|
| 2903 | }
|
|---|
| 2904 | }
|
|---|
| 2905 | if (!dcd->suspendview && hwndMain &&
|
|---|
| 2906 | (pre->fEmphasisMask & CRA_CURSORED) &&
|
|---|
| 2907 | (pci->rc.flRecordAttr & CRA_CURSORED) &&
|
|---|
| 2908 | WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame)
|
|---|
| 2909 | WinSendMsg(hwndMain, UM_LOADFILE,
|
|---|
| 2910 | MPFROMP(((fComments
|
|---|
| 2911 | || (pci->attrFile & FILE_DIRECTORY) ==
|
|---|
| 2912 | 0) ? pci->pszFileName : NULL)), MPVOID);
|
|---|
| 2913 | }
|
|---|
| 2914 | break;
|
|---|
| 2915 |
|
|---|
| 2916 | case CN_ENTER:
|
|---|
| 2917 | if (mp2) {
|
|---|
| 2918 | PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
|
|---|
| 2919 | FILEFINDBUF3 ffb;
|
|---|
| 2920 | HDIR hDir = HDIR_CREATE;
|
|---|
| 2921 | ULONG nm = 1;
|
|---|
| 2922 | APIRET status = 0;
|
|---|
| 2923 |
|
|---|
| 2924 | SetShiftState();
|
|---|
| 2925 | if (pci) {
|
|---|
| 2926 | if (pci->rc.flRecordAttr & CRA_INUSE)
|
|---|
| 2927 | break;
|
|---|
| 2928 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 2929 | status = DosFindFirst(pci->pszFileName, &hDir,
|
|---|
| 2930 | FILE_NORMAL | FILE_DIRECTORY |
|
|---|
| 2931 | FILE_ARCHIVED | FILE_READONLY |
|
|---|
| 2932 | FILE_HIDDEN | FILE_SYSTEM,
|
|---|
| 2933 | &ffb, sizeof(ffb), &nm, FIL_STANDARD);
|
|---|
| 2934 | priority_bumped();
|
|---|
| 2935 | if (!status) {
|
|---|
| 2936 | DosFindClose(hDir);
|
|---|
| 2937 | if (ffb.attrFile & FILE_DIRECTORY) {
|
|---|
| 2938 | if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
|
|---|
| 2939 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0),
|
|---|
| 2940 | MPVOID);
|
|---|
| 2941 | else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
|
|---|
| 2942 | (KC_CTRL | KC_SHIFT))
|
|---|
| 2943 | OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
|
|---|
| 2944 | else if (shiftstate & KC_CTRL)
|
|---|
| 2945 | OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
|
|---|
| 2946 | else
|
|---|
| 2947 | OpenDirCnr(HWND_DESKTOP,
|
|---|
| 2948 | hwndMain,
|
|---|
| 2949 | dcd->hwndFrame, FALSE, pci->pszFileName);
|
|---|
| 2950 | }
|
|---|
| 2951 | else {
|
|---|
| 2952 | SWP swp;
|
|---|
| 2953 |
|
|---|
| 2954 | WinSendMsg(hwnd,
|
|---|
| 2955 | CM_SETRECORDEMPHASIS,
|
|---|
| 2956 | MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
|
|---|
| 2957 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
|---|
| 2958 | DefaultViewKeys(hwnd,
|
|---|
| 2959 | dcd->hwndFrame,
|
|---|
| 2960 | dcd->hwndParent, &swp, pci->pszFileName);
|
|---|
| 2961 | WinSendMsg(hwnd,
|
|---|
| 2962 | CM_SETRECORDEMPHASIS,
|
|---|
| 2963 | MPFROMP(pci),
|
|---|
| 2964 | MPFROM2SHORT(FALSE, CRA_INUSE |
|
|---|
| 2965 | ((fUnHilite) ? CRA_SELECTED : 0)));
|
|---|
| 2966 | }
|
|---|
| 2967 | }
|
|---|
| 2968 | else
|
|---|
| 2969 | RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
|
|---|
| 2970 | }
|
|---|
| 2971 | }
|
|---|
| 2972 | break;
|
|---|
| 2973 | }
|
|---|
| 2974 | }
|
|---|
| 2975 | return 0;
|
|---|
| 2976 |
|
|---|
| 2977 | case UM_LOADFILE:
|
|---|
| 2978 | if (dcd && mp2) {
|
|---|
| 2979 |
|
|---|
| 2980 | HWND hwnd;
|
|---|
| 2981 |
|
|---|
| 2982 | if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
|
|---|
| 2983 | hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
|
|---|
| 2984 | (CHAR *)mp2, dcd->hwndFrame);
|
|---|
| 2985 | else
|
|---|
| 2986 | hwnd = StartMLEEditor(dcd->hwndParent,
|
|---|
| 2987 | (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
|
|---|
| 2988 | free((CHAR *)mp2);
|
|---|
| 2989 | return MRFROMLONG(hwnd);
|
|---|
| 2990 | }
|
|---|
| 2991 | return 0;
|
|---|
| 2992 |
|
|---|
| 2993 | case UM_CLOSE:
|
|---|
| 2994 | WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 2995 | QW_PARENT));
|
|---|
| 2996 | return 0;
|
|---|
| 2997 |
|
|---|
| 2998 | case UM_FOLDUP:
|
|---|
| 2999 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
|---|
| 3000 | DosExit(EXIT_PROCESS, 1);
|
|---|
| 3001 | return 0;
|
|---|
| 3002 |
|
|---|
| 3003 | case WM_CLOSE:
|
|---|
| 3004 | if (dcd) {
|
|---|
| 3005 | dcd->namecanchange = TRUE;
|
|---|
| 3006 | dcd->stopflag = 1;
|
|---|
| 3007 | if (dcd->amextracted)
|
|---|
| 3008 | return 0; // Can not close yet
|
|---|
| 3009 | }
|
|---|
| 3010 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
|
|---|
| 3011 | if (dcd) {
|
|---|
| 3012 | if (!dcd->dontclose && ParentIsDesktop(hwnd, dcd->hwndParent))
|
|---|
| 3013 | PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
|
|---|
| 3014 | if (dcd->hwndObject) {
|
|---|
| 3015 | DosSleep(32); // Allow UM_FOLDUP to process
|
|---|
| 3016 | if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
|
|---|
| 3017 | WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
|
|---|
| 3018 | }
|
|---|
| 3019 | }
|
|---|
| 3020 | else
|
|---|
| 3021 | WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
|
|---|
| 3022 | return 0;
|
|---|
| 3023 |
|
|---|
| 3024 | case WM_DESTROY:
|
|---|
| 3025 | if (CollectorDirMenu)
|
|---|
| 3026 | WinDestroyWindow(CollectorDirMenu);
|
|---|
| 3027 | if (CollectorFileMenu)
|
|---|
| 3028 | WinDestroyWindow(CollectorFileMenu);
|
|---|
| 3029 | if (CollectorCnrMenu)
|
|---|
| 3030 | WinDestroyWindow(CollectorCnrMenu);
|
|---|
| 3031 | CollectorCnrMenu = CollectorFileMenu = CollectorDirMenu = (HWND) 0;
|
|---|
| 3032 | Collector = (HWND) 0;
|
|---|
| 3033 | EmptyCnr(hwnd);
|
|---|
| 3034 | break;
|
|---|
| 3035 | }
|
|---|
| 3036 | if (dcd && dcd->oldproc){
|
|---|
| 3037 | return dcd->oldproc(hwnd, msg, mp1, mp2);
|
|---|
| 3038 | }
|
|---|
| 3039 | else
|
|---|
| 3040 | return PFNWPCnr(hwnd, msg, mp1, mp2);
|
|---|
| 3041 | }
|
|---|
| 3042 |
|
|---|
| 3043 | MRESULT EXPENTRY CollectorMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 3044 | MPARAM mp2)
|
|---|
| 3045 | {
|
|---|
| 3046 | PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 3047 | static short sLastMenuitem;
|
|---|
| 3048 |
|
|---|
| 3049 | switch (msg) {
|
|---|
| 3050 | case WM_MOUSEMOVE: {
|
|---|
| 3051 | if (fOtherHelp) {
|
|---|
| 3052 | RECTL rectl;
|
|---|
| 3053 | SHORT i, sCurrentMenuitem;
|
|---|
| 3054 | SHORT MenuItems = 5;
|
|---|
| 3055 | SHORT asMenuIDs[5] = {IDM_GREP,
|
|---|
| 3056 | IDM_SEEALL,
|
|---|
| 3057 | IDM_CLEARCNR,
|
|---|
| 3058 | IDM_REMOVE,
|
|---|
| 3059 | 0};
|
|---|
| 3060 | PCSZ szHelpString = NULL;
|
|---|
| 3061 |
|
|---|
| 3062 | for (i=0; i<MenuItems; i++) {
|
|---|
| 3063 | sCurrentMenuitem = asMenuIDs[i];
|
|---|
| 3064 | oldMenuProc(hwnd,MM_QUERYITEMRECT,
|
|---|
| 3065 | MPFROM2SHORT(asMenuIDs[i], FALSE),
|
|---|
| 3066 | &rectl);
|
|---|
| 3067 |
|
|---|
| 3068 | if (MOUSEMSG(&msg)->x > rectl.xLeft &&
|
|---|
| 3069 | MOUSEMSG(&msg)->x < rectl.xRight &&
|
|---|
| 3070 | MOUSEMSG(&msg)->y > rectl.yBottom &&
|
|---|
| 3071 | MOUSEMSG(&msg)->y < rectl.yTop)
|
|---|
| 3072 | break;
|
|---|
| 3073 | } // for
|
|---|
| 3074 |
|
|---|
| 3075 | switch (sCurrentMenuitem) {
|
|---|
| 3076 | case 0:
|
|---|
| 3077 | break;
|
|---|
| 3078 | case IDM_GREP:
|
|---|
| 3079 | szHelpString = GetPString(IDS_COLMENUSEEKSCANHELP);
|
|---|
| 3080 | break;
|
|---|
| 3081 | case IDM_SEEALL:
|
|---|
| 3082 | szHelpString = GetPString(IDS_COLMENUSEEALLHELP);
|
|---|
| 3083 | break;
|
|---|
| 3084 | case IDM_CLEARCNR:
|
|---|
| 3085 | szHelpString = GetPString(IDS_COLMENUCLEARCNRHELP);
|
|---|
| 3086 | break;
|
|---|
| 3087 | case IDM_REMOVE:
|
|---|
| 3088 | szHelpString = GetPString(IDS_COLMENUREMOVECNRHELP);
|
|---|
| 3089 | break;
|
|---|
| 3090 | default:
|
|---|
| 3091 | break;
|
|---|
| 3092 | }
|
|---|
| 3093 |
|
|---|
| 3094 | if (sLastMenuitem != sCurrentMenuitem && szHelpString) {
|
|---|
| 3095 | sLastMenuitem = sCurrentMenuitem;
|
|---|
| 3096 | MakeBubble(hwnd, TRUE, szHelpString);
|
|---|
| 3097 | }
|
|---|
| 3098 | else if (hwndBubble && !sCurrentMenuitem){
|
|---|
| 3099 | sLastMenuitem = sCurrentMenuitem;
|
|---|
| 3100 | WinDestroyWindow(hwndBubble);
|
|---|
| 3101 | }
|
|---|
| 3102 | }
|
|---|
| 3103 | }
|
|---|
| 3104 | }
|
|---|
| 3105 | return oldMenuProc(hwnd, msg, mp1, mp2);
|
|---|
| 3106 | }
|
|---|
| 3107 |
|
|---|
| 3108 | HWND StartCollector(HWND hwndParent, INT flags)
|
|---|
| 3109 | {
|
|---|
| 3110 | HWND hwndFrame = (HWND) 0;
|
|---|
| 3111 | HWND hwndClient;
|
|---|
| 3112 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
|
|---|
| 3113 | FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
|
|---|
| 3114 | USHORT id;
|
|---|
| 3115 | DIRCNRDATA *dcd;
|
|---|
| 3116 |
|
|---|
| 3117 | static USHORT idinc = 0;
|
|---|
| 3118 |
|
|---|
| 3119 | if (ParentIsDesktop(hwndParent, hwndParent))
|
|---|
| 3120 | FrameFlags |= (FCF_TASKLIST | FCF_SHELLPOSITION | FCF_MENU);
|
|---|
| 3121 | if (Collector) {
|
|---|
| 3122 | WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
|
|---|
| 3123 | QW_PARENT),
|
|---|
| 3124 | QW_PARENT),
|
|---|
| 3125 | HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE);
|
|---|
| 3126 | return WinQueryWindow(WinQueryWindow(Collector, QW_PARENT), QW_PARENT);
|
|---|
| 3127 | }
|
|---|
| 3128 | hwndFrame = WinCreateStdWindow(hwndParent,
|
|---|
| 3129 | WS_VISIBLE,
|
|---|
| 3130 | &FrameFlags,
|
|---|
| 3131 | (CHAR *) WC_COLLECTOR,
|
|---|
| 3132 | NULL,
|
|---|
| 3133 | WS_VISIBLE | fwsAnimate,
|
|---|
| 3134 | FM3ModHandle, COLLECTOR_FRAME, &hwndClient);
|
|---|
| 3135 | if (hwndFrame && hwndClient) {
|
|---|
| 3136 | id = COLLECTOR_FRAME + idinc++;
|
|---|
| 3137 | WinSetWindowUShort(hwndFrame, QWS_ID, id);
|
|---|
| 3138 | # ifdef FORTIFY
|
|---|
| 3139 | Fortify_EnterScope();
|
|---|
| 3140 | # endif
|
|---|
| 3141 | dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
|
|---|
| 3142 | if (!dcd) {
|
|---|
| 3143 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
|---|
| 3144 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
|---|
| 3145 | hwndFrame = (HWND) 0;
|
|---|
| 3146 | }
|
|---|
| 3147 | else {
|
|---|
| 3148 | dcd->size = sizeof(DIRCNRDATA);
|
|---|
| 3149 | dcd->id = id;
|
|---|
| 3150 | dcd->type = COLLECTOR_FRAME;
|
|---|
| 3151 | dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
|
|---|
| 3152 | dcd->hwndFrame = hwndFrame;
|
|---|
| 3153 | dcd->hwndClient = hwndClient;
|
|---|
| 3154 | if (flags & 4)
|
|---|
| 3155 | dcd->dontclose = TRUE;
|
|---|
| 3156 | {
|
|---|
| 3157 | PFNWP oldproc;
|
|---|
| 3158 |
|
|---|
| 3159 | oldproc = WinSubclassWindow(hwndFrame, (PFNWP) CollectorFrameWndProc);
|
|---|
| 3160 | WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
|
|---|
| 3161 | }
|
|---|
| 3162 | dcd->hwndCnr = WinCreateWindow(hwndClient,
|
|---|
| 3163 | WC_CONTAINER,
|
|---|
| 3164 | NULL,
|
|---|
| 3165 | CCS_AUTOPOSITION | CCS_MINIICONS |
|
|---|
| 3166 | CCS_MINIRECORDCORE | ulCnrType |
|
|---|
| 3167 | WS_VISIBLE,
|
|---|
| 3168 | 0,
|
|---|
| 3169 | 0,
|
|---|
| 3170 | 0,
|
|---|
| 3171 | 0,
|
|---|
| 3172 | hwndClient,
|
|---|
| 3173 | HWND_TOP,
|
|---|
| 3174 | (ULONG) COLLECTOR_CNR, NULL, NULL);
|
|---|
| 3175 | if (!dcd->hwndCnr) {
|
|---|
| 3176 | Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
|
|---|
| 3177 | PCSZ_WINCREATEWINDOW);
|
|---|
| 3178 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
|---|
| 3179 | free(dcd);
|
|---|
| 3180 | hwndFrame = (HWND) 0;
|
|---|
| 3181 | }
|
|---|
| 3182 | else {
|
|---|
| 3183 | Collector = dcd->hwndCnr;
|
|---|
| 3184 | WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
|
|---|
| 3185 | WinSetWindowText(hwndFrame, (CHAR *) GetPString(IDS_COLLECTORTITLETEXT));
|
|---|
| 3186 | if (FrameFlags & FCF_MENU) {
|
|---|
| 3187 | PFNWP oldmenuproc;
|
|---|
| 3188 | HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
|
|---|
| 3189 |
|
|---|
| 3190 | oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) CollectorMenuProc);
|
|---|
| 3191 | WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
|
|---|
| 3192 | if (!fToolbar) {
|
|---|
| 3193 | if (hwndMenu) {
|
|---|
| 3194 |
|
|---|
| 3195 | WinSendMsg(hwndMenu,
|
|---|
| 3196 | MM_DELETEITEM,
|
|---|
| 3197 | MPFROM2SHORT(IDM_SEEALL, FALSE), MPVOID);
|
|---|
| 3198 | WinSendMsg(hwndMenu,
|
|---|
| 3199 | MM_DELETEITEM,
|
|---|
| 3200 | MPFROM2SHORT(IDM_GREP, FALSE), MPVOID);
|
|---|
| 3201 | WinSendMsg(hwndMenu,
|
|---|
| 3202 | MM_DELETEITEM,
|
|---|
| 3203 | MPFROM2SHORT(IDM_CLEARCNR, FALSE), MPVOID);
|
|---|
| 3204 | WinSendMsg(hwndMenu,
|
|---|
| 3205 | MM_DELETEITEM,
|
|---|
| 3206 | MPFROM2SHORT(IDM_REMOVE, FALSE), MPVOID);
|
|---|
| 3207 | }
|
|---|
| 3208 | }
|
|---|
| 3209 | }
|
|---|
| 3210 | dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
|
|---|
| 3211 | (PFNWP) CollectorCnrWndProc);
|
|---|
| 3212 | {
|
|---|
| 3213 | USHORT ids[] = { DIR_TOTALS,
|
|---|
| 3214 | DIR_SELECTED,
|
|---|
| 3215 | DIR_VIEW,
|
|---|
| 3216 | DIR_SORT,
|
|---|
| 3217 | DIR_FILTER,
|
|---|
| 3218 | 0
|
|---|
| 3219 | };
|
|---|
| 3220 |
|
|---|
| 3221 | CommonCreateTextChildren(dcd->hwndClient,
|
|---|
| 3222 | WC_COLSTATUS, ids);
|
|---|
| 3223 | }
|
|---|
| 3224 | if (FrameFlags & FCF_SHELLPOSITION)
|
|---|
| 3225 | PostMsg(hwndClient, UM_SIZE, MPVOID, MPVOID);
|
|---|
| 3226 | if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
|
|---|
| 3227 | WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
|
|---|
| 3228 | }
|
|---|
| 3229 | }
|
|---|
| 3230 | # ifdef FORTIFY
|
|---|
| 3231 | DosSleep(1); // Let receiver take ownership
|
|---|
| 3232 | Fortify_LeaveScope();
|
|---|
| 3233 | # endif
|
|---|
| 3234 | }
|
|---|
| 3235 | return hwndFrame;
|
|---|
| 3236 | }
|
|---|
| 3237 |
|
|---|
| 3238 | #pragma alloc_text(COLLECTOR,CollectorCnrWndProc,CollectorObjWndProc)
|
|---|
| 3239 | #pragma alloc_text(COLLECTOR,CollectorClientWndProc,CollectorTextProc)
|
|---|
| 3240 | #pragma alloc_text(COLLECTOR,CollectorFrameWndProc)
|
|---|
| 3241 | #pragma alloc_text(STARTUP,StartCollector)
|
|---|