[27] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: arccnrs.c 1034 2008-06-30 14:17:03Z gyoung $
|
---|
| 5 |
|
---|
[123] | 6 | Archive containers
|
---|
| 7 |
|
---|
[28] | 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[907] | 9 | Copyright (c) 2001, 2008 Steven H. Levine
|
---|
[27] | 10 |
|
---|
[130] | 11 | 11 Jun 02 SHL Ensure archive name not garbage
|
---|
| 12 | 22 May 03 SHL ArcObjWndProc: fix UM_RESCAN now that we understand it
|
---|
| 13 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 14 | 23 May 05 SHL Use QWL_USER
|
---|
[156] | 15 | 25 May 05 SHL Rename comnam to szCommonName and fix typo
|
---|
| 16 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL
|
---|
[212] | 17 | 05 Jun 05 SHL Drop obsolete, localize
|
---|
| 18 | 05 Jun 05 SHL Correct last sort logic
|
---|
| 19 | 05 Jun 05 SHL Use QWL_USER
|
---|
[229] | 20 | 22 Jun 05 SHL ArcSort: correct typo in last sort fix
|
---|
[249] | 21 | 13 Aug 05 SHL FillArcCnr: optimize
|
---|
[300] | 22 | 08 Dec 05 SHL FillArcCnr: allow list start and end markers to be empty (i.e. tar)
|
---|
| 23 | 08 Dec 05 SHL ArcCnrWndProc: suppress IDM_EXTRACT if no simple extract (i.e. tar)
|
---|
| 24 | 30 Dec 05 SHL ArcCnrWndProc: correct date/time column display setup
|
---|
| 25 | 29 May 06 SHL Comments
|
---|
[358] | 26 | 14 Jul 06 SHL Use Runtime_Error
|
---|
[367] | 27 | 26 Jul 06 SHL Correct SelectAll usage
|
---|
[406] | 28 | 29 Jul 06 SHL Use xfgets_bstripcr
|
---|
[423] | 29 | 31 Jul 06 SHL Lower priority for archives with more than 1000 entries
|
---|
[426] | 30 | 02 Aug 06 SHL Add logic to stop processing large archives
|
---|
[460] | 31 | 23 Aug 06 SHL Integrate John Small's switch list title logic
|
---|
[531] | 32 | 03 Nov 06 SHL Renames
|
---|
[562] | 33 | 14 Mar 07 SHL ArcObjWndProc/UM_ENTER: delay before starting viewer
|
---|
[593] | 34 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
[618] | 35 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeISH limit
|
---|
[606] | 36 | 06 Apr 07 GKY Add some error checking in drag/drop
|
---|
[618] | 37 | 20 Apr 07 SHL Sync with NumItemsToUnhilite mods
|
---|
[627] | 38 | 21 Apr 07 GKY Find FM2Utils by path or utils directory
|
---|
[672] | 39 | 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
|
---|
[688] | 40 | 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
|
---|
[696] | 41 | 16 Jun 07 SHL Use DosQueryAppType not DosQAppType
|
---|
[751] | 42 | 02 Aug 07 SHL Sync with ARCITEM mods
|
---|
[773] | 43 | 06 Aug 07 SHL Use BldFullPathName and BldQuotedFileName
|
---|
| 44 | 06 Aug 07 SHL Move BldQuotedFileName and BldQuotedFullPathNamehere
|
---|
| 45 | to be near primary caller
|
---|
[775] | 46 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
[793] | 47 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[814] | 48 | 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
|
---|
[872] | 49 | 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
|
---|
[897] | 50 | 30 Dec 07 GKY Use TestCDates for sort by date
|
---|
[917] | 51 | 10 Jan 08 SHL Sync with CfgDlgProc mods
|
---|
[946] | 52 | 10 Feb 08 GKY Implement bubble help for bitmap menu items
|
---|
[953] | 53 | 15 Feb 08 SHL Sync with settings menu rework
|
---|
[985] | 54 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
[618] | 55 |
|
---|
[27] | 56 | ***********************************************************************/
|
---|
| 57 |
|
---|
[907] | 58 | #include <stdlib.h> // free..
|
---|
[2] | 59 | #include <string.h>
|
---|
| 60 | #include <ctype.h>
|
---|
[907] | 61 | #include <direct.h> // rmdir
|
---|
| 62 | #include <share.h> // SH_DENYWR
|
---|
| 63 | #include <limits.h> // ULONG_MAX
|
---|
[689] | 64 | #include <process.h> // _beginthread
|
---|
[762] | 65 |
|
---|
| 66 | #if 0
|
---|
[751] | 67 | #include <malloc.h> // _heapchk
|
---|
[762] | 68 | #endif
|
---|
[156] | 69 |
|
---|
[907] | 70 | #define INCL_DOS
|
---|
| 71 | #define INCL_DOSERRORS
|
---|
| 72 | #define INCL_WIN
|
---|
| 73 | #define INCL_LONGLONG
|
---|
| 74 |
|
---|
| 75 | #include "arccnrs.h" // StartArcCnr
|
---|
[2] | 76 | #include "fm3dlg.h"
|
---|
| 77 | #include "fm3str.h"
|
---|
| 78 | #include "mle.h"
|
---|
[907] | 79 | #include "pathutil.h" // BldFullPathName
|
---|
| 80 | #include "filldir.h" // EmptyCnr...
|
---|
| 81 | #include "errutil.h" // Dos_Error...
|
---|
| 82 | #include "strutil.h" // GetPString
|
---|
[953] | 83 | #include "notebook.h" // CfgDlgProc
|
---|
[907] | 84 | #include "fm3dll.h"
|
---|
[1011] | 85 | #include "fortify.h"
|
---|
[2] | 86 |
|
---|
| 87 | #pragma data_seg(DATA1)
|
---|
[358] | 88 |
|
---|
| 89 | static INT DefArcSortFlags;
|
---|
| 90 | static PSZ pszSrcFile = __FILE__;
|
---|
| 91 |
|
---|
[551] | 92 | static MRESULT EXPENTRY ArcErrProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 93 | MPARAM mp2)
|
---|
[172] | 94 | {
|
---|
[2] | 95 | ARCDUMP *ad;
|
---|
[773] | 96 | CHAR szQuotedArcName[CCHMAXPATH];
|
---|
[2] | 97 |
|
---|
[551] | 98 | switch (msg) {
|
---|
| 99 | case WM_INITDLG:
|
---|
| 100 | if (!mp2)
|
---|
| 101 | WinDismissDlg(hwnd, 0);
|
---|
| 102 | else {
|
---|
| 103 | ad = (ARCDUMP *) mp2;
|
---|
| 104 | WinSetWindowPtr(hwnd, QWL_USER, ad);
|
---|
| 105 | if (ad->errmsg)
|
---|
| 106 | WinSetDlgItemText(hwnd, ARCERR_TEXT, ad->errmsg);
|
---|
| 107 | if (!ad->info->test)
|
---|
| 108 | WinEnableWindow(WinWindowFromID(hwnd, ARCERR_TEST), FALSE);
|
---|
| 109 | if (ad->listname) {
|
---|
| 110 | MLEsetlimit(WinWindowFromID(hwnd, ARCERR_MLE), -1L);
|
---|
| 111 | MLEsetformat(WinWindowFromID(hwnd, ARCERR_MLE), MLFIE_NOTRANS);
|
---|
| 112 | MLEsetcurpos(WinWindowFromID(hwnd, ARCERR_MLE),
|
---|
| 113 | MLEgetlen(WinWindowFromID(hwnd, ARCERR_MLE)));
|
---|
| 114 | MLEinsert(WinWindowFromID(hwnd, ARCERR_MLE),
|
---|
| 115 | GetPString(IDS_ARCHIVERREPORTTEXT));
|
---|
| 116 | MLEinsertfile(WinWindowFromID(hwnd, ARCERR_MLE), ad->listname);
|
---|
[2] | 117 | }
|
---|
[551] | 118 | }
|
---|
| 119 | break;
|
---|
| 120 |
|
---|
| 121 | case WM_COMMAND:
|
---|
| 122 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 123 | case DID_CANCEL:
|
---|
| 124 | WinDismissDlg(hwnd, 0);
|
---|
[2] | 125 | break;
|
---|
| 126 |
|
---|
[551] | 127 | case IDM_HELP:
|
---|
| 128 | if (hwndHelp) {
|
---|
| 129 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 130 | MPFROM2SHORT(HELP_ARCERR, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 131 | }
|
---|
| 132 | break;
|
---|
[2] | 133 |
|
---|
[551] | 134 | case DID_OK:
|
---|
| 135 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 136 | WinDlgBox(HWND_DESKTOP, hwnd, ArcReviewDlgProc, FM3ModHandle,
|
---|
| 137 | AD_FRAME, MPFROMP(ad));
|
---|
| 138 | WinDismissDlg(hwnd, 0);
|
---|
| 139 | break;
|
---|
[2] | 140 |
|
---|
[551] | 141 | case ARCERR_VIEW:
|
---|
| 142 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 143 | {
|
---|
| 144 | CHAR *list[2];
|
---|
[2] | 145 |
|
---|
[551] | 146 | list[0] = ad->arcname;
|
---|
| 147 | list[1] = NULL;
|
---|
| 148 | if (TestBinary(ad->arcname)) {
|
---|
| 149 | if (*binview)
|
---|
| 150 | ExecOnList((HWND) 0, binview, WINDOWED | SEPARATE, NULL, list,
|
---|
[888] | 151 | NULL, pszSrcFile, __LINE__);
|
---|
[551] | 152 | else
|
---|
| 153 | StartMLEEditor(HWND_DESKTOP, 16 + 4 + 1, ad->arcname, hwnd);
|
---|
| 154 | }
|
---|
| 155 | else {
|
---|
| 156 | if (*viewer) {
|
---|
| 157 | ExecOnList((HWND) 0, viewer, WINDOWED | SEPARATE |
|
---|
[907] | 158 | (fViewChild ? CHILD : 0),
|
---|
| 159 | NULL, list, NULL, pszSrcFile, __LINE__);
|
---|
[551] | 160 | }
|
---|
| 161 | else
|
---|
| 162 | StartMLEEditor(HWND_DESKTOP, 8 + 4 + 1, ad->arcname, hwnd);
|
---|
| 163 | }
|
---|
| 164 | }
|
---|
| 165 | break;
|
---|
[2] | 166 |
|
---|
[551] | 167 | case ARCERR_TEST:
|
---|
| 168 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 169 | runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
|
---|
[888] | 170 | hwnd, pszSrcFile, __LINE__, NULL, NULL,
|
---|
[773] | 171 | "%s %s",
|
---|
| 172 | ad->info->test,
|
---|
| 173 | BldQuotedFileName(szQuotedArcName, ad->arcname));
|
---|
[551] | 174 | break;
|
---|
| 175 | }
|
---|
| 176 | return 0;
|
---|
[2] | 177 | }
|
---|
[551] | 178 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 179 | }
|
---|
| 180 |
|
---|
[551] | 181 | static SHORT APIENTRY ArcSort(PMINIRECORDCORE pmrc1, PMINIRECORDCORE pmrc2,
|
---|
| 182 | PVOID pStorage)
|
---|
[172] | 183 | {
|
---|
[551] | 184 | PARCITEM pai1 = (PARCITEM) pmrc1;
|
---|
| 185 | PARCITEM pai2 = (PARCITEM) pmrc2;
|
---|
| 186 | DIRCNRDATA *pdcd = (DIRCNRDATA *) pStorage;
|
---|
| 187 | SHORT ret = 0;
|
---|
| 188 | CHAR *pext, *ppext;
|
---|
| 189 | INT sortFlags;
|
---|
[2] | 190 |
|
---|
[423] | 191 | if (!pdcd) {
|
---|
[212] | 192 | HWND hwndCnr = pai1->hwndCnr;
|
---|
[551] | 193 |
|
---|
| 194 | pdcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
|
---|
[358] | 195 | if (!pdcd) {
|
---|
[377] | 196 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
[212] | 197 | return ret;
|
---|
| 198 | }
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | sortFlags = pdcd->sortFlags; // Optimize
|
---|
| 202 |
|
---|
[423] | 203 | if (sortFlags) {
|
---|
[551] | 204 | switch (sortFlags & (~SORT_REVERSE)) {
|
---|
| 205 | case SORT_FIRSTEXTENSION:
|
---|
[730] | 206 | pext = strchr(pai1->pszFileName, '.');
|
---|
| 207 | ppext = strchr(pai2->pszFileName, '.');
|
---|
[551] | 208 | if (!pext)
|
---|
| 209 | pext = NullStr;
|
---|
| 210 | if (!ppext)
|
---|
| 211 | ppext = NullStr;
|
---|
| 212 | ret = stricmp(pext, ppext);
|
---|
| 213 | break;
|
---|
[2] | 214 |
|
---|
[551] | 215 | case SORT_LASTEXTENSION:
|
---|
[730] | 216 | pext = strrchr(pai1->pszFileName, '.');
|
---|
| 217 | ppext = strrchr(pai2->pszFileName, '.');
|
---|
[551] | 218 | if (!pext)
|
---|
| 219 | pext = NullStr;
|
---|
| 220 | if (!ppext)
|
---|
| 221 | ppext = NullStr;
|
---|
| 222 | ret = stricmp(pext, ppext);
|
---|
| 223 | break;
|
---|
[2] | 224 |
|
---|
[551] | 225 | case SORT_LWDATE:
|
---|
[897] | 226 | ret = TestCDates(&pai1->date, &pai1->time,
|
---|
[907] | 227 | &pai2->date, &pai2->time);
|
---|
| 228 | /*(pai1->date.year < pai2->date.year) ? 1 :
|
---|
[551] | 229 | (pai1->date.year > pai2->date.year) ? -1 :
|
---|
| 230 | (pai1->date.month < pai2->date.month) ? 1 :
|
---|
| 231 | (pai1->date.month > pai2->date.month) ? -1 :
|
---|
| 232 | (pai1->date.day < pai2->date.day) ? 1 :
|
---|
| 233 | (pai1->date.day > pai2->date.day) ? -1 :
|
---|
| 234 | (pai1->time.hours < pai2->time.hours) ? 1 :
|
---|
| 235 | (pai1->time.hours > pai2->time.hours) ? -1 :
|
---|
| 236 | (pai1->time.minutes < pai2->time.minutes) ? 1 :
|
---|
| 237 | (pai1->time.minutes > pai2->time.minutes) ? -1 :
|
---|
| 238 | (pai1->time.seconds < pai2->time.seconds) ? 1 :
|
---|
[897] | 239 | (pai1->time.seconds > pai2->time.seconds) ? -1 : 0;*/
|
---|
[551] | 240 | break;
|
---|
[2] | 241 |
|
---|
[551] | 242 | case SORT_SIZE:
|
---|
| 243 | ret =
|
---|
| 244 | (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile ==
|
---|
| 245 | pai2->cbFile) ? 0 : -1;
|
---|
| 246 | if (!ret)
|
---|
| 247 | ret =
|
---|
| 248 | (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp ==
|
---|
| 249 | pai2->cbComp) ? 0 : -1;
|
---|
| 250 | break;
|
---|
[2] | 251 |
|
---|
[551] | 252 | case SORT_EASIZE:
|
---|
| 253 | ret =
|
---|
| 254 | (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp ==
|
---|
| 255 | pai2->cbComp) ? 0 : -1;
|
---|
| 256 | if (!ret)
|
---|
| 257 | ret =
|
---|
| 258 | (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile ==
|
---|
| 259 | pai2->cbFile) ? 0 : -1;
|
---|
| 260 | break;
|
---|
[2] | 261 | }
|
---|
[423] | 262 | if (!ret)
|
---|
[730] | 263 | ret = (SHORT) stricmp(pai1->pszFileName, pai2->pszFileName);
|
---|
[423] | 264 | if (ret && (sortFlags & SORT_REVERSE))
|
---|
[562] | 265 | ret = ret > 0 ? -1 : 1;
|
---|
[2] | 266 | return ret;
|
---|
| 267 | }
|
---|
[730] | 268 | return (SHORT) stricmp(pai1->pszFileName, pai2->pszFileName);
|
---|
[2] | 269 | }
|
---|
| 270 |
|
---|
[551] | 271 | static INT APIENTRY ArcFilter(PMINIRECORDCORE rmini, PVOID arg)
|
---|
[172] | 272 | {
|
---|
[551] | 273 | DIRCNRDATA *dcd = (DIRCNRDATA *) arg;
|
---|
| 274 | PARCITEM r;
|
---|
| 275 | register INT x;
|
---|
| 276 | INT ret = FALSE;
|
---|
[2] | 277 |
|
---|
[423] | 278 | if (dcd && *dcd->mask.szMask) {
|
---|
[551] | 279 | r = (PARCITEM) rmini;
|
---|
[423] | 280 | if (dcd->mask.pszMasks[1]) {
|
---|
[551] | 281 | for (x = 0; dcd->mask.pszMasks[x]; x++) {
|
---|
| 282 | if (*dcd->mask.pszMasks[x]) {
|
---|
| 283 | if (*dcd->mask.pszMasks[x] != '/') {
|
---|
[730] | 284 | if (wildcard(r->pszFileName, dcd->mask.pszMasks[x], FALSE))
|
---|
[551] | 285 | ret = TRUE;
|
---|
| 286 | }
|
---|
| 287 | else {
|
---|
[730] | 288 | if (wildcard(r->pszFileName, dcd->mask.pszMasks[x] + 1, FALSE)) {
|
---|
[551] | 289 | ret = FALSE;
|
---|
| 290 | break;
|
---|
| 291 | }
|
---|
| 292 | }
|
---|
| 293 | }
|
---|
[2] | 294 | }
|
---|
| 295 | }
|
---|
| 296 | else {
|
---|
[730] | 297 | if (wildcard(r->pszFileName, dcd->mask.szMask, FALSE))
|
---|
[551] | 298 | ret = TRUE;
|
---|
[2] | 299 | }
|
---|
| 300 | }
|
---|
| 301 | else
|
---|
| 302 | ret = TRUE;
|
---|
| 303 | return ret;
|
---|
| 304 | }
|
---|
| 305 |
|
---|
[551] | 306 | static MRESULT EXPENTRY ArcFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 307 | MPARAM mp2)
|
---|
[172] | 308 | {
|
---|
[551] | 309 | return CommonFrameWndProc(ARC_CNR, hwnd, msg, mp1, mp2);
|
---|
[2] | 310 | }
|
---|
| 311 |
|
---|
[551] | 312 | static BOOL IsArcThere(HWND hwnd, CHAR * arcname)
|
---|
[172] | 313 | {
|
---|
[423] | 314 | if (arcname) {
|
---|
| 315 | if (IsFile(arcname) != 1) {
|
---|
[551] | 316 | saymsg(MB_CANCEL, hwnd,
|
---|
| 317 | GetPString(IDS_SAYWHATTEXT),
|
---|
| 318 | GetPString(IDS_ARCNOTTHERETEXT), arcname);
|
---|
[2] | 319 | return FALSE;
|
---|
| 320 | }
|
---|
| 321 | return TRUE;
|
---|
| 322 | }
|
---|
| 323 | return FALSE;
|
---|
| 324 | }
|
---|
| 325 |
|
---|
[751] | 326 | /**
|
---|
| 327 | * Free storage associated with archive container item
|
---|
| 328 | * Caller is responsible for correcting pointers
|
---|
| 329 | */
|
---|
| 330 |
|
---|
| 331 | static VOID FreeArcItemData(PARCITEM pai)
|
---|
| 332 | {
|
---|
| 333 | // DbgMsg(pszSrcFile, __LINE__, "FreeArcItemData %p", pai);
|
---|
[762] | 334 | PSZ psz;
|
---|
[751] | 335 |
|
---|
[762] | 336 | if (pai->pszFileName && pai->pszFileName != NullStr) {
|
---|
| 337 | psz = pai->pszFileName;
|
---|
| 338 | pai->pszFileName = NullStr;
|
---|
[1032] | 339 | # ifdef FORTIFY
|
---|
| 340 | xfree(psz, pszSrcFile, __LINE__);
|
---|
| 341 | # else
|
---|
[762] | 342 | free(psz);
|
---|
[1032] | 343 | # endif
|
---|
| 344 | # ifdef FORTIFY
|
---|
[1034] | 345 | xFortify_LeaveScope(pszSrcFile, __LINE__);
|
---|
[1032] | 346 | # endif
|
---|
[762] | 347 | }
|
---|
[751] | 348 | }
|
---|
| 349 |
|
---|
| 350 | /**
|
---|
[762] | 351 | * Remove item(s) from archive container and free associated storage if requested
|
---|
| 352 | * @param paiFirst points to first item to remove or NULL to remove all
|
---|
| 353 | * @param usCnt is remove count or 0 to remove all
|
---|
[751] | 354 | */
|
---|
| 355 |
|
---|
[762] | 356 | static VOID RemoveArcItems(HWND hwnd, PARCITEM paiFirst, USHORT usCnt, USHORT usFlags)
|
---|
[751] | 357 | {
|
---|
[762] | 358 | INT remaining = usCnt;
|
---|
| 359 | PARCITEM pai;
|
---|
| 360 |
|
---|
| 361 | if ((usCnt && !paiFirst) || (!usCnt && paiFirst))
|
---|
| 362 | Runtime_Error(pszSrcFile, __LINE__, "paiFirst %p usCnt %u mismatch", paiFirst, usCnt);
|
---|
| 363 | else {
|
---|
| 364 | // Free our buffers if free requested
|
---|
| 365 | if (usFlags & CMA_FREE) {
|
---|
| 366 | if (paiFirst)
|
---|
| 367 | pai = paiFirst;
|
---|
| 368 | else {
|
---|
[751] | 369 | pai = (PARCITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID,
|
---|
| 370 | MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
[762] | 371 | if ((INT)pai == -1) {
|
---|
[751] | 372 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_QUERYRECORD");
|
---|
[762] | 373 | remaining = -1;
|
---|
| 374 | pai = NULL;
|
---|
[751] | 375 | }
|
---|
| 376 | }
|
---|
[762] | 377 | while (pai) {
|
---|
| 378 | FreeArcItemData(pai);
|
---|
| 379 | pai = (PARCITEM)pai->rc.preccNextRecord;
|
---|
| 380 | if (remaining && --remaining == 0)
|
---|
| 381 | break;
|
---|
| 382 | }
|
---|
[751] | 383 | }
|
---|
| 384 | }
|
---|
| 385 |
|
---|
[762] | 386 | // DbgMsg(pszSrcFile, __LINE__, "RemoveArcItems %p %u %s", pai, usCnt, pai->pszFileName);
|
---|
[751] | 387 |
|
---|
[762] | 388 | if (remaining != - 1) {
|
---|
| 389 | remaining = (INT)WinSendMsg(hwnd, CM_REMOVERECORD, MPFROMP(&paiFirst), MPFROM2SHORT(usCnt, usFlags));
|
---|
| 390 | if (remaining == -1) {
|
---|
[751] | 391 | // Win_Error2(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,IDS_CMREMOVEERRTEXT);
|
---|
[762] | 392 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVERECORD hwnd %x pai %p cnt %u", hwnd, paiFirst, usCnt);
|
---|
[751] | 393 | }
|
---|
| 394 | }
|
---|
| 395 | }
|
---|
| 396 |
|
---|
| 397 | /**
|
---|
[762] | 398 | * Empty all records from an archive container and
|
---|
| 399 | * free associated storage and free up field infos
|
---|
[751] | 400 | */
|
---|
| 401 |
|
---|
| 402 | static VOID EmptyArcCnr(HWND hwnd)
|
---|
| 403 | {
|
---|
[773] | 404 | #if 0 // fixme to be gone or to be configurable
|
---|
[751] | 405 | {
|
---|
| 406 | int state = _heapchk();
|
---|
| 407 | if (state != _HEAPOK)
|
---|
| 408 | Runtime_Error(pszSrcFile, __LINE__, "heap corrupted %d", state);
|
---|
[762] | 409 | else
|
---|
| 410 | DbgMsg(pszSrcFile, __LINE__, "_memavl %u", _memavl());
|
---|
[751] | 411 | }
|
---|
| 412 | #endif
|
---|
| 413 |
|
---|
| 414 | // Remove all ARCITEM records
|
---|
| 415 | RemoveArcItems(hwnd, NULL, 0, CMA_FREE);
|
---|
| 416 |
|
---|
| 417 | // Use common code to remove rest
|
---|
| 418 | EmptyCnr(hwnd);
|
---|
| 419 | }
|
---|
| 420 |
|
---|
[423] | 421 | //== FillArcCnr() generate archive content list and fill container window ==
|
---|
| 422 |
|
---|
[551] | 423 | static INT FillArcCnr(HWND hwndCnr, CHAR * arcname, ARC_TYPE ** arcinfo,
|
---|
| 424 | ULONGLONG * pullTotalBytes, volatile PCHAR pStopFlag)
|
---|
[44] | 425 | {
|
---|
[551] | 426 | FILE *fp;
|
---|
| 427 | HFILE oldstdout;
|
---|
| 428 | HFILE newstdout;
|
---|
| 429 | CHAR s[CCHMAXPATH * 2], lonename[CCHMAXPATH + 2],
|
---|
[773] | 430 | *nsize, *osize, *fdate, *fname, *p, *pp, arctemp[33];
|
---|
[551] | 431 | BOOL gotstart;
|
---|
| 432 | BOOL gotend;
|
---|
| 433 | BOOL wasquote;
|
---|
[773] | 434 | BOOL nomove = FALSE; // fixme to be gone?
|
---|
[551] | 435 | INT highest = 0, x, counter = 0, numarcfiles = 0;
|
---|
| 436 | PARCITEM lastpai;
|
---|
| 437 | ARC_TYPE *info;
|
---|
| 438 | ARC_TYPE *tinfo;
|
---|
| 439 | ULONG apptype;
|
---|
| 440 | APIRET rc;
|
---|
[2] | 441 |
|
---|
[423] | 442 | if (!arcname || !arcinfo)
|
---|
[2] | 443 | return 0;
|
---|
[300] | 444 |
|
---|
[2] | 445 | info = *arcinfo;
|
---|
[423] | 446 | if (!info)
|
---|
[551] | 447 | info = find_type(arcname, NULL);
|
---|
| 448 | for (x = 0; x < 99; x++) {
|
---|
| 449 | sprintf(arctemp, "%s.%03x", ArcTempRoot, (clock() & 4095L));
|
---|
[423] | 450 | if (IsFile(arctemp) == 1)
|
---|
| 451 | DosSleep(rand() % 100);
|
---|
| 452 | else
|
---|
| 453 | break;
|
---|
| 454 | }
|
---|
[300] | 455 |
|
---|
[2] | 456 | ReTry:
|
---|
| 457 |
|
---|
| 458 | #ifdef DEBUG
|
---|
[27] | 459 | if (info && info->id)
|
---|
[551] | 460 | WinSetWindowText(WinQueryWindow
|
---|
| 461 | (WinQueryWindow(hwndCnr, QW_PARENT), QW_PARENT),
|
---|
| 462 | info->id);
|
---|
[2] | 463 | #endif
|
---|
| 464 |
|
---|
| 465 | tinfo = NULL;
|
---|
| 466 | numarcfiles = counter = highest = 0;
|
---|
| 467 | gotstart = gotend = FALSE;
|
---|
| 468 | lastpai = NULL;
|
---|
[156] | 469 | *pullTotalBytes = 0;
|
---|
[358] | 470 | if (!info || !info->list)
|
---|
[377] | 471 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
[358] | 472 | else {
|
---|
[751] | 473 | RemoveArcItems(hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
|
---|
[2] | 474 | *arcinfo = info;
|
---|
| 475 | highest = info->osizepos;
|
---|
[423] | 476 | if (info->nsizepos > highest)
|
---|
[2] | 477 | highest = info->nsizepos;
|
---|
[423] | 478 | if (info->fdpos > highest)
|
---|
[2] | 479 | highest = info->fdpos;
|
---|
[423] | 480 | if (info->fnpos > highest)
|
---|
[2] | 481 | highest = info->fnpos;
|
---|
[423] | 482 | if (highest > 50) {
|
---|
[551] | 483 | saymsg(MB_ENTER | MB_ICONEXCLAMATION, HWND_DESKTOP,
|
---|
| 484 | GetPString(IDS_SHAMETEXT), "%s", GetPString(IDS_BUNGEDUPTEXT));
|
---|
[423] | 485 | }
|
---|
| 486 | if (info->fnpos == -1)
|
---|
[2] | 487 | highest = 32767;
|
---|
[300] | 488 |
|
---|
[2] | 489 | DosError(FERR_DISABLEHARDERR);
|
---|
| 490 | DosForceDelete(arctemp);
|
---|
| 491 | DosError(FERR_DISABLEHARDERR);
|
---|
[300] | 492 |
|
---|
[551] | 493 | strcpy(s, info->list);
|
---|
| 494 | p = strchr(s, ' ');
|
---|
[423] | 495 | if (p)
|
---|
[2] | 496 | *p = 0;
|
---|
| 497 | DosError(FERR_DISABLEHARDERR);
|
---|
[696] | 498 | if (!DosQueryAppType(s, &apptype) &&
|
---|
[563] | 499 | (apptype & FAPPTYP_DOS ||
|
---|
| 500 | apptype & FAPPTYP_WINDOWSREAL ||
|
---|
| 501 | apptype & FAPPTYP_WINDOWSPROT ||
|
---|
| 502 | apptype & FAPPTYP_WINDOWSPROT31)) {
|
---|
[2] | 503 | p = GetCmdSpec(TRUE);
|
---|
| 504 | runemf2(SEPARATE | INVISIBLE | MINIMIZED | BACKGROUND | WAIT,
|
---|
[888] | 505 | hwndCnr, pszSrcFile, __LINE__, NULL, "DOS_BACKGROUND_EXECUTION=1",
|
---|
[773] | 506 | "%s /C %s %s >%s",
|
---|
| 507 | p, // shell
|
---|
| 508 | info->list, // list command
|
---|
| 509 | BldQuotedFileName(s, arcname),
|
---|
[562] | 510 | arctemp);
|
---|
[2] | 511 | }
|
---|
| 512 | else {
|
---|
[551] | 513 | fp = xfopen(arctemp, "w", pszSrcFile, __LINE__);
|
---|
[423] | 514 | if (!fp)
|
---|
[551] | 515 | return 0;
|
---|
[358] | 516 | else {
|
---|
[551] | 517 | newstdout = -1;
|
---|
| 518 | DosError(FERR_DISABLEHARDERR);
|
---|
| 519 | rc = DosDupHandle(fileno(stdout), &newstdout);
|
---|
| 520 | if (rc) {
|
---|
| 521 | Dos_Error(MB_CANCEL, rc, hwndCnr, pszSrcFile, __LINE__,
|
---|
| 522 | "DosDupHandle");
|
---|
| 523 | return 0;
|
---|
[358] | 524 | }
|
---|
| 525 | else {
|
---|
[551] | 526 | oldstdout = fileno(stdout);
|
---|
| 527 | DosError(FERR_DISABLEHARDERR);
|
---|
| 528 | rc = DosDupHandle(fileno(fp), &oldstdout);
|
---|
| 529 | if (rc) {
|
---|
| 530 | Dos_Error(MB_CANCEL, rc, hwndCnr, pszSrcFile, __LINE__,
|
---|
| 531 | "DosDupHandle");
|
---|
| 532 | return 0;
|
---|
[358] | 533 | }
|
---|
| 534 | else {
|
---|
[551] | 535 | runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT,
|
---|
[888] | 536 | hwndCnr, pszSrcFile, __LINE__, NULL, NULL,
|
---|
[773] | 537 | "%s %s",
|
---|
| 538 | info->list,
|
---|
| 539 | BldQuotedFileName(s, arcname));
|
---|
[551] | 540 | oldstdout = fileno(stdout);
|
---|
| 541 | DosError(FERR_DISABLEHARDERR);
|
---|
| 542 | DosDupHandle(newstdout, &oldstdout);
|
---|
| 543 | DosClose(newstdout);
|
---|
| 544 | fclose(fp);
|
---|
| 545 | }
|
---|
| 546 | }
|
---|
[2] | 547 | }
|
---|
| 548 | }
|
---|
[300] | 549 |
|
---|
[2] | 550 | DosError(FERR_DISABLEHARDERR);
|
---|
[551] | 551 | fp = _fsopen(arctemp, "r", SH_DENYWR);
|
---|
[300] | 552 |
|
---|
[358] | 553 | if (fp) {
|
---|
[300] | 554 | gotstart = !info->startlist || !*info->startlist; // If list has no start marker
|
---|
| 555 |
|
---|
[551] | 556 | while (!feof(fp) && !gotend && !*pStopFlag) {
|
---|
| 557 | if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
|
---|
| 558 | break;
|
---|
| 559 | if (!gotstart) {
|
---|
| 560 | if (!strcmp(s, info->startlist))
|
---|
| 561 | gotstart = TRUE;
|
---|
| 562 | }
|
---|
| 563 | else if (info->endlist && !strcmp(s, info->endlist))
|
---|
| 564 | gotend = TRUE;
|
---|
| 565 | else {
|
---|
[300] | 566 | /* add to container */
|
---|
[551] | 567 | fname = NULL;
|
---|
| 568 | bstrip(s);
|
---|
| 569 | if (info->nameisfirst) {
|
---|
| 570 | strncpy(lonename, s, CCHMAXPATH + 2);
|
---|
| 571 | lonename[CCHMAXPATH + 1] = 0;
|
---|
| 572 | fname = lonename;
|
---|
| 573 | if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
|
---|
| 574 | break;
|
---|
| 575 | if (*fname == '\"') {
|
---|
| 576 | memmove(fname, fname + 1, strlen(fname) + 1);
|
---|
| 577 | p = strchr(fname, '\"');
|
---|
| 578 | if (p)
|
---|
| 579 | *p = 0;
|
---|
| 580 | }
|
---|
| 581 | }
|
---|
| 582 | nsize = NULL;
|
---|
| 583 | osize = fdate = NullStr;
|
---|
| 584 | p = s;
|
---|
| 585 | for (x = 0; x <= highest; x++) {
|
---|
| 586 | pp = p;
|
---|
| 587 | while (*pp && (*pp == ' ' || *pp == '\t')) /* skip leading */
|
---|
| 588 | pp++;
|
---|
| 589 | if (!*pp)
|
---|
| 590 | break;
|
---|
| 591 | wasquote = FALSE;
|
---|
| 592 | p = pp;
|
---|
| 593 | while (*p && (wasquote ||
|
---|
| 594 | ((x != info->fnpos || !info->nameislast) ?
|
---|
| 595 | (*p != ' ' && *p != '\t') : TRUE))) {
|
---|
| 596 | if (*p == '\"') {
|
---|
| 597 | if (!wasquote) {
|
---|
| 598 | wasquote = TRUE;
|
---|
| 599 | memmove(p, p + 1, strlen(p));
|
---|
| 600 | while (*p == ' ' || *p == '\t')
|
---|
| 601 | p++;
|
---|
| 602 | }
|
---|
| 603 | else {
|
---|
| 604 | memmove(p, p + 1, strlen(p));
|
---|
| 605 | break;
|
---|
| 606 | }
|
---|
| 607 | }
|
---|
| 608 | else if (*p)
|
---|
| 609 | p++;
|
---|
| 610 | }
|
---|
| 611 | if (*p) {
|
---|
| 612 | *p = 0;
|
---|
| 613 | p++;
|
---|
| 614 | }
|
---|
| 615 | if (x == info->nsizepos)
|
---|
| 616 | nsize = pp;
|
---|
| 617 | else if (x == info->osizepos)
|
---|
| 618 | osize = pp;
|
---|
| 619 | else if (x == info->fdpos) {
|
---|
| 620 | fdate = pp;
|
---|
| 621 | if (info->fdflds > 1 && info->fdflds < 24) {
|
---|
| 622 | INT y;
|
---|
[2] | 623 |
|
---|
[551] | 624 | if (*p) {
|
---|
| 625 | p--;
|
---|
| 626 | *p = ' ';
|
---|
| 627 | for (y = 0; y < info->fdflds - 1; y++) {
|
---|
| 628 | while (*p && (*p == ' ' || *p == '\t'))
|
---|
| 629 | p++;
|
---|
| 630 | while (*p && (*p != ' ' && *p != '\t'))
|
---|
| 631 | p++;
|
---|
| 632 | x++;
|
---|
| 633 | }
|
---|
| 634 | if (*p) {
|
---|
| 635 | *p = 0;
|
---|
| 636 | p++;
|
---|
| 637 | }
|
---|
| 638 | }
|
---|
| 639 | }
|
---|
| 640 | }
|
---|
| 641 | else if (x == info->fnpos) {
|
---|
| 642 | fname = pp;
|
---|
| 643 | if (pp && *pp == '*' && !*(pp + 1)) /* workaround for LH.EXE */
|
---|
| 644 | fname = NULL;
|
---|
| 645 | if (info->nameislast)
|
---|
| 646 | break;
|
---|
| 647 | }
|
---|
| 648 | else if ((!p || !*p) && info->fnpos == -1) {
|
---|
| 649 | fname = pp;
|
---|
| 650 | break;
|
---|
| 651 | }
|
---|
| 652 | }
|
---|
| 653 | if (info->nameisnext) {
|
---|
| 654 | if (!xfgets_bstripcr
|
---|
| 655 | (lonename, sizeof(lonename), fp, pszSrcFile, __LINE__))
|
---|
| 656 | break;
|
---|
| 657 | fname = lonename;
|
---|
| 658 | }
|
---|
[423] | 659 | // fixme to complain?
|
---|
[551] | 660 | if (fname && *fname) {
|
---|
[2] | 661 |
|
---|
[551] | 662 | RECORDINSERT ri;
|
---|
| 663 | PARCITEM pai;
|
---|
[2] | 664 |
|
---|
| 665 | #ifdef DEBUG
|
---|
[551] | 666 | saymsg(MB_ENTER, hwndCnr, DEBUG_STRING,
|
---|
| 667 | "fname: %s\r\rpp: %s\r\rp: %s\r\rlonename: %s\r\rhighest: %ld\r\rx: %ld\r\rfdate: %s",
|
---|
[562] | 668 | fname ? fname : "NULL",
|
---|
| 669 | pp ? pp : "NULL",
|
---|
| 670 | p ? p : "NULL",
|
---|
[551] | 671 | lonename, highest, x, (fdate) ? fdate : "NULL");
|
---|
[2] | 672 | #endif
|
---|
| 673 |
|
---|
[551] | 674 | pai = WinSendMsg(hwndCnr,
|
---|
| 675 | CM_ALLOCRECORD,
|
---|
| 676 | MPFROMLONG(EXTRA_ARCRECORD_BYTES),
|
---|
| 677 | MPFROMLONG(1L));
|
---|
| 678 | if (!pai) {
|
---|
[358] | 679 | Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD");
|
---|
| 680 | break;
|
---|
| 681 | }
|
---|
| 682 | else {
|
---|
[551] | 683 | memset(pai, 0, sizeof(ARCITEM));
|
---|
| 684 | pai->hwndCnr = hwndCnr;
|
---|
| 685 | if (*fname == '*') {
|
---|
| 686 | fname++;
|
---|
| 687 | pai->flags = ARCFLAGS_REALDIR;
|
---|
[358] | 688 | }
|
---|
[551] | 689 | if (fname[strlen(fname) - 1] == '\\' ||
|
---|
| 690 | fname[strlen(fname) - 1] == '/')
|
---|
| 691 | pai->flags = ARCFLAGS_REALDIR;
|
---|
[730] | 692 | pai->pszFileName = xstrdup(fname,pszSrcFile, __LINE__);
|
---|
[762] | 693 | pai->pszDisplayName = pai->pszFileName;
|
---|
| 694 | pai->rc.pszIcon = pai->pszDisplayName;
|
---|
[551] | 695 | if (fdate)
|
---|
| 696 | strcpy(pai->szDate, fdate);
|
---|
[730] | 697 | // pai->pszFileName = pai->pszFileName;
|
---|
[551] | 698 | pai->rc.pszIcon = pai->pszFileName;
|
---|
[562] | 699 | pai->rc.hptrIcon = (pai->flags & ARCFLAGS_REALDIR) != 0 ?
|
---|
[551] | 700 | hptrDir : hptrFile;
|
---|
| 701 | pai->pszDate = pai->szDate;
|
---|
| 702 | if (osize)
|
---|
| 703 | pai->cbFile = atol(osize);
|
---|
| 704 | if (nsize)
|
---|
| 705 | pai->cbComp = atol(nsize);
|
---|
| 706 | if (info->datetype && fdate && *fdate)
|
---|
| 707 | ArcDateTime(fdate, info->datetype, &pai->date, &pai->time);
|
---|
| 708 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
| 709 | ri.cb = sizeof(RECORDINSERT);
|
---|
| 710 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
| 711 | ri.pRecordParent = (PRECORDCORE) NULL;
|
---|
| 712 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
| 713 | ri.cRecordsInsert = 1L;
|
---|
| 714 | ri.fInvalidateRecord = FALSE;
|
---|
| 715 | if (WinSendMsg(hwndCnr,
|
---|
| 716 | CM_INSERTRECORD, MPFROMP(pai), MPFROMP(&ri))) {
|
---|
| 717 | *pullTotalBytes += pai->cbFile;
|
---|
| 718 | }
|
---|
| 719 | numarcfiles++;
|
---|
| 720 | if (!(++counter % 50)) {
|
---|
| 721 | if (!lastpai)
|
---|
| 722 | lastpai = pai;
|
---|
| 723 | WinSendMsg(hwndCnr,
|
---|
| 724 | CM_INVALIDATERECORD,
|
---|
| 725 | lastpai,
|
---|
| 726 | MPFROM2SHORT(10, CMA_ERASE | CMA_REPOSITION));
|
---|
| 727 | lastpai = pai;
|
---|
| 728 | }
|
---|
[426] | 729 | // Avoid hogging system for large archive
|
---|
| 730 | if (numarcfiles == 100)
|
---|
[551] | 731 | priority_idle();
|
---|
| 732 | }
|
---|
| 733 | }
|
---|
| 734 | }
|
---|
| 735 | } // while !eof
|
---|
[300] | 736 |
|
---|
[2] | 737 | fclose(fp);
|
---|
[300] | 738 |
|
---|
[426] | 739 | if (*pStopFlag)
|
---|
[551] | 740 | numarcfiles = 0; // Request close
|
---|
| 741 | else if (!numarcfiles || !gotstart
|
---|
| 742 | || (!gotend && info->endlist && *info->endlist)) {
|
---|
[423] | 743 | // Oops
|
---|
[551] | 744 | ARCDUMP ad;
|
---|
| 745 | CHAR errstr[CCHMAXPATH + 256];
|
---|
[2] | 746 |
|
---|
[423] | 747 | // Try for alternate archiver
|
---|
[551] | 748 | tinfo = info;
|
---|
| 749 | do {
|
---|
| 750 | tinfo = tinfo->next;
|
---|
| 751 | if (tinfo)
|
---|
| 752 | tinfo = find_type(arcname, tinfo);
|
---|
| 753 | if (tinfo) {
|
---|
| 754 | DosError(FERR_DISABLEHARDERR);
|
---|
| 755 | DosForceDelete(arctemp);
|
---|
| 756 | info = tinfo;
|
---|
| 757 | goto ReTry;
|
---|
| 758 | }
|
---|
| 759 | } while (tinfo);
|
---|
| 760 | DosBeep(750, 50); // wake up user
|
---|
| 761 | sprintf(errstr, GetPString(IDS_ARCERRORINFOTEXT),
|
---|
| 762 | arcname,
|
---|
[562] | 763 | !gotstart ? GetPString(IDS_NOGOTSTARTTEXT) : NullStr,
|
---|
| 764 | !numarcfiles ? GetPString(IDS_NOARCFILESFOUNDTEXT) :
|
---|
[551] | 765 | NullStr,
|
---|
[562] | 766 | !gotend ? GetPString(IDS_NOENDOFLISTTEXT) : NullStr);
|
---|
[551] | 767 | memset(&ad, 0, sizeof(ARCDUMP));
|
---|
| 768 | ad.info = info;
|
---|
| 769 | strcpy(ad.listname, arctemp);
|
---|
| 770 | strcpy(ad.arcname, arcname);
|
---|
| 771 | ad.errmsg = errstr;
|
---|
| 772 | WinDlgBox(HWND_DESKTOP,
|
---|
| 773 | hwndCnr,
|
---|
| 774 | ArcErrProc, FM3ModHandle, ARCERR_FRAME, MPFROMP(&ad));
|
---|
[2] | 775 | }
|
---|
[249] | 776 | else if (!nomove && tinfo) {
|
---|
| 777 | /* if we got a false hit, move working hit to top */
|
---|
[551] | 778 | tinfo = info->next;
|
---|
| 779 | info->next = arcsighead;
|
---|
| 780 | arcsighead->prev = info;
|
---|
| 781 | if (tinfo)
|
---|
| 782 | tinfo->next->prev = info->prev;
|
---|
| 783 | info->prev->next = tinfo;
|
---|
| 784 | info->prev = NULL;
|
---|
| 785 | arcsighead = info;
|
---|
| 786 | rewrite_archiverbb2(NULL); // Rewrite with warning
|
---|
[2] | 787 | }
|
---|
[551] | 788 | } // if opened
|
---|
[426] | 789 |
|
---|
[2] | 790 | DosError(FERR_DISABLEHARDERR);
|
---|
| 791 | DosForceDelete(arctemp);
|
---|
| 792 | }
|
---|
| 793 |
|
---|
[426] | 794 | if (numarcfiles)
|
---|
[423] | 795 | priority_normal();
|
---|
| 796 |
|
---|
[2] | 797 | return numarcfiles;
|
---|
| 798 | }
|
---|
| 799 |
|
---|
[551] | 800 | MRESULT EXPENTRY ArcTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[172] | 801 | {
|
---|
[551] | 802 | static BOOL emphasized = FALSE;
|
---|
| 803 | static HWND hwndButtonPopup = (HWND) 0;
|
---|
| 804 | static ULONG timestamp = ULONG_MAX;
|
---|
| 805 | static USHORT lastid = 0;
|
---|
[2] | 806 |
|
---|
[551] | 807 | switch (msg) {
|
---|
| 808 | case WM_CREATE:
|
---|
| 809 | return CommonTextProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 810 |
|
---|
[551] | 811 | case WM_COMMAND:
|
---|
| 812 | return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 813 | ARC_CNR), msg, mp1, mp2);
|
---|
[2] | 814 |
|
---|
[551] | 815 | case UM_CONTEXTMENU:
|
---|
| 816 | case WM_CONTEXTMENU:
|
---|
| 817 | {
|
---|
| 818 | USHORT id;
|
---|
[2] | 819 |
|
---|
[551] | 820 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 821 | switch (id) {
|
---|
| 822 | case DIR_SELECTED:
|
---|
| 823 | case DIR_VIEW:
|
---|
| 824 | case DIR_SORT:
|
---|
| 825 | {
|
---|
| 826 | POINTL ptl = { 0, 0 };
|
---|
| 827 | SWP swp;
|
---|
| 828 | DIRCNRDATA *dcd;
|
---|
[2] | 829 |
|
---|
[551] | 830 | if (hwndButtonPopup)
|
---|
| 831 | WinDestroyWindow(hwndButtonPopup);
|
---|
| 832 | if (id == DIR_SELECTED)
|
---|
| 833 | id = DIR_RESTORE;
|
---|
| 834 | if (id == lastid) {
|
---|
[2] | 835 |
|
---|
[551] | 836 | ULONG check;
|
---|
[2] | 837 |
|
---|
[551] | 838 | DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &check,
|
---|
| 839 | sizeof(check));
|
---|
| 840 | if (check < timestamp + 500) {
|
---|
| 841 | lastid = 0;
|
---|
| 842 | goto MenuAbort;
|
---|
| 843 | }
|
---|
| 844 | }
|
---|
| 845 | hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
|
---|
| 846 | if (hwndButtonPopup) {
|
---|
| 847 | WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
|
---|
| 848 | dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
|
---|
| 849 | QW_PARENT),
|
---|
| 850 | ARC_CNR), QWL_USER);
|
---|
| 851 | if (id == DIR_SORT) {
|
---|
| 852 | if (dcd)
|
---|
| 853 | SetSortChecks(hwndButtonPopup, dcd->sortFlags);
|
---|
| 854 | WinSendMsg(hwndButtonPopup,
|
---|
| 855 | MM_DELETEITEM,
|
---|
| 856 | MPFROM2SHORT(IDM_SORTNONE, FALSE), MPVOID);
|
---|
| 857 | WinSendMsg(hwndButtonPopup,
|
---|
| 858 | MM_DELETEITEM,
|
---|
| 859 | MPFROM2SHORT(IDM_SORTNAME, FALSE), MPVOID);
|
---|
| 860 | WinSendMsg(hwndButtonPopup,
|
---|
| 861 | MM_DELETEITEM,
|
---|
| 862 | MPFROM2SHORT(IDM_SORTLADATE, FALSE), MPVOID);
|
---|
| 863 | WinSendMsg(hwndButtonPopup,
|
---|
| 864 | MM_DELETEITEM,
|
---|
| 865 | MPFROM2SHORT(IDM_SORTCRDATE, FALSE), MPVOID);
|
---|
| 866 | WinSendMsg(hwndButtonPopup,
|
---|
| 867 | MM_DELETEITEM,
|
---|
| 868 | MPFROM2SHORT(IDM_SORTDIRSFIRST, FALSE), MPVOID);
|
---|
| 869 | WinSendMsg(hwndButtonPopup,
|
---|
| 870 | MM_DELETEITEM,
|
---|
| 871 | MPFROM2SHORT(IDM_SORTDIRSLAST, FALSE), MPVOID);
|
---|
| 872 | WinSendMsg(hwndButtonPopup,
|
---|
| 873 | MM_DELETEITEM,
|
---|
| 874 | MPFROM2SHORT(IDM_SORTSUBJECT, FALSE), MPVOID);
|
---|
| 875 | WinSendMsg(hwndButtonPopup,
|
---|
| 876 | MM_SETITEMTEXT,
|
---|
| 877 | MPFROM2SHORT(IDM_SORTEASIZE, 0),
|
---|
| 878 | MPFROMP(GetPString(IDS_COMPRESSEDSIZEMENUTEXT)));
|
---|
| 879 | WinSendMsg(hwndButtonPopup,
|
---|
| 880 | MM_SETITEMTEXT,
|
---|
| 881 | MPFROM2SHORT(IDM_SORTLWDATE, 0),
|
---|
| 882 | MPFROMP(GetPString(IDS_DATEMENUTEXT)));
|
---|
| 883 | }
|
---|
| 884 | ptl.x = 0;
|
---|
| 885 | if (WinPopupMenu(HWND_OBJECT,
|
---|
| 886 | HWND_OBJECT,
|
---|
| 887 | hwndButtonPopup, -32767, -32767, 0, 0)) {
|
---|
| 888 | WinQueryWindowPos(hwndButtonPopup, &swp);
|
---|
| 889 | ptl.y = -(swp.cy + 2);
|
---|
| 890 | }
|
---|
| 891 | else {
|
---|
| 892 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 893 | ptl.y = swp.cy + 2;
|
---|
| 894 | }
|
---|
| 895 | if (WinPopupMenu(hwnd,
|
---|
| 896 | hwnd,
|
---|
| 897 | hwndButtonPopup,
|
---|
| 898 | ptl.x,
|
---|
| 899 | ptl.y,
|
---|
| 900 | 0,
|
---|
| 901 | PU_HCONSTRAIN | PU_VCONSTRAIN |
|
---|
| 902 | PU_KEYBOARD | PU_MOUSEBUTTON1)) {
|
---|
| 903 | CenterOverWindow(hwndButtonPopup);
|
---|
| 904 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
|
---|
| 905 | }
|
---|
| 906 | }
|
---|
| 907 | }
|
---|
| 908 | break;
|
---|
| 909 | default:
|
---|
| 910 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 911 | ARC_CNR),
|
---|
| 912 | WM_CONTROL, MPFROM2SHORT(ARC_CNR, CN_CONTEXTMENU), MPVOID);
|
---|
| 913 | break;
|
---|
[2] | 914 | }
|
---|
[551] | 915 | }
|
---|
| 916 | MenuAbort:
|
---|
| 917 | if (msg == UM_CONTEXTMENU)
|
---|
| 918 | return 0;
|
---|
| 919 | break;
|
---|
[2] | 920 |
|
---|
[551] | 921 | case WM_MENUEND:
|
---|
| 922 | if (hwndButtonPopup == (HWND) mp2) {
|
---|
| 923 | lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
|
---|
| 924 | WinDestroyWindow(hwndButtonPopup);
|
---|
| 925 | hwndButtonPopup = (HWND) 0;
|
---|
| 926 | DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, ×tamp,
|
---|
| 927 | sizeof(timestamp));
|
---|
| 928 | switch (lastid) {
|
---|
| 929 | case DIR_VIEW:
|
---|
| 930 | case DIR_SORT:
|
---|
| 931 | case DIR_RESTORE:
|
---|
| 932 | case DIR_SELECTED:
|
---|
| 933 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
|
---|
| 934 | break;
|
---|
[2] | 935 | }
|
---|
[551] | 936 | }
|
---|
| 937 | break;
|
---|
[2] | 938 |
|
---|
[551] | 939 | case WM_MOUSEMOVE:
|
---|
| 940 | {
|
---|
| 941 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 942 | char *s = NULL;
|
---|
[2] | 943 |
|
---|
[551] | 944 | if (fOtherHelp) {
|
---|
| 945 | if ((!hwndBubble ||
|
---|
| 946 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
|
---|
| 947 | !WinQueryCapture(HWND_DESKTOP)) {
|
---|
| 948 | switch (id) {
|
---|
| 949 | case DIR_TOTALS:
|
---|
| 950 | s = GetPString(IDS_ARCCNRTOTALSHELPTEXT);
|
---|
| 951 | break;
|
---|
| 952 | case DIR_SELECTED:
|
---|
| 953 | s = GetPString(IDS_ARCCNRSELECTEDHELPTEXT);
|
---|
| 954 | break;
|
---|
| 955 | case DIR_VIEW:
|
---|
| 956 | s = GetPString(IDS_ARCCNRVIEWHELPTEXT);
|
---|
| 957 | break;
|
---|
| 958 | case DIR_SORT:
|
---|
| 959 | s = GetPString(IDS_DIRCNRSORTHELP);
|
---|
| 960 | break;
|
---|
| 961 | case DIR_FILTER:
|
---|
| 962 | s = GetPString(IDS_DIRCNRFILTERHELP);
|
---|
| 963 | break;
|
---|
| 964 | case DIR_FOLDERICON:
|
---|
| 965 | s = GetPString(IDS_ARCCNRFOLDERHELPTEXT);
|
---|
| 966 | break;
|
---|
| 967 | default:
|
---|
| 968 | break;
|
---|
| 969 | }
|
---|
| 970 | if (s)
|
---|
| 971 | MakeBubble(hwnd, TRUE, s);
|
---|
| 972 | else if (hwndBubble)
|
---|
| 973 | WinDestroyWindow(hwndBubble);
|
---|
| 974 | }
|
---|
[2] | 975 | }
|
---|
[551] | 976 | switch (id) {
|
---|
| 977 | case DIR_FILTER:
|
---|
| 978 | case DIR_SORT:
|
---|
| 979 | case DIR_VIEW:
|
---|
| 980 | case DIR_SELECTED:
|
---|
| 981 | case DIR_FOLDERICON:
|
---|
| 982 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
| 983 | }
|
---|
| 984 | }
|
---|
| 985 | break;
|
---|
[2] | 986 |
|
---|
[551] | 987 | case WM_BUTTON3UP:
|
---|
| 988 | case WM_BUTTON1UP:
|
---|
| 989 | case WM_BUTTON1DOWN:
|
---|
| 990 | case WM_BUTTON3DOWN:
|
---|
| 991 | {
|
---|
| 992 | USHORT id;
|
---|
[2] | 993 |
|
---|
[551] | 994 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 995 | switch (id) {
|
---|
| 996 | case DIR_FILTER:
|
---|
| 997 | case DIR_SORT:
|
---|
| 998 | case DIR_VIEW:
|
---|
| 999 | case DIR_SELECTED:
|
---|
| 1000 | case DIR_FOLDERICON:
|
---|
| 1001 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
[2] | 1002 | }
|
---|
[551] | 1003 | }
|
---|
| 1004 | break;
|
---|
[2] | 1005 |
|
---|
[551] | 1006 | case UM_CLICKED:
|
---|
| 1007 | case UM_CLICKED3:
|
---|
| 1008 | {
|
---|
| 1009 | USHORT id, cmd = 0;
|
---|
[2] | 1010 |
|
---|
[551] | 1011 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 1012 | switch (id) {
|
---|
| 1013 | case DIR_FOLDERICON:
|
---|
| 1014 | switch (msg) {
|
---|
| 1015 | case WM_BUTTON3CLICK:
|
---|
| 1016 | case WM_CHORD:
|
---|
| 1017 | cmd = IDM_RESCAN;
|
---|
| 1018 | break;
|
---|
| 1019 | default:
|
---|
| 1020 | if ((SHORT2FROMMP(mp2) & KC_ALT) != 0)
|
---|
| 1021 | cmd = IDM_WINDOWDLG;
|
---|
| 1022 | else
|
---|
| 1023 | cmd = IDM_WALKDIR;
|
---|
| 1024 | break;
|
---|
| 1025 | }
|
---|
| 1026 | break;
|
---|
| 1027 | case DIR_VIEW:
|
---|
| 1028 | case DIR_SORT:
|
---|
| 1029 | case DIR_SELECTED:
|
---|
| 1030 | PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
|
---|
| 1031 | break;
|
---|
| 1032 | case DIR_FILTER:
|
---|
| 1033 | cmd = IDM_FILTER;
|
---|
| 1034 | break;
|
---|
| 1035 | default:
|
---|
| 1036 | break;
|
---|
[2] | 1037 | }
|
---|
[551] | 1038 | if (cmd)
|
---|
| 1039 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1040 | ARC_CNR),
|
---|
| 1041 | WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
|
---|
| 1042 | }
|
---|
| 1043 | return 0;
|
---|
[2] | 1044 |
|
---|
[551] | 1045 | case WM_BEGINDRAG:
|
---|
| 1046 | case DM_DROP:
|
---|
| 1047 | case DM_DRAGOVER:
|
---|
| 1048 | case DM_DRAGLEAVE:
|
---|
| 1049 | case DM_DROPHELP:
|
---|
| 1050 | if (msg == DM_DRAGOVER) {
|
---|
| 1051 | if (!emphasized) {
|
---|
| 1052 | emphasized = TRUE;
|
---|
| 1053 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
[2] | 1054 | }
|
---|
[551] | 1055 | }
|
---|
| 1056 | else if (msg != WM_BEGINDRAG) {
|
---|
| 1057 | if (emphasized) {
|
---|
| 1058 | emphasized = FALSE;
|
---|
| 1059 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
[2] | 1060 | }
|
---|
[551] | 1061 | }
|
---|
| 1062 | switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
|
---|
| 1063 | case DIR_FOLDERICON:
|
---|
| 1064 | switch (msg) {
|
---|
| 1065 | case DM_DRAGOVER:
|
---|
[618] | 1066 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
[551] | 1067 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
[562] | 1068 | return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
|
---|
[551] | 1069 | case DM_DROPHELP:
|
---|
| 1070 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_ARCCNRFOLDERDROPHELPTEXT));
|
---|
| 1071 | return 0;
|
---|
| 1072 | case DM_DROP:
|
---|
| 1073 | {
|
---|
| 1074 | char szFrom[CCHMAXPATH + 2];
|
---|
[2] | 1075 |
|
---|
[551] | 1076 | if (emphasized) {
|
---|
| 1077 | emphasized = FALSE;
|
---|
| 1078 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
| 1079 | }
|
---|
[618] | 1080 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom)))
|
---|
[551] | 1081 | WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1082 | ARC_CNR),
|
---|
| 1083 | WM_COMMAND,
|
---|
| 1084 | MPFROM2SHORT(IDM_SWITCH, 0), MPFROMP(szFrom));
|
---|
| 1085 | }
|
---|
| 1086 | return 0;
|
---|
| 1087 | default:
|
---|
| 1088 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
| 1089 | }
|
---|
| 1090 | default:
|
---|
| 1091 | {
|
---|
| 1092 | CNRDRAGINFO cnd;
|
---|
| 1093 | USHORT dcmd;
|
---|
[2] | 1094 |
|
---|
[551] | 1095 | switch (msg) {
|
---|
| 1096 | case DM_DROP:
|
---|
| 1097 | dcmd = CN_DROP;
|
---|
| 1098 | break;
|
---|
| 1099 | case DM_DRAGOVER:
|
---|
| 1100 | dcmd = CN_DRAGOVER;
|
---|
| 1101 | break;
|
---|
| 1102 | case DM_DRAGLEAVE:
|
---|
| 1103 | dcmd = CN_DRAGLEAVE;
|
---|
| 1104 | break;
|
---|
| 1105 | case DM_DROPHELP:
|
---|
| 1106 | dcmd = CN_DROPHELP;
|
---|
| 1107 | break;
|
---|
| 1108 | case WM_BEGINDRAG:
|
---|
| 1109 | dcmd = CN_INITDRAG;
|
---|
| 1110 | break;
|
---|
| 1111 | }
|
---|
| 1112 | cnd.pDragInfo = (PDRAGINFO) mp1;
|
---|
| 1113 | cnd.pRecord = NULL;
|
---|
| 1114 | return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1115 | WM_CONTROL,
|
---|
| 1116 | MPFROM2SHORT(ARC_CNR, dcmd), MPFROMP(&cnd));
|
---|
[2] | 1117 | }
|
---|
[551] | 1118 | }
|
---|
[2] | 1119 | }
|
---|
[551] | 1120 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
[2] | 1121 | }
|
---|
| 1122 |
|
---|
[551] | 1123 | MRESULT EXPENTRY ArcClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1124 | MPARAM mp2)
|
---|
| 1125 | {
|
---|
[2] | 1126 |
|
---|
[551] | 1127 | switch (msg) {
|
---|
| 1128 | case UM_CONTAINERHWND:
|
---|
| 1129 | return MRFROMLONG(WinWindowFromID(hwnd, ARC_CNR));
|
---|
[2] | 1130 |
|
---|
[551] | 1131 | case UM_VIEWSMENU:
|
---|
| 1132 | // fixme to disble menu items as needed
|
---|
[872] | 1133 | return MRFROMLONG(CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP));
|
---|
[2] | 1134 |
|
---|
[551] | 1135 | case UM_FILESMENU:
|
---|
| 1136 | // fixme to disble menu items as needed
|
---|
[872] | 1137 | return MRFROMLONG(CheckMenu(hwnd, &ArcMenu, ARC_POPUP));
|
---|
[2] | 1138 |
|
---|
[551] | 1139 | case MM_PORTHOLEINIT:
|
---|
| 1140 | case WM_INITMENU:
|
---|
| 1141 | case UM_INITMENU:
|
---|
| 1142 | case UM_COMMAND:
|
---|
| 1143 | case UM_LOADFILE:
|
---|
| 1144 | case UM_UPDATERECORD:
|
---|
| 1145 | case UM_UPDATERECORDLIST:
|
---|
| 1146 | case WM_COMMAND:
|
---|
| 1147 | case WM_CONTROL:
|
---|
| 1148 | case WM_CLOSE:
|
---|
| 1149 | return WinSendMsg(WinWindowFromID(hwnd, ARC_CNR), msg, mp1, mp2);
|
---|
[2] | 1150 |
|
---|
[551] | 1151 | case WM_PSETFOCUS:
|
---|
| 1152 | case WM_SETFOCUS:
|
---|
| 1153 | if (mp2)
|
---|
| 1154 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
---|
| 1155 | break;
|
---|
[2] | 1156 |
|
---|
[551] | 1157 | case UM_FOCUSME:
|
---|
| 1158 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, ARC_CNR));
|
---|
| 1159 | break;
|
---|
[2] | 1160 |
|
---|
[551] | 1161 | case WM_PAINT:
|
---|
| 1162 | {
|
---|
| 1163 | HPS hps;
|
---|
| 1164 | RECTL rcl;
|
---|
[2] | 1165 |
|
---|
[551] | 1166 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
|
---|
| 1167 | if (hps) {
|
---|
| 1168 | WinQueryWindowRect(hwnd, &rcl);
|
---|
| 1169 | WinFillRect(hps, &rcl, CLR_PALEGRAY);
|
---|
| 1170 | CommonTextPaint(hwnd, hps);
|
---|
| 1171 | WinEndPaint(hps);
|
---|
[2] | 1172 | }
|
---|
[551] | 1173 | }
|
---|
| 1174 | break;
|
---|
[2] | 1175 |
|
---|
[551] | 1176 | case UM_SIZE:
|
---|
| 1177 | case WM_SIZE:
|
---|
| 1178 | if (msg == UM_SIZE) {
|
---|
[2] | 1179 |
|
---|
[551] | 1180 | SWP swp;
|
---|
[2] | 1181 |
|
---|
[551] | 1182 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 1183 | mp1 = MPFROM2SHORT(swp.cx, swp.cy);
|
---|
| 1184 | mp2 = MPFROM2SHORT(swp.cx, swp.cy);
|
---|
| 1185 | }
|
---|
| 1186 | {
|
---|
| 1187 | USHORT cx, cy, bx;
|
---|
[2] | 1188 |
|
---|
[551] | 1189 | cx = SHORT1FROMMP(mp2);
|
---|
| 1190 | cy = SHORT2FROMMP(mp2);
|
---|
| 1191 | WinSetWindowPos(WinWindowFromID(hwnd, ARC_CNR), HWND_TOP,
|
---|
| 1192 | 0,
|
---|
| 1193 | 22, cx, cy - (24 + 22), SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1194 | WinSetWindowPos(WinWindowFromID(hwnd, ARC_EXTRACTDIR), HWND_TOP,
|
---|
| 1195 | 0, 0, cx, 22, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1196 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_FOLDERICON), HWND_TOP,
|
---|
| 1197 | 2, cy - 22, 24, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1198 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
|
---|
| 1199 | 29,
|
---|
| 1200 | cy - 22,
|
---|
| 1201 | (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1202 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
|
---|
| 1203 | 29 + (cx / 3) + 2,
|
---|
| 1204 | cy - 22,
|
---|
| 1205 | (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1206 | bx = (cx - (29 + (((cx / 3) + 2) * 2))) / 3;
|
---|
| 1207 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
|
---|
| 1208 | 29 + (((cx / 3) + 2) * 2),
|
---|
| 1209 | cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1210 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
|
---|
| 1211 | 29 + (((cx / 3) + 2) * 2) + bx,
|
---|
| 1212 | cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1213 | WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
|
---|
| 1214 | 29 + (((cx / 3) + 2) * 2) + (bx * 2),
|
---|
| 1215 | cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
| 1216 | }
|
---|
| 1217 | CommonTextPaint(hwnd, (HPS) 0);
|
---|
| 1218 | if (msg == UM_SIZE) {
|
---|
| 1219 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
|
---|
| 1220 | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
|
---|
| 1221 | return 0;
|
---|
| 1222 | }
|
---|
| 1223 | break;
|
---|
[2] | 1224 | }
|
---|
[551] | 1225 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1226 | }
|
---|
| 1227 |
|
---|
[551] | 1228 | MRESULT EXPENTRY ArcObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[172] | 1229 | {
|
---|
[2] | 1230 | DIRCNRDATA *dcd;
|
---|
[358] | 1231 | PSZ psz;
|
---|
[773] | 1232 | CHAR szQuotedArcName[CCHMAXPATH];
|
---|
| 1233 | CHAR szQuotedMemberName[CCHMAXPATH];
|
---|
[2] | 1234 |
|
---|
[551] | 1235 | switch (msg) {
|
---|
| 1236 | case DM_PRINTOBJECT:
|
---|
| 1237 | case DM_DISCARDOBJECT:
|
---|
| 1238 | dcd = INSTDATA(hwnd);
|
---|
| 1239 | if (dcd) {
|
---|
[2] | 1240 |
|
---|
[551] | 1241 | LISTINFO *li;
|
---|
| 1242 | CNRDRAGINFO cni;
|
---|
[2] | 1243 |
|
---|
[551] | 1244 | cni.pRecord = NULL;
|
---|
| 1245 | cni.pDragInfo = (PDRAGINFO) mp1;
|
---|
| 1246 | li = DoFileDrop(dcd->hwndCnr,
|
---|
[762] | 1247 | dcd->directory, FALSE, MPVOID, MPFROMP(&cni));
|
---|
[687] | 1248 | CheckPmDrgLimit(cni.pDragInfo);
|
---|
[551] | 1249 | if (li) {
|
---|
| 1250 | li->type = (msg == DM_DISCARDOBJECT) ? IDM_DELETE : IDM_PRINT;
|
---|
| 1251 | if (!li->list ||
|
---|
| 1252 | !li->list[0] || !PostMsg(hwnd, UM_ACTION, MPFROMP(li), MPVOID))
|
---|
| 1253 | FreeListInfo(li);
|
---|
| 1254 | else
|
---|
| 1255 | return MRFROMLONG(DRR_SOURCE);
|
---|
[2] | 1256 | }
|
---|
[551] | 1257 | }
|
---|
| 1258 | return MRFROMLONG(DRR_TARGET);
|
---|
[2] | 1259 |
|
---|
[551] | 1260 | case DM_RENDERPREPARE:
|
---|
| 1261 | return (MRESULT) TRUE;
|
---|
[2] | 1262 |
|
---|
[551] | 1263 | case DM_RENDER:
|
---|
| 1264 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1265 | if (dcd && dcd->info && dcd->info->extract && dcd->arcname) {
|
---|
[2] | 1266 |
|
---|
[551] | 1267 | PDRAGTRANSFER pdt = (PDRAGTRANSFER) mp1;
|
---|
| 1268 | CHAR filename[CCHMAXPATH];
|
---|
| 1269 | ULONG len;
|
---|
[2] | 1270 |
|
---|
[551] | 1271 | if (pdt->hwndClient && pdt->pditem && pdt->hstrSelectedRMF &&
|
---|
| 1272 | pdt->hstrRenderToName) {
|
---|
| 1273 | if (pdt->usOperation == DO_COPY || pdt->usOperation == DO_MOVE) {
|
---|
| 1274 | *filename = 0;
|
---|
| 1275 | len = DrgQueryStrName(pdt->hstrSelectedRMF, CCHMAXPATH, filename);
|
---|
| 1276 | filename[len] = 0;
|
---|
| 1277 | if (!strnicmp(filename, "OS2FILE,", 8)) {
|
---|
| 1278 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"RMF = \"%s\"",filename);
|
---|
| 1279 | }
|
---|
| 1280 | else {
|
---|
| 1281 | *filename = 0;
|
---|
| 1282 | len =
|
---|
| 1283 | DrgQueryStrName(pdt->hstrRenderToName, CCHMAXPATH, filename);
|
---|
| 1284 | filename[len] = 0;
|
---|
| 1285 | if (len && *filename) {
|
---|
| 1286 | psz = xstrdup(filename, pszSrcFile, __LINE__);
|
---|
| 1287 | if (psz) {
|
---|
| 1288 | PostMsg(hwnd, UM_RENDER, MPFROMP(pdt), MPFROMP(psz));
|
---|
| 1289 | return (MRESULT) TRUE;
|
---|
| 1290 | }
|
---|
| 1291 | }
|
---|
[358] | 1292 | else {
|
---|
[551] | 1293 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"No render-to name given.");
|
---|
[358] | 1294 | }
|
---|
| 1295 | }
|
---|
[551] | 1296 | }
|
---|
| 1297 | pdt->fsReply = DMFL_RENDERRETRY;
|
---|
[2] | 1298 | }
|
---|
[551] | 1299 | }
|
---|
| 1300 | return (MRESULT) FALSE;
|
---|
[2] | 1301 |
|
---|
[551] | 1302 | case UM_RENDER:
|
---|
| 1303 | {
|
---|
| 1304 | PDRAGTRANSFER pdt = (PDRAGTRANSFER) mp1;
|
---|
| 1305 | USHORT usRes = DMFL_RENDERFAIL;
|
---|
[2] | 1306 |
|
---|
[551] | 1307 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1308 | if (dcd && dcd->info && dcd->info->extract && dcd->arcname) {
|
---|
[2] | 1309 |
|
---|
[551] | 1310 | CHAR *filename = (CHAR *) mp2, *p;
|
---|
| 1311 | ULONG len;
|
---|
| 1312 | CHAR membername[CCHMAXPATH], construct[CCHMAXPATH * 2];
|
---|
[2] | 1313 |
|
---|
[551] | 1314 | *membername = 0;
|
---|
| 1315 | len = DrgQueryStrName(pdt->pditem->hstrSourceName,
|
---|
| 1316 | CCHMAXPATH, membername);
|
---|
| 1317 | membername[len] = 0;
|
---|
| 1318 | if (*membername && len && filename) {
|
---|
| 1319 | unlinkf("%s", filename);
|
---|
| 1320 | strcpy(construct, filename);
|
---|
| 1321 | p = strrchr(filename, '\\');
|
---|
| 1322 | if (!p)
|
---|
| 1323 | *construct = 0;
|
---|
| 1324 | else {
|
---|
| 1325 | if (p == filename || *(p - 1) == ':')
|
---|
| 1326 | p++;
|
---|
| 1327 | *p = 0;
|
---|
| 1328 | }
|
---|
| 1329 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%s %s %s\r[%s]",dcd->info->extract,dcd->arcname,membername,construct);
|
---|
| 1330 | runemf2(SEPARATE | WINDOWED | WAIT |
|
---|
[888] | 1331 | (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
|
---|
| 1332 | dcd->hwndClient, pszSrcFile, __LINE__, construct, NULL,
|
---|
[773] | 1333 | "%s %s %s",
|
---|
[551] | 1334 | dcd->info->extract,
|
---|
[773] | 1335 | BldQuotedFileName(szQuotedArcName, dcd->arcname),
|
---|
| 1336 | BldQuotedFileName(szQuotedMemberName, membername));
|
---|
| 1337 | BldFullPathName(construct, construct, membername);
|
---|
[551] | 1338 | if (IsFile(construct) != -1) {
|
---|
| 1339 | rename(construct, filename);
|
---|
| 1340 | unlinkf("%s", construct);
|
---|
| 1341 | if (IsFile(filename) != -1)
|
---|
| 1342 | usRes = DMFL_RENDEROK;
|
---|
| 1343 | }
|
---|
| 1344 | }
|
---|
[2] | 1345 | }
|
---|
[1009] | 1346 | xfree((CHAR *)mp2, pszSrcFile, __LINE__);
|
---|
[551] | 1347 | PostMsg(pdt->hwndClient, DM_RENDERCOMPLETE, MPFROMP(pdt),
|
---|
| 1348 | MPFROM2SHORT(usRes, 0));
|
---|
| 1349 | }
|
---|
| 1350 | return 0;
|
---|
[2] | 1351 |
|
---|
[551] | 1352 | case UM_SETUP:
|
---|
| 1353 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1354 | if (!dcd) {
|
---|
| 1355 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 1356 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 1357 | }
|
---|
| 1358 | else {
|
---|
| 1359 | /* set unique id */
|
---|
| 1360 | WinSetWindowUShort(hwnd, QWS_ID, ARCOBJ_FRAME + (ARC_FRAME - dcd->id));
|
---|
| 1361 | dcd->hwndObject = hwnd; // pass back hwnd
|
---|
| 1362 | if (ParentIsDesktop(hwnd, dcd->hwndParent))
|
---|
[771] | 1363 | DosSleep(100); //05 Aug 07 GKY 250 // Avoid race?
|
---|
[551] | 1364 | }
|
---|
| 1365 | return 0;
|
---|
| 1366 |
|
---|
| 1367 | case UM_RESCAN:
|
---|
| 1368 | /*
|
---|
| 1369 | * populate container
|
---|
| 1370 | */
|
---|
| 1371 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1372 | if (dcd) {
|
---|
| 1373 | if (mp1)
|
---|
| 1374 | strcpy(dcd->arcname, (CHAR *) mp1); // Update name on request
|
---|
| 1375 | dcd->ullTotalBytes = dcd->totalfiles =
|
---|
| 1376 | dcd->selectedfiles = dcd->selectedbytes = 0;
|
---|
| 1377 | WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0");
|
---|
| 1378 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
|
---|
| 1379 | dcd->totalfiles = FillArcCnr(dcd->hwndCnr,
|
---|
| 1380 | dcd->arcname,
|
---|
| 1381 | &dcd->info,
|
---|
| 1382 | &dcd->ullTotalBytes, &dcd->stopflag);
|
---|
| 1383 | if (!dcd->totalfiles)
|
---|
| 1384 | PostMsg(dcd->hwndCnr, WM_CLOSE, MPVOID, MPVOID);
|
---|
[423] | 1385 | else {
|
---|
[551] | 1386 | dcd->arcfilled = TRUE;
|
---|
| 1387 | if (!PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID))
|
---|
| 1388 | WinSendMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 1389 | PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
|
---|
| 1390 | WinSendMsg(dcd->hwndCnr,
|
---|
| 1391 | CM_INVALIDATERECORD,
|
---|
| 1392 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
[2] | 1393 | }
|
---|
[551] | 1394 | }
|
---|
| 1395 | return 0;
|
---|
[2] | 1396 |
|
---|
[551] | 1397 | case UM_SELECT:
|
---|
| 1398 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1399 | if (dcd) {
|
---|
| 1400 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1401 | case IDM_SELECTALL:
|
---|
| 1402 | case IDM_SELECTALLFILES:
|
---|
| 1403 | SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, TRUE);
|
---|
| 1404 | break;
|
---|
| 1405 | case IDM_DESELECTALL:
|
---|
| 1406 | case IDM_DESELECTALLFILES:
|
---|
| 1407 | DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, TRUE);
|
---|
| 1408 | break;
|
---|
| 1409 | case IDM_DESELECTMASK:
|
---|
| 1410 | case IDM_SELECTMASK:
|
---|
| 1411 | {
|
---|
| 1412 | MASK mask;
|
---|
| 1413 | PARCITEM pci = (PARCITEM) mp2;
|
---|
[2] | 1414 |
|
---|
[551] | 1415 | memset(&mask, 0, sizeof(MASK));
|
---|
| 1416 | mask.fNoAttribs = TRUE;
|
---|
| 1417 | mask.fNoDirs = TRUE;
|
---|
| 1418 | strcpy(mask.prompt,
|
---|
| 1419 | GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
|
---|
| 1420 | IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
|
---|
| 1421 | if (pci && (INT) pci != -1)
|
---|
[730] | 1422 | strcpy(mask.szMask, pci->pszFileName);
|
---|
[551] | 1423 | if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
|
---|
| 1424 | FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
|
---|
| 1425 | if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
|
---|
| 1426 | SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, NULL, FALSE);
|
---|
| 1427 | else
|
---|
| 1428 | DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, NULL, FALSE);
|
---|
| 1429 | }
|
---|
| 1430 | }
|
---|
[2] | 1431 |
|
---|
[551] | 1432 | case IDM_INVERT:
|
---|
| 1433 | InvertAll(dcd->hwndCnr);
|
---|
| 1434 | break;
|
---|
[2] | 1435 | }
|
---|
[551] | 1436 | }
|
---|
| 1437 | return 0;
|
---|
[2] | 1438 |
|
---|
[551] | 1439 | case UM_ENTER:
|
---|
| 1440 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1441 | if (dcd) {
|
---|
[2] | 1442 |
|
---|
[551] | 1443 | CHAR *s = (CHAR *) mp1, *p, *pp, filename[CCHMAXPATH];
|
---|
[2] | 1444 |
|
---|
[551] | 1445 | if (s) {
|
---|
| 1446 | if (!dcd->info->extract) {
|
---|
| 1447 | Runtime_Error(pszSrcFile, __LINE__, "no extract");
|
---|
[1009] | 1448 | xfree(s, pszSrcFile, __LINE__);
|
---|
[551] | 1449 | return 0;
|
---|
| 1450 | }
|
---|
[773] | 1451 | runemf2(SEPARATE | WINDOWED | WAIT |
|
---|
[888] | 1452 | (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
|
---|
| 1453 | dcd->hwndClient, pszSrcFile, __LINE__, dcd->workdir, NULL,
|
---|
[773] | 1454 | "%s %s %s",
|
---|
[562] | 1455 | dcd->info->exwdirs ? dcd->info->exwdirs :
|
---|
| 1456 | dcd->info->extract,
|
---|
[773] | 1457 | BldQuotedFileName(szQuotedArcName, dcd->arcname),
|
---|
| 1458 | BldQuotedFileName(szQuotedMemberName, s));
|
---|
[551] | 1459 | if (!dcd->info->exwdirs) {
|
---|
| 1460 | p = s;
|
---|
| 1461 | p = strrchr(s, '\\');
|
---|
| 1462 | pp = strrchr(s, '/');
|
---|
| 1463 | if (p && pp)
|
---|
| 1464 | p = max(p, pp);
|
---|
| 1465 | else if (!p)
|
---|
| 1466 | p = pp;
|
---|
| 1467 | if (p)
|
---|
| 1468 | memmove(s, p + 1, strlen(p + 1));
|
---|
| 1469 | }
|
---|
| 1470 | sprintf(filename, "%s\\%s", dcd->workdir, s);
|
---|
| 1471 | p = filename;
|
---|
| 1472 | while (*p) {
|
---|
| 1473 | if (*p == '/')
|
---|
| 1474 | *p = '\\';
|
---|
| 1475 | p++;
|
---|
| 1476 | }
|
---|
[562] | 1477 | // printf("%s %d UM_ENTER %s %s\n",__FILE__, __LINE__,filename, s); fflush(stdout); // 10 Mar 07 SHL hang
|
---|
[1009] | 1478 | xfree(s, pszSrcFile, __LINE__);
|
---|
[562] | 1479 | if (IsFile(filename) == 1) {
|
---|
[917] | 1480 | #if 1 // 06 Oct 07 SHL fixme to be gone - set to 0 for ticket #58 testing
|
---|
[570] | 1481 | if (fViewChild && fArcStuffVisible)
|
---|
[835] | 1482 | DosSleep(100); // Allow unzip session to finish closing 14 Mar 07 SHL
|
---|
[907] | 1483 | #endif
|
---|
[551] | 1484 | WinSendMsg(dcd->hwndCnr, UM_ENTER, MPFROMP(filename), MPVOID);
|
---|
[562] | 1485 | }
|
---|
[2] | 1486 | }
|
---|
[551] | 1487 | }
|
---|
| 1488 | return 0;
|
---|
[2] | 1489 |
|
---|
[551] | 1490 | case UM_COMMAND:
|
---|
| 1491 | if (mp1) {
|
---|
| 1492 | if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
|
---|
| 1493 | return (MRESULT) TRUE;
|
---|
| 1494 | }
|
---|
| 1495 | return 0;
|
---|
[2] | 1496 |
|
---|
[551] | 1497 | case UM_ACTION:
|
---|
| 1498 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1499 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1500 | if (dcd) {
|
---|
[2] | 1501 |
|
---|
[551] | 1502 | LISTINFO *li = (LISTINFO *) mp1;
|
---|
| 1503 | register INT x;
|
---|
[2] | 1504 |
|
---|
[551] | 1505 | if (li && li->list && li->list[0]) {
|
---|
| 1506 | switch (li->type) {
|
---|
| 1507 | case IDM_ARCHIVE:
|
---|
| 1508 | case IDM_ARCHIVEM:
|
---|
| 1509 | {
|
---|
| 1510 | DIRCNRDATA ad;
|
---|
| 1511 | CHAR szBuffer[1025], *p;
|
---|
[2] | 1512 |
|
---|
[551] | 1513 | if (!li->list[1] && !stricmp(li->list[0], dcd->arcname)) {
|
---|
| 1514 | Runtime_Error(pszSrcFile, __LINE__, "arc to self");
|
---|
| 1515 | break;
|
---|
| 1516 | }
|
---|
| 1517 | ad = *dcd;
|
---|
| 1518 | ad.namecanchange = 0;
|
---|
| 1519 | ad.fmoving = (li->type == IDM_ARCHIVEM);
|
---|
| 1520 | if (!WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ArchiveDlgProc, FM3ModHandle, ARCH_FRAME, (PVOID) & ad) || !*ad.arcname || !*ad.command) /* we blew it */
|
---|
| 1521 | break;
|
---|
| 1522 | /* build the sucker */
|
---|
| 1523 | strcpy(szBuffer, ad.command);
|
---|
| 1524 | strcat(szBuffer, " ");
|
---|
[773] | 1525 |
|
---|
| 1526 | BldQuotedFileName(szBuffer + strlen(szBuffer), ad.arcname);
|
---|
| 1527 |
|
---|
| 1528 | p = &szBuffer[strlen(szBuffer)]; // Remeber where archiver name ends
|
---|
| 1529 |
|
---|
[551] | 1530 | if (ad.mask.szMask) {
|
---|
| 1531 | strcat(szBuffer, " ");
|
---|
[773] | 1532 |
|
---|
| 1533 | BldQuotedFileName(szBuffer + strlen(szBuffer), ad.mask.szMask);
|
---|
[551] | 1534 | }
|
---|
| 1535 | strcat(szBuffer, " ");
|
---|
| 1536 | x = 0;
|
---|
[773] | 1537 |
|
---|
| 1538 | // Run commands avoiding command line overflow
|
---|
[551] | 1539 | while (li->list[x]) {
|
---|
[773] | 1540 |
|
---|
| 1541 | if (IsFile(li->list[x]))
|
---|
[907] | 1542 | BldQuotedFileName(szBuffer + strlen(szBuffer), li->list[x]);
|
---|
[773] | 1543 | else
|
---|
[907] | 1544 | BldQuotedFullPathName(szBuffer + strlen(szBuffer), li->list[x], "*");
|
---|
[773] | 1545 |
|
---|
[551] | 1546 | x++;
|
---|
| 1547 | if (!li->list[x] || strlen(szBuffer) +
|
---|
[1004] | 1548 | strlen(li->list[x]) + 5 > MaxComLineStrg) {
|
---|
[551] | 1549 | runemf2(SEPARATE | WINDOWED |
|
---|
[907] | 1550 | (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED) |
|
---|
| 1551 | WAIT, hwnd, pszSrcFile, __LINE__,
|
---|
| 1552 | NULL, NULL, "%s", szBuffer);
|
---|
[551] | 1553 | *p = 0;
|
---|
| 1554 | }
|
---|
| 1555 | strcat(szBuffer, " ");
|
---|
[773] | 1556 | } // while
|
---|
| 1557 |
|
---|
[551] | 1558 | PostMsg(dcd->hwndCnr, UM_RESCAN, MPFROMSHORT(1), MPVOID);
|
---|
| 1559 | Broadcast(WinQueryAnchorBlock(hwnd),
|
---|
| 1560 | hwndMain, UM_UPDATERECORD, MPFROMP(ad.arcname), MPVOID);
|
---|
| 1561 | Broadcast(WinQueryAnchorBlock(hwnd),
|
---|
| 1562 | hwndMain,
|
---|
| 1563 | UM_UPDATERECORDLIST, MPFROMP(li->list), MPVOID);
|
---|
| 1564 | }
|
---|
| 1565 | break;
|
---|
[2] | 1566 |
|
---|
[551] | 1567 | case IDM_REFRESH:
|
---|
| 1568 | case IDM_DELETE:
|
---|
| 1569 | {
|
---|
| 1570 | CHAR cl[1001], *endofit;
|
---|
| 1571 | INT z;
|
---|
| 1572 | CHECKLIST ck;
|
---|
| 1573 | CHAR prompt[CCHMAXPATH + 257];
|
---|
[2] | 1574 |
|
---|
[551] | 1575 | if (!dcd->info->delete)
|
---|
| 1576 | break;
|
---|
| 1577 | memset(&ck, 0, sizeof(ck));
|
---|
| 1578 | ck.size = sizeof(ck);
|
---|
| 1579 | ck.list = li->list;
|
---|
| 1580 | ck.cmd = li->type;
|
---|
| 1581 | ck.prompt = prompt;
|
---|
| 1582 | sprintf(prompt, GetPString(IDS_ARCCNRDELREFTEXT),
|
---|
| 1583 | (li->type == IDM_DELETE) ?
|
---|
| 1584 | GetPString(IDS_DELETELOWERTEXT) :
|
---|
| 1585 | GetPString(IDS_REFRESHLOWERTEXT),
|
---|
| 1586 | &"s"[li->list[1] == NULL],
|
---|
| 1587 | dcd->arcname,
|
---|
| 1588 | (li->type == IDM_DELETE) ?
|
---|
| 1589 | GetPString(IDS_DELETELOWERTEXT) :
|
---|
| 1590 | GetPString(IDS_REFRESHLOWERTEXT));
|
---|
| 1591 | if (!WinDlgBox(HWND_DESKTOP, hwnd, CheckListProc,
|
---|
| 1592 | FM3ModHandle, CHECK_FRAME, MPFROMP(&ck)))
|
---|
| 1593 | break;
|
---|
| 1594 | li->list = ck.list;
|
---|
| 1595 | if (!li->list || !li->list[0])
|
---|
| 1596 | break;
|
---|
[773] | 1597 | strcpy(cl, li->type == IDM_DELETE ?
|
---|
| 1598 | dcd->info->delete :
|
---|
| 1599 | dcd->info->create);
|
---|
| 1600 | strcat(cl, " ");
|
---|
| 1601 | BldQuotedFileName(cl + strlen(cl), dcd->arcname);
|
---|
[551] | 1602 | endofit = &cl[strlen(cl)];
|
---|
| 1603 | z = 0;
|
---|
| 1604 | do {
|
---|
| 1605 | for (x = z; li->list[x] &&
|
---|
[888] | 1606 | strlen(cl) + strlen(li->list[x]) < 999; x++) {
|
---|
[551] | 1607 | strcat(cl, " ");
|
---|
[773] | 1608 | BldQuotedFileName(cl + strlen(cl), li->list[x]);
|
---|
[551] | 1609 | }
|
---|
| 1610 | z = x;
|
---|
[773] | 1611 | runemf2(SEPARATE | WINDOWED | WAIT |
|
---|
[888] | 1612 | (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
|
---|
| 1613 | hwnd, pszSrcFile, __LINE__, NullStr, NULL, "%s", cl);
|
---|
[551] | 1614 | *endofit = 0;
|
---|
| 1615 | } while (li->list[x]);
|
---|
| 1616 | PostMsg(dcd->hwndCnr, UM_RESCAN, MPFROMSHORT(1), MPVOID);
|
---|
| 1617 | Broadcast(WinQueryAnchorBlock(hwnd),
|
---|
| 1618 | hwndMain,
|
---|
| 1619 | UM_UPDATERECORD, MPFROMP(dcd->arcname), MPVOID);
|
---|
| 1620 | }
|
---|
| 1621 | break;
|
---|
[2] | 1622 |
|
---|
[551] | 1623 | case IDM_PRINT:
|
---|
| 1624 | case IDM_VIRUSSCAN:
|
---|
| 1625 | case IDM_VIEW:
|
---|
| 1626 | case IDM_MCIPLAY:
|
---|
| 1627 | case IDM_VIEWARCHIVE:
|
---|
| 1628 | case IDM_VIEWTEXT:
|
---|
| 1629 | case IDM_VIEWBINARY:
|
---|
| 1630 | case IDM_EDIT:
|
---|
| 1631 | case IDM_EDITTEXT:
|
---|
| 1632 | case IDM_EDITBINARY:
|
---|
| 1633 | case IDM_EXEC:
|
---|
| 1634 | case IDM_EXTRACTWDIRS:
|
---|
| 1635 | case IDM_EXTRACT:
|
---|
| 1636 | {
|
---|
| 1637 | CHAR cl[1001], *endofit, *ptr;
|
---|
| 1638 | INT z;
|
---|
[2] | 1639 |
|
---|
[551] | 1640 | if ((li->type == IDM_EXTRACT && !li->info->extract) ||
|
---|
| 1641 | ((li->type == IDM_VIEW || li->type == IDM_VIEWTEXT ||
|
---|
| 1642 | li->type == IDM_VIEWBINARY || li->type == IDM_EDIT ||
|
---|
| 1643 | li->type == IDM_VIEWARCHIVE || li->type == IDM_EDITTEXT ||
|
---|
| 1644 | li->type == IDM_EDITBINARY || li->type == IDM_MCIPLAY) &&
|
---|
| 1645 | (!li->info->extract && !li->info->exwdirs)) ||
|
---|
| 1646 | (li->type != IDM_EXTRACT && li->type != IDM_EDIT &&
|
---|
| 1647 | li->type != IDM_VIEW && li->type != IDM_VIEWTEXT &&
|
---|
| 1648 | li->type != IDM_VIEWBINARY &&
|
---|
| 1649 | li->type != IDM_VIEWARCHIVE &&
|
---|
| 1650 | li->type != IDM_EDITTEXT &&
|
---|
| 1651 | li->type != IDM_EDITBINARY &&
|
---|
| 1652 | li->type != IDM_MCIPLAY && !li->info->exwdirs)) {
|
---|
| 1653 | Runtime_Error(pszSrcFile, __LINE__, "no cmd for request");
|
---|
| 1654 | break;
|
---|
| 1655 | }
|
---|
| 1656 | if (li->type == IDM_EXTRACT || li->type == IDM_EXTRACTWDIRS) {
|
---|
[2] | 1657 |
|
---|
[551] | 1658 | CHAR fullname[CCHMAXPATH * 2];
|
---|
| 1659 | CHAR **exfiles = NULL;
|
---|
[907] | 1660 | UINT numfiles = 0, numalloc = 0;
|
---|
[2] | 1661 |
|
---|
[551] | 1662 | for (x = 0; li->list[x]; x++) {
|
---|
[773] | 1663 | BldFullPathName(fullname, li->targetpath, li->list[x]);
|
---|
[551] | 1664 | if (IsFile(fullname) != -1) {
|
---|
| 1665 | AddToList(li->list[x], &exfiles, &numfiles, &numalloc);
|
---|
| 1666 | li->list = RemoveFromList(li->list, li->list[x]);
|
---|
| 1667 | if (!li->list)
|
---|
| 1668 | break;
|
---|
| 1669 | x--;
|
---|
| 1670 | }
|
---|
| 1671 | }
|
---|
| 1672 | if (exfiles && numfiles) {
|
---|
[2] | 1673 |
|
---|
[551] | 1674 | CHECKLIST ckl;
|
---|
| 1675 | CHAR prompt[(CCHMAXPATH * 2) + 256];
|
---|
[2] | 1676 |
|
---|
[551] | 1677 | memset(&ckl, 0, sizeof(ckl));
|
---|
| 1678 | ckl.size = sizeof(ckl);
|
---|
| 1679 | ckl.list = exfiles;
|
---|
| 1680 | ckl.prompt = prompt;
|
---|
| 1681 | ckl.cmd = li->type;
|
---|
| 1682 | sprintf(prompt,
|
---|
| 1683 | GetPString(IDS_REPLACEWARNTEXT),
|
---|
| 1684 | &"s"[numfiles == 1],
|
---|
| 1685 | li->arcname, &"s"[numfiles != 1], li->targetpath);
|
---|
| 1686 | if (!WinDlgBox(HWND_DESKTOP, hwnd, CheckListProc,
|
---|
| 1687 | FM3ModHandle, CHECK_FRAME, MPFROMP(&ckl))) {
|
---|
| 1688 | if (ckl.list)
|
---|
| 1689 | FreeList(ckl.list);
|
---|
| 1690 | break;
|
---|
| 1691 | }
|
---|
| 1692 | else if (ckl.list)
|
---|
| 1693 | li->list = CombineLists(li->list, ckl.list);
|
---|
| 1694 | }
|
---|
| 1695 | }
|
---|
| 1696 | if (!li->list || !li->list[0])
|
---|
| 1697 | break;
|
---|
[773] | 1698 | strcpy(cl,
|
---|
| 1699 | (li->type == IDM_EXTRACT ||
|
---|
| 1700 | ((li->type == IDM_VIEW ||
|
---|
| 1701 | li->type == IDM_VIEWTEXT ||
|
---|
| 1702 | li->type == IDM_VIEWBINARY ||
|
---|
| 1703 | li->type == IDM_VIEWARCHIVE ||
|
---|
| 1704 | li->type == IDM_PRINT ||
|
---|
| 1705 | li->type == IDM_EDIT ||
|
---|
| 1706 | li->type == IDM_EDITTEXT ||
|
---|
| 1707 | (li->type == IDM_EDITBINARY &&
|
---|
| 1708 | li->type == IDM_MCIPLAY)) &&
|
---|
| 1709 | !li->info->exwdirs)) ?
|
---|
| 1710 | li->info->extract :
|
---|
| 1711 | li->info->exwdirs);
|
---|
| 1712 | strcat(cl, " ");
|
---|
| 1713 | BldQuotedFileName(cl + strlen(cl), li->arcname);
|
---|
[888] | 1714 | endofit = &cl[strlen(cl)];
|
---|
| 1715 | z = 0;
|
---|
| 1716 | do {
|
---|
| 1717 | for (x = z; li->list[x] &&
|
---|
[551] | 1718 | strlen(cl) + strlen(li->list[x]) < 999; x++) {
|
---|
| 1719 | strcat(cl, " ");
|
---|
[773] | 1720 | BldQuotedFileName(cl + strlen(cl), li->list[x]);
|
---|
[551] | 1721 | ptr = li->list[x];
|
---|
| 1722 | while (*ptr) {
|
---|
| 1723 | if (*ptr == '/')
|
---|
| 1724 | *ptr = '\\';
|
---|
| 1725 | ptr++;
|
---|
| 1726 | }
|
---|
| 1727 | }
|
---|
| 1728 | z = x;
|
---|
| 1729 | runemf2(SEPARATE | WINDOWED |
|
---|
[888] | 1730 | (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED) |
|
---|
[907] | 1731 | WAIT, hwnd, pszSrcFile, __LINE__,
|
---|
| 1732 | li->targetpath, NULL, "%s", cl);
|
---|
[551] | 1733 | *endofit = 0;
|
---|
| 1734 | } while (li->list[x]);
|
---|
| 1735 | if (li->type == IDM_EXTRACT || li->type == IDM_EXTRACTWDIRS) {
|
---|
| 1736 | /* update windows */
|
---|
| 1737 | for (x = 0; li->list[x]; x++) {
|
---|
[2] | 1738 |
|
---|
[551] | 1739 | CHAR *temp, *p;
|
---|
[2] | 1740 |
|
---|
[551] | 1741 | temp = li->list[x];
|
---|
| 1742 | p = temp;
|
---|
| 1743 | while (*p) {
|
---|
| 1744 | if (*p == '/')
|
---|
| 1745 | *p = '\\';
|
---|
| 1746 | p++;
|
---|
| 1747 | }
|
---|
[1017] | 1748 | p = xmalloc(strlen(temp) + strlen(li->targetpath) + 2,
|
---|
| 1749 | pszSrcFile, __LINE__);
|
---|
[551] | 1750 | if (p) {
|
---|
| 1751 | strcpy(p, li->targetpath);
|
---|
| 1752 | if (p[strlen(p) - 1] != '\\')
|
---|
| 1753 | strcat(p, "\\");
|
---|
| 1754 | strcat(p, temp);
|
---|
| 1755 | li->list[x] = p;
|
---|
[1009] | 1756 | xfree(temp, pszSrcFile, __LINE__);
|
---|
[551] | 1757 | }
|
---|
| 1758 | }
|
---|
| 1759 | if (fFolderAfterExtract) {
|
---|
[2] | 1760 |
|
---|
[551] | 1761 | CHAR objectpath[CCHMAXPATH], *p;
|
---|
| 1762 | APIRET rc;
|
---|
[2] | 1763 |
|
---|
[551] | 1764 | GetDesktopName(objectpath, sizeof(objectpath));
|
---|
| 1765 | rc = WinDlgBox(HWND_DESKTOP, dcd->hwndParent, ObjCnrDlgProc,
|
---|
| 1766 | FM3ModHandle, OBJCNR_FRAME,
|
---|
| 1767 | MPFROMP(objectpath));
|
---|
| 1768 | if (rc) {
|
---|
| 1769 | if (rc > 1)
|
---|
| 1770 | strcpy(objectpath, "<WP_DESKTOP>");
|
---|
| 1771 | p = NULL;
|
---|
| 1772 | if (li->arcname) {
|
---|
| 1773 | p = strrchr(li->arcname, '\\');
|
---|
| 1774 | if (p)
|
---|
| 1775 | p++;
|
---|
| 1776 | }
|
---|
| 1777 | MakeShadows(dcd->hwndParent, li->list, 2, objectpath, p);
|
---|
| 1778 | }
|
---|
| 1779 | }
|
---|
| 1780 | Broadcast(WinQueryAnchorBlock(hwnd),
|
---|
| 1781 | hwndMain,
|
---|
| 1782 | UM_UPDATERECORDLIST, MPFROMP(li->list), MPVOID);
|
---|
| 1783 | }
|
---|
| 1784 | else if (li->type == IDM_EXEC)
|
---|
| 1785 | ExecOnList(hwnd,
|
---|
| 1786 | li->runfile,
|
---|
| 1787 | WINDOWED | SEPARATEKEEP | PROMPT,
|
---|
| 1788 | li->targetpath,
|
---|
[907] | 1789 | NULL, GetPString(IDS_EXECARCFILETITLETEXT),
|
---|
| 1790 | pszSrcFile, __LINE__);
|
---|
[551] | 1791 | else if (li->type == IDM_VIRUSSCAN)
|
---|
| 1792 | ExecOnList(hwnd, virus, PROMPT | WINDOWED | SEPARATEKEEP,
|
---|
| 1793 | li->targetpath, NULL,
|
---|
[907] | 1794 | GetPString(IDS_VIRUSSCANARCHIVETITLETEXT),
|
---|
| 1795 | pszSrcFile, __LINE__);
|
---|
[551] | 1796 | else if (li->type == IDM_VIEW || li->type == IDM_VIEWTEXT ||
|
---|
| 1797 | li->type == IDM_VIEWBINARY || li->type == IDM_EDIT ||
|
---|
| 1798 | li->type == IDM_EDITTEXT ||
|
---|
| 1799 | li->type == IDM_VIEWARCHIVE ||
|
---|
| 1800 | li->type == IDM_EDITBINARY ||
|
---|
| 1801 | li->type == IDM_MCIPLAY || li->type == IDM_PRINT) {
|
---|
[2] | 1802 |
|
---|
[551] | 1803 | CHAR *temp, *p;
|
---|
[2] | 1804 |
|
---|
[551] | 1805 | for (x = 0; li->list[x]; x++) {
|
---|
| 1806 | if (!li->info->exwdirs) {
|
---|
| 1807 | temp = li->list[x];
|
---|
| 1808 | p = strrchr(li->list[x], '\\');
|
---|
| 1809 | if (p) {
|
---|
| 1810 | p++;
|
---|
| 1811 | li->list[x] = xstrdup(p, pszSrcFile, __LINE__);
|
---|
| 1812 | if (!li->list[x])
|
---|
| 1813 | li->list[x] = temp;
|
---|
| 1814 | else {
|
---|
[1032] | 1815 | xfree(temp, pszSrcFile, __LINE__);
|
---|
[551] | 1816 | }
|
---|
| 1817 | }
|
---|
| 1818 | }
|
---|
[773] | 1819 | BldFullPathName(cl, li->targetpath, li->list[x]);
|
---|
[551] | 1820 | temp = li->list[x];
|
---|
| 1821 | li->list[x] = xstrdup(cl, pszSrcFile, __LINE__);
|
---|
| 1822 | if (!li->list[x])
|
---|
| 1823 | li->list[x] = temp;
|
---|
| 1824 | else
|
---|
[1032] | 1825 | xfree(temp, pszSrcFile, __LINE__);
|
---|
[551] | 1826 | }
|
---|
| 1827 | if (li->type == IDM_VIEW || li->type == IDM_EDIT) {
|
---|
[2] | 1828 |
|
---|
[551] | 1829 | BOOL isit = TestBinary(li->list[0]);
|
---|
[2] | 1830 |
|
---|
[551] | 1831 | if (isit) {
|
---|
| 1832 | if (li->type == IDM_VIEW)
|
---|
| 1833 | li->type = IDM_VIEWBINARY;
|
---|
| 1834 | else
|
---|
| 1835 | li->type = IDM_EDITBINARY;
|
---|
| 1836 | }
|
---|
| 1837 | else {
|
---|
| 1838 | if (li->type == IDM_VIEW)
|
---|
| 1839 | li->type = IDM_VIEWTEXT;
|
---|
| 1840 | else
|
---|
| 1841 | li->type = IDM_EDITTEXT;
|
---|
| 1842 | }
|
---|
| 1843 | }
|
---|
| 1844 | if (li->type == IDM_MCIPLAY) {
|
---|
[2] | 1845 |
|
---|
[762] | 1846 | FILE *fp;
|
---|
[2] | 1847 |
|
---|
[551] | 1848 | fp = xfopen("$FM2PLAY.$$$", "w", pszSrcFile, __LINE__);
|
---|
| 1849 | if (fp) {
|
---|
| 1850 | fprintf(fp, "%s", ";AV/2-built FM2Play listfile\n");
|
---|
| 1851 | for (x = 0; li->list[x]; x++)
|
---|
| 1852 | fprintf(fp, "%s\n", li->list[x]);
|
---|
| 1853 | fprintf(fp, ";end\n");
|
---|
[762] | 1854 | fclose(fp);
|
---|
| 1855 | RunFM2Util("FM2PLAY.EXE", "/@$FM2PLAY.$$$");
|
---|
| 1856 | }
|
---|
[551] | 1857 | }
|
---|
| 1858 | else if (li->type == IDM_PRINT) {
|
---|
| 1859 | strcpy(li->targetpath, printer);
|
---|
| 1860 | if (_beginthread(PrintListThread, NULL, 65536, (PVOID) li) !=
|
---|
| 1861 | -1) {
|
---|
| 1862 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 1863 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 1864 | li = NULL;
|
---|
| 1865 | }
|
---|
| 1866 | }
|
---|
| 1867 | else if (li->type == IDM_VIEWARCHIVE) {
|
---|
[2] | 1868 |
|
---|
[551] | 1869 | ARC_TYPE *info;
|
---|
[2] | 1870 |
|
---|
[551] | 1871 | for (x = 0; li->list[x]; x++) {
|
---|
| 1872 | if (IsFile(li->list[x]) == 1) {
|
---|
| 1873 | info = NULL; // Do not hide dups - fixme to know why?
|
---|
| 1874 | if (WinDlgBox(HWND_DESKTOP, HWND_DESKTOP,
|
---|
| 1875 | SBoxDlgProc, FM3ModHandle, ASEL_FRAME,
|
---|
| 1876 | (PVOID) & info) && info) {
|
---|
| 1877 | StartArcCnr(HWND_DESKTOP,
|
---|
| 1878 | HWND_DESKTOP, li->list[x], 4, info);
|
---|
| 1879 | }
|
---|
| 1880 | }
|
---|
| 1881 | }
|
---|
| 1882 | }
|
---|
| 1883 | else if ((li->type == IDM_VIEWTEXT && *viewer) ||
|
---|
| 1884 | (li->type == IDM_VIEWBINARY && *binview) ||
|
---|
| 1885 | (li->type == IDM_EDITTEXT && *editor) ||
|
---|
| 1886 | (li->type == IDM_EDITBINARY && *bined)) {
|
---|
[814] | 1887 | DosSleep(32); //05 Aug 07 GKY 100
|
---|
[551] | 1888 | ExecOnList(hwnd, ((li->type == IDM_VIEWTEXT) ? viewer :
|
---|
| 1889 | (li->type == IDM_VIEWBINARY) ? binview :
|
---|
| 1890 | (li->type == IDM_EDITTEXT) ? editor :
|
---|
| 1891 | bined),
|
---|
| 1892 | WINDOWED | SEPARATE, li->targetpath, li->list,
|
---|
[888] | 1893 | NULL, pszSrcFile, __LINE__);
|
---|
[551] | 1894 | }
|
---|
| 1895 | else {
|
---|
| 1896 | if (li->hwnd) {
|
---|
[2] | 1897 |
|
---|
[551] | 1898 | ULONG viewtype;
|
---|
[2] | 1899 |
|
---|
[551] | 1900 | for (x = 0; li->list[x]; x++) {
|
---|
| 1901 | if (x == 0) {
|
---|
| 1902 | if (li->type == IDM_VIEWBINARY ||
|
---|
| 1903 | li->type == IDM_EDITBINARY)
|
---|
| 1904 | viewtype = 16;
|
---|
| 1905 | else
|
---|
| 1906 | viewtype = 8;
|
---|
| 1907 | }
|
---|
| 1908 | else
|
---|
| 1909 | viewtype = 0;
|
---|
| 1910 | temp = xstrdup(li->list[x], pszSrcFile, __LINE__);
|
---|
| 1911 | if (temp) {
|
---|
| 1912 | if (!PostMsg(WinQueryWindow(li->hwnd, QW_PARENT),
|
---|
| 1913 | UM_LOADFILE,
|
---|
| 1914 | MPFROMLONG(4L +
|
---|
| 1915 | (li->type == IDM_VIEWTEXT ||
|
---|
| 1916 | li->type == IDM_VIEWBINARY) +
|
---|
| 1917 | viewtype), MPFROMP(temp)))
|
---|
| 1918 | free(temp);
|
---|
| 1919 | }
|
---|
| 1920 | }
|
---|
| 1921 | }
|
---|
| 1922 | }
|
---|
| 1923 | }
|
---|
| 1924 | }
|
---|
| 1925 | break;
|
---|
[2] | 1926 |
|
---|
[551] | 1927 | case IDM_FIND:
|
---|
| 1928 | {
|
---|
[907] | 1929 | UINT numfiles = 0, numalloced = 0;
|
---|
[551] | 1930 | CHAR **list2 = NULL, fullname[CCHMAXPATH * 2], *p;
|
---|
[2] | 1931 |
|
---|
[551] | 1932 | for (x = 0; li->list[x]; x++) {
|
---|
| 1933 | p = li->list[x];
|
---|
| 1934 | while (*p) {
|
---|
| 1935 | if (*p == '/')
|
---|
| 1936 | *p = '\\';
|
---|
| 1937 | p++;
|
---|
| 1938 | }
|
---|
[773] | 1939 | BldFullPathName(fullname, dcd->directory, li->list[x]);
|
---|
| 1940 | // sprintf(fullname, "%s%s%s", dcd->directory,
|
---|
| 1941 | // (dcd->directory[strlen(dcd->directory) - 1] == '\\') ?
|
---|
| 1942 | // NullStr : "\\", li->list[x]);
|
---|
[551] | 1943 | if (IsFile(fullname) != -1)
|
---|
| 1944 | if (AddToList(fullname, &list2, &numfiles, &numalloced))
|
---|
| 1945 | break;
|
---|
| 1946 | if (strchr(li->list[x], '\\')) {
|
---|
| 1947 | p = strrchr(li->list[x], '\\');
|
---|
| 1948 | if (p) {
|
---|
| 1949 | p++;
|
---|
| 1950 | if (*p) {
|
---|
[773] | 1951 | BldFullPathName(fullname, dcd->directory, p);
|
---|
| 1952 | // sprintf(fullname, "%s%s%s", dcd->directory,
|
---|
| 1953 | // (dcd->directory[strlen(dcd->directory) - 1] ==
|
---|
| 1954 | // '\\') ? NullStr : "\\",
|
---|
| 1955 | // p);
|
---|
[551] | 1956 | if (IsFile(fullname) != -1)
|
---|
| 1957 | if (AddToList(fullname, &list2, &numfiles, &numalloced))
|
---|
| 1958 | break;
|
---|
| 1959 | }
|
---|
| 1960 | }
|
---|
| 1961 | }
|
---|
| 1962 | }
|
---|
| 1963 | if (!numfiles || !list2)
|
---|
| 1964 | Runtime_Error(pszSrcFile, __LINE__, "no files or list");
|
---|
| 1965 | else {
|
---|
| 1966 | WinSendMsg(dcd->hwndCnr, WM_COMMAND,
|
---|
| 1967 | MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
|
---|
[814] | 1968 | DosSleep(10); //05 Aug 07 GKY 128
|
---|
[551] | 1969 | if (Collector) {
|
---|
| 1970 | if (!PostMsg(Collector, WM_COMMAND,
|
---|
| 1971 | MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list2)))
|
---|
| 1972 | FreeList(list2);
|
---|
| 1973 | }
|
---|
| 1974 | else
|
---|
| 1975 | FreeList(list2);
|
---|
| 1976 | }
|
---|
| 1977 | }
|
---|
| 1978 | break;
|
---|
| 1979 | }
|
---|
[2] | 1980 | }
|
---|
[551] | 1981 | FreeListInfo(li);
|
---|
| 1982 | }
|
---|
| 1983 | return 0;
|
---|
[2] | 1984 |
|
---|
[551] | 1985 | case WM_CLOSE:
|
---|
| 1986 | WinDestroyWindow(hwnd);
|
---|
| 1987 | break;
|
---|
[2] | 1988 |
|
---|
[551] | 1989 | case WM_DESTROY:
|
---|
| 1990 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 1991 | if (dcd) {
|
---|
| 1992 | if (*dcd->workdir) {
|
---|
[771] | 1993 | DosSleep(16); //05 Aug 07 GKY 33
|
---|
[551] | 1994 | wipeallf("%s\\*", dcd->workdir);
|
---|
| 1995 | if (rmdir(dcd->workdir)) {
|
---|
[771] | 1996 | DosSleep(100); //05 Aug 07 GKY 256
|
---|
[551] | 1997 | wipeallf("%s\\*", dcd->workdir);
|
---|
| 1998 | rmdir(dcd->workdir);
|
---|
| 1999 | }
|
---|
[2] | 2000 | }
|
---|
[551] | 2001 | FreeList(dcd->lastselection);
|
---|
| 2002 | WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
|
---|
[1009] | 2003 | xfree(dcd, pszSrcFile, __LINE__);
|
---|
[1017] | 2004 | # ifdef FORTIFY
|
---|
| 2005 | Fortify_LeaveScope();
|
---|
| 2006 | # endif
|
---|
[551] | 2007 | WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
|
---|
| 2008 | }
|
---|
| 2009 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 2010 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
| 2011 | break;
|
---|
| 2012 | } // switch
|
---|
| 2013 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 2014 | }
|
---|
| 2015 |
|
---|
[551] | 2016 | static MRESULT EXPENTRY ArcCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 2017 | MPARAM mp2)
|
---|
[172] | 2018 | {
|
---|
[672] | 2019 | DIRCNRDATA *dcd = INSTDATA(hwnd);
|
---|
[773] | 2020 | CHAR szQuotedArcName[CCHMAXPATH];
|
---|
[2] | 2021 |
|
---|
[551] | 2022 | switch (msg) {
|
---|
| 2023 | case DM_PRINTOBJECT:
|
---|
| 2024 | case DM_DISCARDOBJECT:
|
---|
| 2025 | if (dcd)
|
---|
| 2026 | return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
|
---|
| 2027 | else
|
---|
| 2028 | return MRFROMLONG(DRR_TARGET);
|
---|
[2] | 2029 |
|
---|
[551] | 2030 | case WM_CHAR:
|
---|
| 2031 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
| 2032 | if (SHORT1FROMMP(mp1) & KC_KEYUP)
|
---|
| 2033 | return (MRESULT) TRUE;
|
---|
| 2034 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
|
---|
| 2035 | switch (SHORT2FROMMP(mp2)) {
|
---|
| 2036 | case VK_DELETE:
|
---|
| 2037 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
|
---|
| 2038 | break;
|
---|
[2] | 2039 | }
|
---|
[551] | 2040 | }
|
---|
| 2041 | if (shiftstate || fNoSearch)
|
---|
| 2042 | break;
|
---|
| 2043 | if (SHORT1FROMMP(mp1) & KC_CHAR) {
|
---|
[2] | 2044 |
|
---|
[551] | 2045 | ULONG thistime, len;
|
---|
| 2046 | SEARCHSTRING srch;
|
---|
| 2047 | PCNRITEM pci;
|
---|
[2] | 2048 |
|
---|
[551] | 2049 | if (!dcd)
|
---|
| 2050 | break;
|
---|
| 2051 | switch (SHORT1FROMMP(mp2)) {
|
---|
| 2052 | case '\x1b':
|
---|
| 2053 | case '\r':
|
---|
| 2054 | case '\n':
|
---|
| 2055 | dcd->lasttime = 0;
|
---|
| 2056 | *dcd->szCommonName = 0;
|
---|
| 2057 | break;
|
---|
| 2058 | default:
|
---|
| 2059 | thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
|
---|
| 2060 | if (thistime > dcd->lasttime + 1250)
|
---|
| 2061 | *dcd->szCommonName = 0;
|
---|
| 2062 | dcd->lasttime = thistime;
|
---|
| 2063 | if (SHORT1FROMMP(mp2) == ' ' && !*dcd->szCommonName)
|
---|
| 2064 | break;
|
---|
| 2065 | KbdRetry:
|
---|
| 2066 | len = strlen(dcd->szCommonName);
|
---|
| 2067 | if (len >= CCHMAXPATH - 1) {
|
---|
| 2068 | *dcd->szCommonName = 0;
|
---|
| 2069 | len = 0;
|
---|
| 2070 | }
|
---|
| 2071 | dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
|
---|
| 2072 | dcd->szCommonName[len + 1] = 0;
|
---|
| 2073 | memset(&srch, 0, sizeof(SEARCHSTRING));
|
---|
| 2074 | srch.cb = (ULONG) sizeof(SEARCHSTRING);
|
---|
| 2075 | srch.pszSearch = dcd->szCommonName;
|
---|
| 2076 | srch.fsPrefix = TRUE;
|
---|
| 2077 | srch.fsCaseSensitive = FALSE;
|
---|
| 2078 | srch.usView = CV_ICON;
|
---|
| 2079 | pci = WinSendMsg(hwnd,
|
---|
| 2080 | CM_SEARCHSTRING,
|
---|
| 2081 | MPFROMP(&srch), MPFROMLONG(CMA_FIRST));
|
---|
| 2082 | if (pci && (INT) pci != -1) {
|
---|
[2] | 2083 |
|
---|
[551] | 2084 | USHORT attrib = CRA_CURSORED;
|
---|
[2] | 2085 |
|
---|
[551] | 2086 | /* make found item current item */
|
---|
| 2087 | if (!stricmp(pci->pszFileName, dcd->szCommonName))
|
---|
| 2088 | attrib |= CRA_SELECTED;
|
---|
| 2089 | WinSendMsg(hwnd,
|
---|
| 2090 | CM_SETRECORDEMPHASIS,
|
---|
| 2091 | MPFROMP(pci), MPFROM2SHORT(TRUE, attrib));
|
---|
| 2092 | /* make sure that record shows in viewport */
|
---|
| 2093 | ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
|
---|
| 2094 | return (MRESULT) TRUE;
|
---|
| 2095 | }
|
---|
| 2096 | else {
|
---|
| 2097 | if (SHORT1FROMMP(mp2) == ' ') {
|
---|
| 2098 | dcd->szCommonName[len] = 0;
|
---|
| 2099 | break;
|
---|
| 2100 | }
|
---|
| 2101 | *dcd->szCommonName = 0;
|
---|
| 2102 | dcd->lasttime = 0;
|
---|
| 2103 | if (len) // retry as first letter if no match
|
---|
| 2104 | goto KbdRetry;
|
---|
| 2105 | }
|
---|
| 2106 | break;
|
---|
[2] | 2107 | }
|
---|
[551] | 2108 | }
|
---|
| 2109 | break;
|
---|
[2] | 2110 |
|
---|
[551] | 2111 | case WM_MOUSEMOVE:
|
---|
| 2112 | case WM_BUTTON1UP:
|
---|
| 2113 | case WM_BUTTON2UP:
|
---|
| 2114 | case WM_BUTTON3UP:
|
---|
| 2115 | case WM_CHORD:
|
---|
| 2116 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
| 2117 | break;
|
---|
[2] | 2118 |
|
---|
[551] | 2119 | case WM_BUTTON1MOTIONEND:
|
---|
| 2120 | {
|
---|
| 2121 | CNRINFO cnri;
|
---|
[2] | 2122 |
|
---|
[551] | 2123 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
| 2124 | cnri.cb = sizeof(CNRINFO);
|
---|
| 2125 | if (WinSendMsg(hwnd,
|
---|
| 2126 | CM_QUERYCNRINFO,
|
---|
| 2127 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
|
---|
| 2128 | if (cnri.flWindowAttr & CV_DETAIL)
|
---|
| 2129 | PrfWriteProfileData(fmprof,
|
---|
| 2130 | appname,
|
---|
| 2131 | "ArcCnrSplitBar",
|
---|
| 2132 | (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
|
---|
[2] | 2133 | }
|
---|
[551] | 2134 | }
|
---|
| 2135 | break;
|
---|
[2] | 2136 |
|
---|
[551] | 2137 | case WM_PRESPARAMCHANGED:
|
---|
| 2138 | PresParamChanged(hwnd, "ArcCnr", mp1, mp2);
|
---|
| 2139 | break;
|
---|
[2] | 2140 |
|
---|
[551] | 2141 | case UM_UPDATERECORD:
|
---|
| 2142 | case UM_UPDATERECORDLIST:
|
---|
| 2143 | if (dcd && !IsArcThere(hwnd, dcd->arcname))
|
---|
| 2144 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2145 | return 0;
|
---|
[2] | 2146 |
|
---|
[551] | 2147 | case WM_SETFOCUS:
|
---|
| 2148 | /*
|
---|
| 2149 | * put name of our window (archive name) on status line
|
---|
| 2150 | */
|
---|
| 2151 | if (dcd && hwndStatus && mp2)
|
---|
| 2152 | WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2153 | break;
|
---|
[2] | 2154 |
|
---|
[551] | 2155 | case UM_SETUP2:
|
---|
| 2156 | if (dcd && dcd->info) {
|
---|
| 2157 | if (dcd->info->fdpos == -1 || !dcd->info->datetype)
|
---|
| 2158 | dcd->sortFlags &= (~SORT_LWDATE);
|
---|
| 2159 | if (dcd->info->nsizepos == -1)
|
---|
| 2160 | dcd->sortFlags &= (~SORT_EASIZE);
|
---|
| 2161 | if (dcd->info->osizepos == -1)
|
---|
| 2162 | dcd->sortFlags &= (~SORT_SIZE);
|
---|
| 2163 | AdjustCnrColVis(hwnd,
|
---|
| 2164 | GetPString(IDS_OLDSIZECOLTEXT),
|
---|
| 2165 | dcd->info->osizepos != -1, FALSE);
|
---|
| 2166 | AdjustCnrColVis(hwnd,
|
---|
| 2167 | GetPString(IDS_NEWSIZECOLTEXT),
|
---|
| 2168 | dcd->info->nsizepos != -1, FALSE);
|
---|
| 2169 | // Display unsullied date/time string if type 0
|
---|
| 2170 | AdjustCnrColVis(hwnd,
|
---|
| 2171 | GetPString(IDS_DATETIMECOLTEXT),
|
---|
| 2172 | dcd->info->fdpos != -1 && !dcd->info->datetype, FALSE);
|
---|
| 2173 | // Display parsed date/time columns if type specified
|
---|
| 2174 | AdjustCnrColVis(hwnd,
|
---|
| 2175 | GetPString(IDS_TIMECOLTEXT),
|
---|
| 2176 | dcd->info->fdpos != -1 && dcd->info->datetype, FALSE);
|
---|
| 2177 | AdjustCnrColVis(hwnd,
|
---|
| 2178 | GetPString(IDS_DATECOLTEXT),
|
---|
| 2179 | dcd->info->fdpos != -1 && dcd->info->datetype, FALSE);
|
---|
| 2180 | WinSendMsg(hwnd, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
|
---|
| 2181 | }
|
---|
| 2182 | return 0;
|
---|
[2] | 2183 |
|
---|
[551] | 2184 | case UM_RESCAN:
|
---|
| 2185 | if (dcd) {
|
---|
| 2186 | CNRINFO cnri;
|
---|
| 2187 | CHAR s[CCHMAXPATH * 2], tb[81], tf[81];
|
---|
| 2188 | PARCITEM pci;
|
---|
[2] | 2189 |
|
---|
[551] | 2190 | if (mp1) {
|
---|
| 2191 | PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2192 | return 0;
|
---|
| 2193 | }
|
---|
| 2194 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
| 2195 | cnri.cb = sizeof(CNRINFO);
|
---|
| 2196 | WinSendMsg(hwnd,
|
---|
| 2197 | CM_QUERYCNRINFO,
|
---|
| 2198 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
| 2199 | dcd->totalfiles = cnri.cRecords;
|
---|
| 2200 | commafmt(tf, sizeof(tf), dcd->selectedfiles);
|
---|
| 2201 | if (dcd->ullTotalBytes)
|
---|
| 2202 | CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
|
---|
| 2203 | else
|
---|
| 2204 | *tb = 0;
|
---|
| 2205 | sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
|
---|
| 2206 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
|
---|
| 2207 | commafmt(tf, sizeof(tf), dcd->totalfiles);
|
---|
| 2208 | if (dcd->ullTotalBytes)
|
---|
| 2209 | CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, 'K');
|
---|
| 2210 | else
|
---|
| 2211 | *tb = 0;
|
---|
| 2212 | sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
|
---|
| 2213 | WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
|
---|
| 2214 | if (hwndStatus &&
|
---|
| 2215 | dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
|
---|
| 2216 | sprintf(s, " [%s%s%s]%s%s%s %s",
|
---|
| 2217 | tf,
|
---|
[156] | 2218 | *tb ? " / " : NullStr,
|
---|
[551] | 2219 | tb,
|
---|
[562] | 2220 | *dcd->mask.szMask ? " (" : NullStr,
|
---|
| 2221 | *dcd->mask.szMask ? dcd->mask.szMask : NullStr,
|
---|
| 2222 | *dcd->mask.szMask ? ")" : NullStr, dcd->arcname);
|
---|
[551] | 2223 | WinSetWindowText(hwndStatus, s);
|
---|
| 2224 | if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
| 2225 | pci = WinSendMsg(hwnd,
|
---|
| 2226 | CM_QUERYRECORDEMPHASIS,
|
---|
| 2227 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
---|
| 2228 | if (pci && (INT) pci != -1) {
|
---|
| 2229 | if (fSplitStatus && hwndStatus2) {
|
---|
| 2230 | if (dcd->ullTotalBytes)
|
---|
| 2231 | CommaFmtULL(tb, sizeof(tb), pci->cbFile, ' ');
|
---|
| 2232 | else
|
---|
| 2233 | *tb = 0;
|
---|
| 2234 | sprintf(s, "%s%s%s%s",
|
---|
| 2235 | *tb ? " " : NullStr,
|
---|
[730] | 2236 | tb, *tb ? " " : NullStr, pci->pszFileName);
|
---|
[551] | 2237 | WinSetWindowText(hwndStatus2, s);
|
---|
| 2238 | }
|
---|
| 2239 | if (fMoreButtons)
|
---|
[730] | 2240 | WinSetWindowText(hwndName, pci->pszFileName);
|
---|
[551] | 2241 | }
|
---|
| 2242 | else {
|
---|
| 2243 | WinSetWindowText(hwndStatus2, NullStr);
|
---|
| 2244 | WinSetWindowText(hwndName, NullStr);
|
---|
| 2245 | }
|
---|
| 2246 | WinSetWindowText(hwndDate, NullStr);
|
---|
| 2247 | WinSetWindowText(hwndAttr, NullStr);
|
---|
| 2248 | }
|
---|
[2] | 2249 | }
|
---|
[563] | 2250 | if ((dcd->arcfilled && !dcd->totalfiles) ||
|
---|
[762] | 2251 | !IsArcThere(hwnd, dcd->arcname))
|
---|
[551] | 2252 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2253 | }
|
---|
| 2254 | return 0;
|
---|
| 2255 |
|
---|
| 2256 | case UM_SETUP:
|
---|
| 2257 | if (!dcd) {
|
---|
| 2258 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2259 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
[2] | 2260 | return 0;
|
---|
[551] | 2261 | }
|
---|
| 2262 | else {
|
---|
| 2263 | if (!dcd->hwndObject) {
|
---|
| 2264 | /*
|
---|
| 2265 | * first time through -- set things up
|
---|
| 2266 | */
|
---|
| 2267 | {
|
---|
| 2268 | CHAR *p, *pp;
|
---|
| 2269 | ULONG z, was;
|
---|
| 2270 | APIRET rc;
|
---|
[2] | 2271 |
|
---|
[551] | 2272 | rc = DosCreateDir(dcd->workdir, 0);
|
---|
| 2273 | if (rc) {
|
---|
| 2274 | if (rc == ERROR_ACCESS_DENIED) {
|
---|
| 2275 | p = strrchr(dcd->workdir, '.');
|
---|
| 2276 | if (p) {
|
---|
| 2277 | p++;
|
---|
| 2278 | pp = p;
|
---|
| 2279 | was = strtoul(p, &pp, 16);
|
---|
| 2280 | for (z = 0; z < 99; z++) {
|
---|
| 2281 | was++;
|
---|
| 2282 | sprintf(p, "%03x");
|
---|
| 2283 | rc = DosCreateDir(dcd->workdir, 0);
|
---|
| 2284 | if (!rc || rc != ERROR_ACCESS_DENIED)
|
---|
| 2285 | break;
|
---|
| 2286 | }
|
---|
| 2287 | }
|
---|
| 2288 | }
|
---|
| 2289 | if (rc)
|
---|
| 2290 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2291 | return 0;
|
---|
| 2292 | }
|
---|
| 2293 | }
|
---|
| 2294 | RestorePresParams(hwnd, "ArcCnr");
|
---|
| 2295 | dcd->mask.fNoAttribs = TRUE;
|
---|
| 2296 | dcd->mask.fNoDirs = TRUE;
|
---|
| 2297 | *dcd->mask.prompt = 0;
|
---|
| 2298 | {
|
---|
| 2299 | PFIELDINFO pfi, pfiLastLeftCol;
|
---|
| 2300 | ULONG numcols = CON_COLS;
|
---|
| 2301 | CNRINFO cnri;
|
---|
| 2302 | ULONG size;
|
---|
[2] | 2303 |
|
---|
[551] | 2304 | pfi = WinSendMsg(hwnd,
|
---|
| 2305 | CM_ALLOCDETAILFIELDINFO,
|
---|
| 2306 | MPFROMLONG(numcols), NULL);
|
---|
| 2307 | if (pfi) {
|
---|
[2] | 2308 |
|
---|
[551] | 2309 | PFIELDINFO pfiFirst;
|
---|
| 2310 | FIELDINFOINSERT fii;
|
---|
[2] | 2311 |
|
---|
[551] | 2312 | pfiFirst = pfi;
|
---|
| 2313 | pfi->flData = CFA_STRING | CFA_LEFT | CFA_FIREADONLY;
|
---|
| 2314 | pfi->flTitle = CFA_CENTER;
|
---|
| 2315 | pfi->pTitleData = GetPString(IDS_FILENAMECOLTEXT);
|
---|
[739] | 2316 | pfi->offStruct = FIELDOFFSET(ARCITEM, pszDisplayName);
|
---|
[551] | 2317 | pfiLastLeftCol = pfi;
|
---|
| 2318 | pfi = pfi->pNextFieldInfo;
|
---|
| 2319 | pfi->flData =
|
---|
| 2320 | CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 2321 | pfi->flTitle = CFA_CENTER;
|
---|
| 2322 | pfi->pTitleData = GetPString(IDS_OLDSIZECOLTEXT);
|
---|
| 2323 | pfi->offStruct = FIELDOFFSET(ARCITEM, cbFile);
|
---|
| 2324 | pfi = pfi->pNextFieldInfo;
|
---|
| 2325 | pfi->flData =
|
---|
| 2326 | CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 2327 | pfi->flTitle = CFA_CENTER;
|
---|
| 2328 | pfi->pTitleData = GetPString(IDS_NEWSIZECOLTEXT);
|
---|
| 2329 | pfi->offStruct = FIELDOFFSET(ARCITEM, cbComp);
|
---|
| 2330 | pfi = pfi->pNextFieldInfo;
|
---|
| 2331 | pfi->flData =
|
---|
| 2332 | CFA_STRING | CFA_CENTER | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 2333 | pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
|
---|
| 2334 | pfi->pTitleData = GetPString(IDS_DATETIMECOLTEXT);
|
---|
| 2335 | pfi->offStruct = FIELDOFFSET(ARCITEM, pszDate);
|
---|
| 2336 | pfi = pfi->pNextFieldInfo;
|
---|
| 2337 | pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
|
---|
| 2338 | pfi->flTitle = CFA_CENTER;
|
---|
| 2339 | pfi->pTitleData = GetPString(IDS_DATECOLTEXT);
|
---|
| 2340 | pfi->offStruct = FIELDOFFSET(ARCITEM, date);
|
---|
| 2341 | pfi = pfi->pNextFieldInfo;
|
---|
| 2342 | pfi->flData = CFA_TIME | CFA_RIGHT | CFA_FIREADONLY;
|
---|
| 2343 | pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
|
---|
| 2344 | pfi->pTitleData = GetPString(IDS_TIMECOLTEXT);
|
---|
| 2345 | pfi->offStruct = FIELDOFFSET(ARCITEM, time);
|
---|
| 2346 | memset(&fii, 0, sizeof(FIELDINFOINSERT));
|
---|
| 2347 | fii.cb = sizeof(FIELDINFOINSERT);
|
---|
| 2348 | fii.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
|
---|
| 2349 | fii.cFieldInfoInsert = (SHORT) numcols;
|
---|
| 2350 | fii.fInvalidateFieldInfo = TRUE;
|
---|
| 2351 | WinSendMsg(hwnd,
|
---|
| 2352 | CM_INSERTDETAILFIELDINFO,
|
---|
| 2353 | MPFROMP(pfiFirst), MPFROMP(&fii));
|
---|
| 2354 | PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
[2] | 2355 |
|
---|
[551] | 2356 | memset(&cnri, 0, sizeof(cnri));
|
---|
| 2357 | cnri.cb = sizeof(CNRINFO);
|
---|
| 2358 | cnri.pFieldInfoLast = pfiLastLeftCol;
|
---|
| 2359 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET + 32;
|
---|
[2] | 2360 |
|
---|
[551] | 2361 | size = sizeof(LONG);
|
---|
| 2362 | PrfQueryProfileData(fmprof, appname, "ArcCnrSplitBar",
|
---|
| 2363 | &cnri.xVertSplitbar, &size);
|
---|
| 2364 | if (cnri.xVertSplitbar <= 0)
|
---|
| 2365 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET + 32;
|
---|
[2] | 2366 |
|
---|
[551] | 2367 | cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_NAME));
|
---|
| 2368 | cnri.flWindowAttr |= (CV_DETAIL | CA_DETAILSVIEWTITLES | CV_FLOW);
|
---|
| 2369 | cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH |
|
---|
| 2370 | CA_MIXEDTARGETEMPH));
|
---|
| 2371 | cnri.pSortRecord = (PVOID) ArcSort;
|
---|
| 2372 | WinSendMsg(hwnd,
|
---|
| 2373 | CM_SETCNRINFO,
|
---|
| 2374 | MPFROMP(&cnri),
|
---|
| 2375 | MPFROMLONG(CMA_PFIELDINFOLAST |
|
---|
| 2376 | CMA_XVERTSPLITBAR |
|
---|
| 2377 | CMA_PSORTRECORD | CMA_FLWINDOWATTR));
|
---|
| 2378 | }
|
---|
| 2379 | }
|
---|
| 2380 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
|
---|
| 2381 | if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) {
|
---|
| 2382 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 2383 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
| 2384 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2385 | return 0;
|
---|
| 2386 | }
|
---|
| 2387 | else
|
---|
[766] | 2388 | DosSleep(1);
|
---|
[551] | 2389 | SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2390 | DIR_FILTER), &dcd->mask, TRUE);
|
---|
| 2391 | SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2392 | DIR_SORT), dcd->sortFlags, TRUE);
|
---|
| 2393 | DefArcSortFlags = dcd->sortFlags; // Remember for new windows
|
---|
[2] | 2394 | }
|
---|
[551] | 2395 | }
|
---|
| 2396 | return 0;
|
---|
[2] | 2397 |
|
---|
[551] | 2398 | case UM_SETDIR:
|
---|
| 2399 | if (dcd) {
|
---|
[2] | 2400 |
|
---|
[551] | 2401 | CHAR s[CCHMAXPATH], *p;
|
---|
| 2402 | ULONG ret = 0;
|
---|
[2] | 2403 |
|
---|
[551] | 2404 | WinQueryDlgItemText(dcd->hwndClient, ARC_EXTRACTDIR, CCHMAXPATH, s);
|
---|
| 2405 | bstrip(s);
|
---|
| 2406 | MakeFullName(s);
|
---|
| 2407 | if (*s) {
|
---|
| 2408 | while ((p = strchr(s, '/')) != NULL)
|
---|
| 2409 | *p = '\\';
|
---|
| 2410 | while (strlen(s) > 3 && s[strlen(s) - 1] == '\\')
|
---|
| 2411 | s[strlen(s) - 1] = 0;
|
---|
| 2412 | if (stricmp(s, dcd->directory)) {
|
---|
| 2413 | if (IsFullName(s)) {
|
---|
| 2414 | if (driveflags[toupper(*s) - 'A'] &
|
---|
| 2415 | (DRIVE_NOTWRITEABLE | DRIVE_IGNORE | DRIVE_INVALID)) {
|
---|
| 2416 | Runtime_Error(pszSrcFile, __LINE__, "drive %s bad", s);
|
---|
| 2417 | WinSetDlgItemText(dcd->hwndClient,
|
---|
| 2418 | ARC_EXTRACTDIR, dcd->directory);
|
---|
| 2419 | return 0;
|
---|
| 2420 | }
|
---|
| 2421 | }
|
---|
| 2422 | if (!SetDir(dcd->hwndParent, hwnd, s, 0)) {
|
---|
| 2423 | if (stricmp(dcd->directory, s)) {
|
---|
| 2424 | DosEnterCritSec();
|
---|
| 2425 | strcpy(lastextractpath, s);
|
---|
| 2426 | DosExitCritSec();
|
---|
| 2427 | }
|
---|
| 2428 | strcpy(dcd->directory, s);
|
---|
| 2429 | if ((!isalpha(*s) || s[1] != ':') && *s != '.')
|
---|
| 2430 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
---|
| 2431 | hwnd,
|
---|
| 2432 | GetPString(IDS_WARNINGTEXT),
|
---|
| 2433 | GetPString(IDS_SPECIFYDRIVETEXT));
|
---|
| 2434 | }
|
---|
| 2435 | else
|
---|
| 2436 | ret = 1;
|
---|
| 2437 | }
|
---|
[2] | 2438 | }
|
---|
[551] | 2439 | WinSetDlgItemText(dcd->hwndClient, ARC_EXTRACTDIR, dcd->directory);
|
---|
| 2440 | return (MRESULT) ret;
|
---|
| 2441 | }
|
---|
| 2442 | return 0;
|
---|
| 2443 |
|
---|
| 2444 | case UM_ENTER:
|
---|
| 2445 | if (WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID))
|
---|
[2] | 2446 | return 0;
|
---|
[551] | 2447 | SetShiftState();
|
---|
| 2448 | if (dcd && (CHAR *) mp1) {
|
---|
[2] | 2449 |
|
---|
[551] | 2450 | SWP swp;
|
---|
| 2451 | CHAR *filename = mp1;
|
---|
[2] | 2452 |
|
---|
[551] | 2453 | if (IsFile(filename) != 1)
|
---|
| 2454 | return 0;
|
---|
| 2455 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
| 2456 | DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp, filename);
|
---|
| 2457 | if (fUnHilite)
|
---|
[672] | 2458 | UnHilite(hwnd, FALSE, &dcd->lastselection, 0);
|
---|
[551] | 2459 | }
|
---|
| 2460 | return 0;
|
---|
[2] | 2461 |
|
---|
[551] | 2462 | case WM_MENUEND:
|
---|
| 2463 | if (dcd) {
|
---|
[2] | 2464 |
|
---|
[551] | 2465 | HWND hwndMenu = (HWND) mp2;
|
---|
[2] | 2466 |
|
---|
[551] | 2467 | if (hwndMenu == ArcCnrMenu || hwndMenu == ArcMenu) {
|
---|
| 2468 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
---|
| 2469 | if (dcd->cnremphasized) {
|
---|
| 2470 | WinSendMsg(hwnd,
|
---|
| 2471 | CM_SETRECORDEMPHASIS,
|
---|
| 2472 | MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
|
---|
| 2473 | dcd->cnremphasized = FALSE;
|
---|
| 2474 | }
|
---|
[2] | 2475 | }
|
---|
[551] | 2476 | }
|
---|
| 2477 | break;
|
---|
[2] | 2478 |
|
---|
[551] | 2479 | case MM_PORTHOLEINIT:
|
---|
| 2480 | if (dcd) {
|
---|
| 2481 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2482 | case 0:
|
---|
| 2483 | case 1:
|
---|
| 2484 | {
|
---|
| 2485 | ULONG wmsg;
|
---|
[2] | 2486 |
|
---|
[562] | 2487 | wmsg = SHORT1FROMMP(mp1) == 0 ? UM_FILESMENU : UM_VIEWSMENU;
|
---|
[551] | 2488 | PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
|
---|
| 2489 | wmsg, MPVOID, MPVOID), mp1, mp2);
|
---|
| 2490 | }
|
---|
| 2491 | break;
|
---|
[2] | 2492 | }
|
---|
[551] | 2493 | }
|
---|
| 2494 | break;
|
---|
[2] | 2495 |
|
---|
[551] | 2496 | case UM_INITMENU:
|
---|
| 2497 | case WM_INITMENU:
|
---|
| 2498 | if (dcd) {
|
---|
| 2499 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2500 | case IDM_FILESMENU:
|
---|
| 2501 | if (dcd->info) {
|
---|
| 2502 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2503 | IDM_DELETE, dcd->info->delete != NULL);
|
---|
| 2504 | WinEnableMenuItem((HWND) mp2, IDM_TEST, dcd->info->test != NULL);
|
---|
| 2505 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2506 | IDM_EXTRACT, dcd->info->extract != NULL);
|
---|
| 2507 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2508 | IDM_EXTRACTWDIRS, dcd->info->exwdirs != NULL);
|
---|
| 2509 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2510 | IDM_ARCEXTRACTWDIRS, dcd->info->exwdirs != NULL);
|
---|
| 2511 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2512 | IDM_ARCEXTRACTWDIRSEXIT,
|
---|
| 2513 | dcd->info->exwdirs != NULL);
|
---|
| 2514 | }
|
---|
| 2515 | break;
|
---|
[2] | 2516 |
|
---|
[551] | 2517 | case IDM_VIEWSMENU:
|
---|
| 2518 | WinCheckMenuItem((HWND) mp2,
|
---|
[562] | 2519 | IDM_MINIICONS, (dcd->flWindowAttr & CV_MINI) != 0);
|
---|
[551] | 2520 | WinEnableMenuItem((HWND) mp2,
|
---|
| 2521 | IDM_RESELECT, (dcd->lastselection != NULL));
|
---|
| 2522 | break;
|
---|
[2] | 2523 |
|
---|
[551] | 2524 | case IDM_COMMANDSMENU:
|
---|
| 2525 | SetupCommandMenu((HWND) mp2, hwnd);
|
---|
| 2526 | break;
|
---|
[2] | 2527 |
|
---|
[551] | 2528 | case IDM_SORTSUBMENU:
|
---|
| 2529 | SetSortChecks((HWND) mp2, dcd->sortFlags);
|
---|
| 2530 | break;
|
---|
[2] | 2531 |
|
---|
[551] | 2532 | case IDM_WINDOWSMENU:
|
---|
| 2533 | /*
|
---|
| 2534 | * add switchlist entries to end of pulldown menu
|
---|
| 2535 | */
|
---|
[562] | 2536 | SetupWinList((HWND)mp2,
|
---|
| 2537 | hwndMain ? hwndMain : (HWND)0, dcd->hwndFrame);
|
---|
[551] | 2538 | break;
|
---|
[2] | 2539 | }
|
---|
[551] | 2540 | dcd->hwndLastMenu = (HWND) mp2;
|
---|
| 2541 | }
|
---|
| 2542 | if (msg == WM_INITMENU)
|
---|
| 2543 | break;
|
---|
| 2544 | return 0;
|
---|
[2] | 2545 |
|
---|
[551] | 2546 | case UM_LOADFILE:
|
---|
| 2547 | if (dcd && mp2) {
|
---|
[2] | 2548 |
|
---|
[551] | 2549 | HWND ret;
|
---|
[2] | 2550 |
|
---|
[551] | 2551 | ret = StartMLEEditor(dcd->hwndParent,
|
---|
| 2552 | (INT) mp1, (CHAR *) mp2, dcd->hwndFrame);
|
---|
[1009] | 2553 | xfree((CHAR *) mp2, pszSrcFile, __LINE__);
|
---|
[551] | 2554 | return MRFROMLONG(ret);
|
---|
| 2555 | }
|
---|
| 2556 | return 0;
|
---|
| 2557 |
|
---|
| 2558 | case UM_COMMAND:
|
---|
| 2559 | if (mp1) {
|
---|
| 2560 | if (dcd) {
|
---|
| 2561 | if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
|
---|
| 2562 | Runtime_Error(pszSrcFile, __LINE__, "post");
|
---|
| 2563 | FreeListInfo((LISTINFO *) mp1);
|
---|
| 2564 | }
|
---|
| 2565 | else
|
---|
| 2566 | return (MRESULT) TRUE;
|
---|
[2] | 2567 | }
|
---|
[551] | 2568 | else
|
---|
| 2569 | FreeListInfo((LISTINFO *) mp1);
|
---|
| 2570 | }
|
---|
| 2571 | return 0;
|
---|
[2] | 2572 |
|
---|
[551] | 2573 | case UM_OPENWINDOWFORME:
|
---|
| 2574 | if (dcd) {
|
---|
| 2575 | if (mp1 && !IsFile((CHAR *) mp1)) {
|
---|
| 2576 | OpenDirCnr((HWND) 0, hwndMain, dcd->hwndFrame, FALSE, (char *)mp1);
|
---|
[2] | 2577 | }
|
---|
[551] | 2578 | else if (mp1 && IsFile(mp1) == 1) {
|
---|
| 2579 | StartArcCnr(HWND_DESKTOP,
|
---|
| 2580 | dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
|
---|
| 2581 | }
|
---|
| 2582 | }
|
---|
| 2583 | return 0;
|
---|
[2] | 2584 |
|
---|
[551] | 2585 | case WM_COMMAND:
|
---|
| 2586 | DosError(FERR_DISABLEHARDERR);
|
---|
| 2587 | if (dcd) {
|
---|
| 2588 | if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
|
---|
| 2589 | return 0;
|
---|
| 2590 | if (WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID))
|
---|
| 2591 | return 0;
|
---|
| 2592 | if (!IsArcThere(hwnd, dcd->arcname)) {
|
---|
| 2593 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2594 | return 0;
|
---|
[2] | 2595 | }
|
---|
[551] | 2596 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2597 | case IDM_TREEVIEW:
|
---|
[2] | 2598 |
|
---|
[551] | 2599 | break;
|
---|
[2] | 2600 |
|
---|
[551] | 2601 | case IDM_CONTEXTMENU:
|
---|
| 2602 | {
|
---|
| 2603 | PCNRITEM pci;
|
---|
[2] | 2604 |
|
---|
[551] | 2605 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
| 2606 | PostMsg(hwnd,
|
---|
| 2607 | WM_CONTROL,
|
---|
| 2608 | MPFROM2SHORT(ARC_CNR, CN_CONTEXTMENU), MPFROMP(pci));
|
---|
| 2609 | }
|
---|
| 2610 | break;
|
---|
[2] | 2611 |
|
---|
[551] | 2612 | case IDM_NEXTWINDOW:
|
---|
| 2613 | case IDM_PREVWINDOW:
|
---|
| 2614 | {
|
---|
| 2615 | HWND hwndActive;
|
---|
[2] | 2616 |
|
---|
[551] | 2617 | hwndActive = WinQueryFocus(HWND_DESKTOP);
|
---|
| 2618 | WinSetFocus(HWND_DESKTOP,
|
---|
[563] | 2619 | hwndActive == hwnd ?
|
---|
[762] | 2620 | WinWindowFromID(dcd->hwndClient, ARC_EXTRACTDIR) :
|
---|
| 2621 | hwnd);
|
---|
[551] | 2622 | }
|
---|
| 2623 | break;
|
---|
[2] | 2624 |
|
---|
[551] | 2625 | case IDM_FOLDERAFTEREXTRACT:
|
---|
[562] | 2626 | fFolderAfterExtract = fFolderAfterExtract ? FALSE : TRUE;
|
---|
[551] | 2627 | PrfWriteProfileData(fmprof, appname, "FolderAfterExtract",
|
---|
| 2628 | &fFolderAfterExtract, sizeof(BOOL));
|
---|
| 2629 | break;
|
---|
[2] | 2630 |
|
---|
[551] | 2631 | case IDM_SHOWSELECT:
|
---|
[872] | 2632 | QuickPopup(hwnd, dcd, CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP),
|
---|
[551] | 2633 | IDM_SELECTSUBMENU);
|
---|
| 2634 | break;
|
---|
[2] | 2635 |
|
---|
[551] | 2636 | case IDM_SHOWSORT:
|
---|
[872] | 2637 | QuickPopup(hwnd, dcd, CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP),
|
---|
[551] | 2638 | IDM_SORTSUBMENU);
|
---|
| 2639 | break;
|
---|
[2] | 2640 |
|
---|
[953] | 2641 | case IDM_ARCHIVERSETTINGS:
|
---|
[551] | 2642 | if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
|
---|
[917] | 2643 | PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_ARCHIVERSETTINGS), mp2);
|
---|
| 2644 | else {
|
---|
[551] | 2645 | WinDlgBox(HWND_DESKTOP,
|
---|
| 2646 | hwnd,
|
---|
[917] | 2647 | CfgDlgProc,
|
---|
| 2648 | FM3ModHandle,
|
---|
| 2649 | CFG_FRAME,
|
---|
| 2650 | MPFROMLONG(IDM_ARCHIVERSETTINGS));
|
---|
| 2651 | }
|
---|
[551] | 2652 | break;
|
---|
[2] | 2653 |
|
---|
[551] | 2654 | case IDM_RESCAN:
|
---|
| 2655 | dcd->ullTotalBytes = dcd->totalfiles =
|
---|
| 2656 | dcd->selectedfiles = dcd->selectedbytes = 0;
|
---|
| 2657 | WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0");
|
---|
| 2658 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
|
---|
| 2659 | dcd->totalfiles = FillArcCnr(dcd->hwndCnr,
|
---|
| 2660 | dcd->arcname,
|
---|
| 2661 | &dcd->info,
|
---|
| 2662 | &dcd->ullTotalBytes, &dcd->stopflag);
|
---|
| 2663 | PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2664 | PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
|
---|
| 2665 | WinSendMsg(dcd->hwndCnr,
|
---|
| 2666 | CM_INVALIDATERECORD,
|
---|
| 2667 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
| 2668 | break;
|
---|
[2] | 2669 |
|
---|
[551] | 2670 | case IDM_RESELECT:
|
---|
| 2671 | SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
|
---|
| 2672 | break;
|
---|
[2] | 2673 |
|
---|
[551] | 2674 | case IDM_HELP:
|
---|
| 2675 | if (hwndHelp)
|
---|
| 2676 | WinSendMsg(hwndHelp,
|
---|
| 2677 | HM_DISPLAY_HELP,
|
---|
| 2678 | MPFROM2SHORT(HELP_ARCLIST, 0),
|
---|
| 2679 | MPFROMSHORT(HM_RESOURCEID));
|
---|
| 2680 | break;
|
---|
[2] | 2681 |
|
---|
[551] | 2682 | case IDM_WINDOWDLG:
|
---|
| 2683 | if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndFrame))
|
---|
| 2684 | PostMsg(dcd->hwndParent,
|
---|
| 2685 | UM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
|
---|
| 2686 | break;
|
---|
[2] | 2687 |
|
---|
[551] | 2688 | case IDM_SELECTALL:
|
---|
| 2689 | case IDM_SELECTALLFILES:
|
---|
| 2690 | case IDM_DESELECTALL:
|
---|
| 2691 | case IDM_DESELECTALLFILES:
|
---|
| 2692 | case IDM_SELECTMASK:
|
---|
| 2693 | case IDM_DESELECTMASK:
|
---|
| 2694 | case IDM_INVERT:
|
---|
| 2695 | {
|
---|
| 2696 | PARCITEM pci;
|
---|
[2] | 2697 |
|
---|
[551] | 2698 | pci = (PARCITEM) WinSendMsg(hwnd,
|
---|
| 2699 | CM_QUERYRECORDEMPHASIS,
|
---|
| 2700 | MPFROMLONG(CMA_FIRST),
|
---|
| 2701 | MPFROMSHORT(CRA_CURSORED));
|
---|
| 2702 | if ((INT) pci == -1)
|
---|
| 2703 | pci = NULL;
|
---|
| 2704 | if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
|
---|
| 2705 | if (pci) {
|
---|
| 2706 | if (!(pci->rc.flRecordAttr & CRA_SELECTED))
|
---|
| 2707 | pci->rc.flRecordAttr |= CRA_FILTERED;
|
---|
| 2708 | WinSendMsg(hwnd,
|
---|
| 2709 | CM_INVALIDATERECORD,
|
---|
| 2710 | MPFROMP(&pci),
|
---|
| 2711 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
|
---|
| 2712 | break;
|
---|
| 2713 | }
|
---|
| 2714 | }
|
---|
| 2715 | PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
|
---|
| 2716 | }
|
---|
| 2717 | break;
|
---|
[2] | 2718 |
|
---|
[551] | 2719 | case IDM_SORTSMARTNAME:
|
---|
| 2720 | case IDM_SORTNAME:
|
---|
| 2721 | case IDM_SORTFILENAME:
|
---|
| 2722 | case IDM_SORTSIZE:
|
---|
| 2723 | case IDM_SORTEASIZE:
|
---|
| 2724 | case IDM_SORTFIRST:
|
---|
| 2725 | case IDM_SORTLAST:
|
---|
| 2726 | case IDM_SORTLWDATE:
|
---|
| 2727 | dcd->sortFlags &= SORT_REVERSE;
|
---|
| 2728 | /* intentional fallthru */
|
---|
| 2729 | case IDM_SORTREVERSE:
|
---|
| 2730 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2731 | case IDM_SORTSMARTNAME:
|
---|
| 2732 | case IDM_SORTFILENAME:
|
---|
| 2733 | dcd->sortFlags |= SORT_FILENAME;
|
---|
| 2734 | break;
|
---|
| 2735 | case IDM_SORTSIZE:
|
---|
| 2736 | dcd->sortFlags |= SORT_SIZE;
|
---|
| 2737 | break;
|
---|
| 2738 | case IDM_SORTEASIZE:
|
---|
| 2739 | dcd->sortFlags |= SORT_EASIZE;
|
---|
| 2740 | break;
|
---|
| 2741 | case IDM_SORTFIRST:
|
---|
| 2742 | dcd->sortFlags |= SORT_FIRSTEXTENSION;
|
---|
| 2743 | break;
|
---|
| 2744 | case IDM_SORTLAST:
|
---|
| 2745 | dcd->sortFlags |= SORT_LASTEXTENSION;
|
---|
| 2746 | break;
|
---|
| 2747 | case IDM_SORTLWDATE:
|
---|
| 2748 | dcd->sortFlags |= SORT_LWDATE;
|
---|
| 2749 | break;
|
---|
| 2750 | case IDM_SORTREVERSE:
|
---|
| 2751 | if (dcd->sortFlags & SORT_REVERSE)
|
---|
| 2752 | dcd->sortFlags &= (~SORT_REVERSE);
|
---|
| 2753 | else
|
---|
| 2754 | dcd->sortFlags |= SORT_REVERSE;
|
---|
| 2755 | break;
|
---|
| 2756 | }
|
---|
| 2757 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
|
---|
| 2758 | SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2759 | DIR_SORT), dcd->sortFlags, TRUE);
|
---|
| 2760 | DefArcSortFlags = dcd->sortFlags; // Remember for new windows
|
---|
| 2761 | break;
|
---|
[2] | 2762 |
|
---|
[551] | 2763 | case IDM_COLLECTOR:
|
---|
| 2764 | if (!Collector) {
|
---|
| 2765 | HWND hwndC;
|
---|
| 2766 | SWP swp;
|
---|
[2] | 2767 |
|
---|
[551] | 2768 | if (ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
|
---|
| 2769 | (!fExternalCollector && !strcmp(realappname, FM3Str)))
|
---|
| 2770 | GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
|
---|
[563] | 2771 | hwndC = StartCollector(fExternalCollector ||
|
---|
| 2772 | strcmp(realappname, FM3Str) ?
|
---|
| 2773 | HWND_DESKTOP : dcd->hwndParent, 4);
|
---|
[551] | 2774 | if (hwndC) {
|
---|
| 2775 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
|
---|
| 2776 | (!fExternalCollector && !strcmp(realappname, FM3Str)))
|
---|
| 2777 | WinSetWindowPos(hwndC,
|
---|
| 2778 | HWND_TOP,
|
---|
| 2779 | swp.x,
|
---|
| 2780 | swp.y,
|
---|
| 2781 | swp.cx,
|
---|
| 2782 | swp.cy,
|
---|
| 2783 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
|
---|
| 2784 | else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 2785 | fAutoTile && !strcmp(realappname, FM3Str)) {
|
---|
| 2786 | TileChildren(dcd->hwndParent, TRUE);
|
---|
| 2787 | }
|
---|
| 2788 | WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
|
---|
[771] | 2789 | DosSleep(100); //05 Aug 07 GKY 128
|
---|
[551] | 2790 | }
|
---|
| 2791 | }
|
---|
| 2792 | else
|
---|
| 2793 | StartCollector(dcd->hwndParent, 4);
|
---|
| 2794 | break;
|
---|
[2] | 2795 |
|
---|
[551] | 2796 | case IDM_ARCEXTRACTEXIT:
|
---|
| 2797 | case IDM_ARCEXTRACT:
|
---|
| 2798 | if (dcd->info->extract)
|
---|
| 2799 | runemf2(SEPARATE | WINDOWED |
|
---|
[888] | 2800 | (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
|
---|
[907] | 2801 | hwnd, pszSrcFile, __LINE__,
|
---|
| 2802 | dcd->directory, NULL, "%s %s", dcd->info->extract,
|
---|
[773] | 2803 | BldQuotedFileName(szQuotedArcName, dcd->arcname));
|
---|
[551] | 2804 | if (SHORT1FROMMP(mp1) == IDM_ARCEXTRACTEXIT)
|
---|
| 2805 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2806 | break;
|
---|
[2] | 2807 |
|
---|
[551] | 2808 | case IDM_ARCEXTRACTWDIRSEXIT:
|
---|
| 2809 | case IDM_ARCEXTRACTWDIRS:
|
---|
| 2810 | if (dcd->info->exwdirs)
|
---|
| 2811 | runemf2(SEPARATE | WINDOWED |
|
---|
[888] | 2812 | (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
|
---|
[907] | 2813 | hwnd, pszSrcFile, __LINE__,
|
---|
| 2814 | dcd->directory, NULL, "%s %s",
|
---|
[551] | 2815 | dcd->info->exwdirs,
|
---|
[773] | 2816 | BldQuotedFileName(szQuotedArcName, dcd->arcname));
|
---|
[551] | 2817 | if (SHORT1FROMMP(mp1) == IDM_ARCEXTRACTWDIRSEXIT)
|
---|
| 2818 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2819 | break;
|
---|
[2] | 2820 |
|
---|
[551] | 2821 | case IDM_RESORT:
|
---|
| 2822 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
|
---|
| 2823 | break;
|
---|
[2] | 2824 |
|
---|
[551] | 2825 | case IDM_FILTER:
|
---|
| 2826 | {
|
---|
| 2827 | BOOL empty = FALSE;
|
---|
| 2828 | PARCITEM pci;
|
---|
[2] | 2829 |
|
---|
[551] | 2830 | if (!*dcd->mask.szMask) {
|
---|
| 2831 | empty = TRUE;
|
---|
| 2832 | pci = (PARCITEM) CurrentRecord(hwnd);
|
---|
[730] | 2833 | if (pci && strchr(pci->pszFileName, '.'))
|
---|
| 2834 | strcpy(dcd->mask.szMask, pci->pszFileName);
|
---|
[551] | 2835 | }
|
---|
[2] | 2836 |
|
---|
[551] | 2837 | if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
|
---|
| 2838 | FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
|
---|
| 2839 | WinSendMsg(hwnd, CM_FILTER, MPFROMP(ArcFilter), MPFROMP(dcd));
|
---|
| 2840 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 2841 | }
|
---|
| 2842 | else if (empty)
|
---|
| 2843 | *dcd->mask.szMask = 0;
|
---|
| 2844 | SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2845 | DIR_FILTER), &dcd->mask, TRUE);
|
---|
| 2846 | }
|
---|
| 2847 | break;
|
---|
[2] | 2848 |
|
---|
[551] | 2849 | case IDM_SWITCH:
|
---|
| 2850 | if (mp2) {
|
---|
| 2851 | if (stricmp(dcd->directory, (CHAR *) mp2)) {
|
---|
| 2852 | DosEnterCritSec();
|
---|
| 2853 | strcpy(lastextractpath, (CHAR *) mp2);
|
---|
| 2854 | MakeValidDir(lastextractpath);
|
---|
| 2855 | DosExitCritSec();
|
---|
| 2856 | }
|
---|
| 2857 | strcpy(dcd->directory, (CHAR *) mp2);
|
---|
| 2858 | MakeValidDir(dcd->directory);
|
---|
| 2859 | WinSetWindowText(dcd->hwndExtract, dcd->directory);
|
---|
| 2860 | }
|
---|
| 2861 | break;
|
---|
[2] | 2862 |
|
---|
[551] | 2863 | case IDM_WALKDIR:
|
---|
| 2864 | {
|
---|
| 2865 | CHAR newdir[CCHMAXPATH];
|
---|
[2] | 2866 |
|
---|
[551] | 2867 | strcpy(newdir, dcd->directory);
|
---|
| 2868 | if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkExtractDlgProc,
|
---|
| 2869 | FM3ModHandle, WALK_FRAME,
|
---|
| 2870 | MPFROMP(newdir)) || !*newdir)
|
---|
| 2871 | break;
|
---|
| 2872 | if (stricmp(newdir, dcd->directory)) {
|
---|
| 2873 | strcpy(dcd->directory, newdir);
|
---|
| 2874 | if (stricmp(lastextractpath, newdir))
|
---|
| 2875 | strcpy(lastextractpath, newdir);
|
---|
| 2876 | WinSetWindowText(dcd->hwndExtract, dcd->directory);
|
---|
| 2877 | }
|
---|
| 2878 | }
|
---|
| 2879 | break;
|
---|
[2] | 2880 |
|
---|
[551] | 2881 | case IDM_TEST:
|
---|
| 2882 | if (dcd->info->test)
|
---|
| 2883 | runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
|
---|
[888] | 2884 | hwnd, pszSrcFile, __LINE__, NULL, NULL,
|
---|
[773] | 2885 | "%s %s",dcd->info->test,
|
---|
| 2886 | BldQuotedFileName(szQuotedArcName, dcd->arcname));
|
---|
[551] | 2887 | break;
|
---|
[2] | 2888 |
|
---|
[551] | 2889 | case IDM_REFRESH:
|
---|
| 2890 | case IDM_DELETE:
|
---|
| 2891 | case IDM_PRINT:
|
---|
| 2892 | case IDM_VIEW:
|
---|
| 2893 | case IDM_VIEWTEXT:
|
---|
| 2894 | case IDM_VIEWBINARY:
|
---|
| 2895 | case IDM_VIEWARCHIVE:
|
---|
| 2896 | case IDM_EDIT:
|
---|
| 2897 | case IDM_EDITTEXT:
|
---|
| 2898 | case IDM_EDITBINARY:
|
---|
| 2899 | case IDM_EXTRACT:
|
---|
| 2900 | case IDM_EXTRACTWDIRS:
|
---|
| 2901 | case IDM_FIND:
|
---|
| 2902 | case IDM_EXEC:
|
---|
| 2903 | case IDM_VIRUSSCAN:
|
---|
| 2904 | {
|
---|
| 2905 | LISTINFO *li;
|
---|
[1018] | 2906 | # ifdef FORTIFY
|
---|
| 2907 | Fortify_EnterScope();
|
---|
| 2908 | # endif
|
---|
[551] | 2909 | li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
|
---|
| 2910 | if (li) {
|
---|
| 2911 | li->type = SHORT1FROMMP(mp1);
|
---|
| 2912 | li->hwnd = hwnd;
|
---|
| 2913 | li->list = BuildArcList(hwnd);
|
---|
| 2914 | if (li->type == IDM_REFRESH) {
|
---|
[2] | 2915 |
|
---|
[551] | 2916 | CHAR s[CCHMAXPATH], *p;
|
---|
| 2917 | INT x, y;
|
---|
[2] | 2918 |
|
---|
[551] | 2919 | for (x = 0; li->list && li->list[x]; x++) {
|
---|
[773] | 2920 | BldFullPathName(s, dcd->workdir, li->list[x]);
|
---|
[551] | 2921 | if (IsFile(s) != 1) {
|
---|
[1009] | 2922 | xfree(li->list[x], pszSrcFile, __LINE__);
|
---|
[551] | 2923 | li->list[x] = NULL;
|
---|
| 2924 | for (y = x; li->list[y]; y++)
|
---|
| 2925 | li->list[y] = li->list[y + 1];
|
---|
| 2926 | li->list =
|
---|
| 2927 | xrealloc(li->list, y * sizeof(CHAR *), pszSrcFile,
|
---|
| 2928 | __LINE__);
|
---|
| 2929 | x--;
|
---|
| 2930 | }
|
---|
| 2931 | else {
|
---|
| 2932 | p = xstrdup(s, pszSrcFile, __LINE__);
|
---|
| 2933 | if (p) {
|
---|
[1009] | 2934 | xfree(li->list[x], pszSrcFile, __LINE__);
|
---|
[551] | 2935 | li->list[x] = p;
|
---|
| 2936 | }
|
---|
| 2937 | }
|
---|
| 2938 | } // for
|
---|
| 2939 | }
|
---|
| 2940 | strcpy(li->arcname, dcd->arcname);
|
---|
| 2941 | li->info = dcd->info;
|
---|
| 2942 | {
|
---|
| 2943 | PARCITEM pai;
|
---|
[2] | 2944 |
|
---|
[551] | 2945 | if (SHORT1FROMMP(mp1) != IDM_EXEC)
|
---|
| 2946 | pai = (PARCITEM) CurrentRecord(hwnd);
|
---|
| 2947 | else
|
---|
| 2948 | pai = (PARCITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
|
---|
| 2949 | MPFROMLONG(CMA_FIRST),
|
---|
| 2950 | MPFROMSHORT(CRA_CURSORED));
|
---|
| 2951 | if (pai && (INT) pai != -1)
|
---|
[730] | 2952 | strcpy(li->runfile, pai->pszFileName);
|
---|
[551] | 2953 | else
|
---|
| 2954 | strcpy(li->runfile, li->list[0]);
|
---|
| 2955 | }
|
---|
| 2956 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2957 | case IDM_VIEW:
|
---|
| 2958 | case IDM_VIEWTEXT:
|
---|
| 2959 | case IDM_VIEWBINARY:
|
---|
| 2960 | case IDM_VIEWARCHIVE:
|
---|
| 2961 | case IDM_EDIT:
|
---|
| 2962 | case IDM_EDITTEXT:
|
---|
| 2963 | case IDM_EDITBINARY:
|
---|
| 2964 | case IDM_EXEC:
|
---|
| 2965 | case IDM_PRINT:
|
---|
| 2966 | case IDM_VIRUSSCAN:
|
---|
| 2967 | strcpy(li->targetpath, dcd->workdir);
|
---|
| 2968 | break;
|
---|
| 2969 | default:
|
---|
| 2970 | strcpy(li->targetpath, dcd->directory);
|
---|
| 2971 | break;
|
---|
| 2972 | }
|
---|
| 2973 | if (li->list) {
|
---|
| 2974 | if (!PostMsg(dcd->hwndObject, UM_ACTION, MPFROMP(li), MPVOID)) {
|
---|
| 2975 | Runtime_Error(pszSrcFile, __LINE__, "post");
|
---|
| 2976 | FreeListInfo(li);
|
---|
| 2977 | }
|
---|
| 2978 | else if (fUnHilite && SHORT1FROMMP(mp1) != IDM_EDIT)
|
---|
[672] | 2979 | UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
|
---|
[551] | 2980 | }
|
---|
[1018] | 2981 | else
|
---|
[1009] | 2982 | xfree(li, pszSrcFile, __LINE__);
|
---|
[1018] | 2983 | # ifdef FORTIFY
|
---|
| 2984 | Fortify_LeaveScope();
|
---|
| 2985 | # endif
|
---|
[551] | 2986 | }
|
---|
| 2987 | }
|
---|
| 2988 | break;
|
---|
[2] | 2989 | }
|
---|
[551] | 2990 | }
|
---|
| 2991 | return 0;
|
---|
[2] | 2992 |
|
---|
[551] | 2993 | case WM_CONTROL:
|
---|
| 2994 | DosError(FERR_DISABLEHARDERR);
|
---|
| 2995 | if (dcd) {
|
---|
| 2996 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 2997 | case CN_BEGINEDIT:
|
---|
| 2998 | PostMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
|
---|
| 2999 | break;
|
---|
[2] | 3000 |
|
---|
[551] | 3001 | case CN_ENDEDIT:
|
---|
| 3002 | if (!((PCNREDITDATA) mp2)->pRecord) {
|
---|
[2] | 3003 |
|
---|
[551] | 3004 | PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
|
---|
| 3005 | USHORT cmd = 0;
|
---|
[2] | 3006 |
|
---|
[739] | 3007 | if (!pfi || pfi->offStruct == FIELDOFFSET(ARCITEM, pszDisplayName))
|
---|
[551] | 3008 | cmd = IDM_SORTSMARTNAME;
|
---|
| 3009 | else if (pfi->offStruct == FIELDOFFSET(ARCITEM, cbFile))
|
---|
| 3010 | cmd = IDM_SORTSIZE;
|
---|
| 3011 | else if (pfi->offStruct == FIELDOFFSET(ARCITEM, cbComp))
|
---|
| 3012 | cmd = IDM_SORTEASIZE;
|
---|
| 3013 | else if (pfi->offStruct == FIELDOFFSET(ARCITEM, date))
|
---|
| 3014 | cmd = IDM_SORTLWDATE;
|
---|
| 3015 | else if (pfi->offStruct == FIELDOFFSET(ARCITEM, time))
|
---|
| 3016 | cmd = IDM_SORTLWDATE;
|
---|
| 3017 | if (cmd)
|
---|
| 3018 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
|
---|
| 3019 | }
|
---|
| 3020 | break;
|
---|
[2] | 3021 |
|
---|
[551] | 3022 | case CN_DROPHELP:
|
---|
| 3023 | saymsg(MB_ENTER, hwnd,
|
---|
| 3024 | GetPString(IDS_DROPHELPHDRTEXT),
|
---|
| 3025 | GetPString(IDS_ARCCNRDROPHELPTEXT), dcd->arcname);
|
---|
| 3026 | return 0;
|
---|
[2] | 3027 |
|
---|
[551] | 3028 | case CN_DRAGLEAVE:
|
---|
| 3029 | if (mp2) {
|
---|
[2] | 3030 |
|
---|
[551] | 3031 | PDRAGINFO pDInfo;
|
---|
[2] | 3032 |
|
---|
[551] | 3033 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
---|
[562] | 3034 | DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
|
---|
| 3035 | DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
|
---|
[551] | 3036 | }
|
---|
| 3037 | return 0;
|
---|
[2] | 3038 |
|
---|
[551] | 3039 | case CN_DRAGAFTER:
|
---|
| 3040 | case CN_DRAGOVER:
|
---|
| 3041 | if (mp2) {
|
---|
[2] | 3042 |
|
---|
[773] | 3043 | PDRAGITEM pDItem; /* Pointer to DRAGITEM */
|
---|
| 3044 | PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
|
---|
[551] | 3045 | PARCITEM pci;
|
---|
[2] | 3046 |
|
---|
[551] | 3047 | pci = (PARCITEM) ((PCNRDRAGINFO) mp2)->pRecord;
|
---|
| 3048 | if (SHORT1FROMMP(mp1) == CN_DRAGAFTER)
|
---|
| 3049 | pci = NULL;
|
---|
| 3050 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
---|
[562] | 3051 | DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
|
---|
[551] | 3052 | if (*dcd->arcname) {
|
---|
| 3053 | if ((driveflags[toupper(*dcd->arcname) - 'A'] &
|
---|
| 3054 | DRIVE_NOTWRITEABLE) || !dcd->info || !dcd->info->create) {
|
---|
| 3055 | DrgFreeDraginfo(pDInfo);
|
---|
| 3056 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
| 3057 | }
|
---|
| 3058 | }
|
---|
| 3059 | if (pci) {
|
---|
| 3060 | DrgFreeDraginfo(pDInfo);
|
---|
| 3061 | return MRFROM2SHORT(DOR_NODROP, 0);
|
---|
| 3062 | }
|
---|
[562] | 3063 | pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
|
---|
| 3064 | 0); /* Index to DRAGITEM */
|
---|
[551] | 3065 | if (DrgVerifyRMF(pDItem, /* Check valid rendering */
|
---|
[562] | 3066 | DRM_OS2FILE, /* mechanisms and data */
|
---|
[551] | 3067 | NULL) && !(pDItem->fsControl & DC_PREPARE)) {
|
---|
[773] | 3068 | DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
|
---|
[562] | 3069 | return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
|
---|
| 3070 | fCopyDefault ? DO_COPY : DO_MOVE);
|
---|
[551] | 3071 | }
|
---|
[562] | 3072 | DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
|
---|
[551] | 3073 | }
|
---|
[562] | 3074 | return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */
|
---|
[2] | 3075 |
|
---|
[551] | 3076 | case CN_INITDRAG:
|
---|
| 3077 | if (mp2) {
|
---|
[2] | 3078 |
|
---|
[551] | 3079 | BOOL wasemphasized = FALSE;
|
---|
| 3080 | PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
|
---|
| 3081 | PARCITEM pci;
|
---|
[2] | 3082 |
|
---|
[551] | 3083 | if (pcd) {
|
---|
| 3084 | pci = (PARCITEM) pcd->pRecord;
|
---|
| 3085 | if (pci) {
|
---|
| 3086 | if (pci->rc.flRecordAttr & CRA_SELECTED)
|
---|
| 3087 | wasemphasized = TRUE;
|
---|
| 3088 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 3089 | fSplitStatus && hwndStatus2)
|
---|
| 3090 | WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGARCMEMTEXT));
|
---|
| 3091 | if (DoFileDrag(hwnd,
|
---|
| 3092 | dcd->hwndObject,
|
---|
| 3093 | mp2, dcd->arcname, NULL, TRUE)) {
|
---|
[672] | 3094 | if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
|
---|
| 3095 | UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
|
---|
[551] | 3096 | }
|
---|
| 3097 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 3098 | fSplitStatus && hwndStatus2) {
|
---|
| 3099 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 3100 | }
|
---|
| 3101 | }
|
---|
| 3102 | else {
|
---|
| 3103 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 3104 | fSplitStatus && hwndStatus2)
|
---|
| 3105 | WinSetWindowText(hwndStatus2,
|
---|
| 3106 | GetPString(IDS_DRAGARCFILETEXT));
|
---|
| 3107 | DragOne(hwnd, dcd->hwndObject, dcd->arcname, FALSE);
|
---|
| 3108 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
| 3109 | fSplitStatus && hwndStatus2)
|
---|
| 3110 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
| 3111 | }
|
---|
| 3112 | }
|
---|
| 3113 | }
|
---|
| 3114 | return 0;
|
---|
[2] | 3115 |
|
---|
[551] | 3116 | case CN_DROP:
|
---|
| 3117 | if (mp2) {
|
---|
[2] | 3118 |
|
---|
[551] | 3119 | LISTINFO *li;
|
---|
[2] | 3120 |
|
---|
[551] | 3121 | DosBeep(500, 100); // fixme to know why beep?
|
---|
| 3122 | li = DoFileDrop(hwnd, dcd->arcname, FALSE, mp1, mp2);
|
---|
[762] | 3123 | DosBeep(50, 100); // fixme to know why beep?
|
---|
| 3124 | CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
|
---|
[551] | 3125 | if (li) {
|
---|
[562] | 3126 | li->type = li->type == DO_MOVE ? IDM_ARCHIVEM : IDM_ARCHIVE;
|
---|
[551] | 3127 | strcpy(li->targetpath, dcd->arcname);
|
---|
| 3128 | if (!li->list ||
|
---|
| 3129 | !li->list[0] ||
|
---|
| 3130 | !PostMsg(dcd->hwndObject, UM_ACTION, MPFROMP(li), MPVOID))
|
---|
| 3131 | FreeListInfo(li);
|
---|
| 3132 | }
|
---|
| 3133 | }
|
---|
| 3134 | return 0;
|
---|
[2] | 3135 |
|
---|
[551] | 3136 | case CN_CONTEXTMENU:
|
---|
| 3137 | {
|
---|
| 3138 | PARCITEM pci = (PARCITEM) mp2;
|
---|
[2] | 3139 |
|
---|
[551] | 3140 | if (pci) {
|
---|
| 3141 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
|
---|
| 3142 | MPFROM2SHORT(TRUE, CRA_CURSORED));
|
---|
| 3143 | MarkAll(hwnd, FALSE, FALSE, TRUE);
|
---|
[872] | 3144 | dcd->hwndLastMenu = CheckMenu(hwnd, &ArcMenu, ARC_POPUP);
|
---|
[551] | 3145 | }
|
---|
| 3146 | else {
|
---|
[872] | 3147 | dcd->hwndLastMenu = CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP);
|
---|
[551] | 3148 | if (dcd->hwndLastMenu && !dcd->cnremphasized) {
|
---|
| 3149 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
| 3150 | MPFROM2SHORT(TRUE, CRA_SOURCE));
|
---|
| 3151 | dcd->cnremphasized = TRUE;
|
---|
| 3152 | }
|
---|
| 3153 | }
|
---|
| 3154 | if (dcd->hwndLastMenu) {
|
---|
| 3155 | if (dcd->hwndLastMenu == ArcCnrMenu) {
|
---|
| 3156 | if (dcd->flWindowAttr & CV_MINI)
|
---|
| 3157 | WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
|
---|
| 3158 | }
|
---|
| 3159 | WinCheckMenuItem(dcd->hwndLastMenu, IDM_FOLDERAFTEREXTRACT,
|
---|
| 3160 | fFolderAfterExtract);
|
---|
| 3161 | if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
|
---|
| 3162 | if (dcd->cnremphasized) {
|
---|
| 3163 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
| 3164 | MPFROM2SHORT(FALSE, CRA_SOURCE));
|
---|
| 3165 | dcd->cnremphasized = TRUE;
|
---|
| 3166 | }
|
---|
| 3167 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
---|
| 3168 | }
|
---|
| 3169 | }
|
---|
| 3170 | }
|
---|
| 3171 | break;
|
---|
[2] | 3172 |
|
---|
[551] | 3173 | case CN_EMPHASIS:
|
---|
| 3174 | if (mp2) {
|
---|
[2] | 3175 |
|
---|
[551] | 3176 | PNOTIFYRECORDEMPHASIS pre = mp2;
|
---|
| 3177 | PARCITEM pci;
|
---|
| 3178 | CHAR s[CCHMAXPATHCOMP + 91], tf[81], tb[81];
|
---|
[2] | 3179 |
|
---|
[562] | 3180 | pci = (PARCITEM)(pre ? pre->pRecord : NULL);
|
---|
[551] | 3181 | if (!pci) {
|
---|
| 3182 | if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
| 3183 | if (hwndStatus2)
|
---|
| 3184 | WinSetWindowText(hwndStatus2, NullStr);
|
---|
| 3185 | if (fMoreButtons)
|
---|
| 3186 | WinSetWindowText(hwndName, NullStr);
|
---|
| 3187 | }
|
---|
| 3188 | break;
|
---|
| 3189 | }
|
---|
| 3190 | if (pre->fEmphasisMask & CRA_SELECTED) {
|
---|
| 3191 | if (pci->rc.flRecordAttr & CRA_SELECTED) {
|
---|
| 3192 | dcd->selectedbytes += pci->cbFile;
|
---|
| 3193 | dcd->selectedfiles++;
|
---|
| 3194 | }
|
---|
| 3195 | else if (dcd->selectedfiles) {
|
---|
| 3196 | dcd->selectedbytes -= pci->cbFile;
|
---|
| 3197 | dcd->selectedfiles--;
|
---|
| 3198 | }
|
---|
| 3199 | commafmt(tf, sizeof(tf), dcd->selectedfiles);
|
---|
| 3200 | if (dcd->ullTotalBytes)
|
---|
| 3201 | CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
|
---|
| 3202 | else
|
---|
| 3203 | *tb = 0;
|
---|
| 3204 | sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
|
---|
| 3205 | WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
|
---|
| 3206 | }
|
---|
| 3207 | else if (WinQueryActiveWindow(dcd->hwndParent) ==
|
---|
| 3208 | dcd->hwndFrame &&
|
---|
| 3209 | !ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
| 3210 | if (pre->fEmphasisMask & CRA_CURSORED) {
|
---|
| 3211 | if (pci->rc.flRecordAttr & CRA_CURSORED) {
|
---|
| 3212 | if (fSplitStatus && hwndStatus2) {
|
---|
| 3213 | if (dcd->ullTotalBytes)
|
---|
| 3214 | CommaFmtULL(tb, sizeof(tb), pci->cbFile, ' ');
|
---|
| 3215 | else
|
---|
| 3216 | *tb = 0;
|
---|
| 3217 | sprintf(s, "%s%s%s%s",
|
---|
| 3218 | *tb ? " " : NullStr,
|
---|
[730] | 3219 | tb, *tb ? " " : NullStr, pci->pszFileName);
|
---|
[551] | 3220 | WinSetWindowText(hwndStatus2, s);
|
---|
| 3221 | }
|
---|
| 3222 | if (fMoreButtons)
|
---|
[730] | 3223 | WinSetWindowText(hwndName, pci->pszFileName);
|
---|
[551] | 3224 | }
|
---|
| 3225 | }
|
---|
| 3226 | }
|
---|
| 3227 | }
|
---|
| 3228 | break;
|
---|
[2] | 3229 |
|
---|
[551] | 3230 | case CN_ENTER:
|
---|
| 3231 | if (mp2) {
|
---|
[2] | 3232 |
|
---|
[551] | 3233 | PARCITEM pci = (PARCITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
|
---|
[2] | 3234 |
|
---|
[551] | 3235 | if (pci) {
|
---|
[2] | 3236 |
|
---|
[551] | 3237 | CHAR *s;
|
---|
[2] | 3238 |
|
---|
[551] | 3239 | if ((pci->rc.flRecordAttr & CRA_INUSE) ||
|
---|
| 3240 | (pci->flags & (ARCFLAGS_REALDIR | ARCFLAGS_PSEUDODIR)))
|
---|
| 3241 | break;
|
---|
[730] | 3242 | s = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
|
---|
[551] | 3243 | if (s) {
|
---|
| 3244 | if (!PostMsg(dcd->hwndObject, UM_ENTER, MPFROMP(s), MPVOID)) {
|
---|
| 3245 | Runtime_Error(pszSrcFile, __LINE__, "post");
|
---|
[1009] | 3246 | xfree(s, pszSrcFile, __LINE__);
|
---|
[551] | 3247 | }
|
---|
| 3248 | }
|
---|
| 3249 | }
|
---|
| 3250 | }
|
---|
| 3251 | break;
|
---|
[2] | 3252 | }
|
---|
[551] | 3253 | }
|
---|
| 3254 | return 0;
|
---|
[2] | 3255 |
|
---|
[551] | 3256 | case UM_FOLDUP:
|
---|
| 3257 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 3258 | DosExit(EXIT_PROCESS, 1);
|
---|
| 3259 | return 0;
|
---|
[2] | 3260 |
|
---|
[551] | 3261 | case UM_CLOSE:
|
---|
| 3262 | WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 3263 | QW_PARENT));
|
---|
| 3264 | return 0;
|
---|
[2] | 3265 |
|
---|
[551] | 3266 | case WM_SAVEAPPLICATION:
|
---|
| 3267 | if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
| 3268 | SWP swp;
|
---|
[2] | 3269 |
|
---|
[551] | 3270 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
| 3271 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
|
---|
| 3272 | PrfWriteProfileData(fmprof, appname, "AV2SizePos", &swp, sizeof(swp));
|
---|
| 3273 | }
|
---|
| 3274 | break;
|
---|
[2] | 3275 |
|
---|
[551] | 3276 | case WM_CLOSE:
|
---|
| 3277 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
|
---|
| 3278 | if (dcd)
|
---|
| 3279 | dcd->stopflag++;
|
---|
| 3280 | if (dcd && dcd->hwndObject) {
|
---|
| 3281 | if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
|
---|
| 3282 | WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 3283 | }
|
---|
| 3284 | // In case object window frees dcd
|
---|
| 3285 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 3286 | if (!dcd ||
|
---|
| 3287 | (!dcd->dontclose &&
|
---|
| 3288 | !dcd->amextracted && ParentIsDesktop(hwnd, dcd->hwndParent))) {
|
---|
| 3289 | if (!PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID))
|
---|
| 3290 | WinSendMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
|
---|
| 3291 | }
|
---|
| 3292 | return 0;
|
---|
| 3293 |
|
---|
| 3294 | case WM_DESTROY:
|
---|
| 3295 | if (ArcMenu)
|
---|
| 3296 | WinDestroyWindow(ArcMenu);
|
---|
| 3297 | if (ArcCnrMenu)
|
---|
| 3298 | WinDestroyWindow(ArcCnrMenu);
|
---|
| 3299 | ArcMenu = ArcCnrMenu = (HWND) 0;
|
---|
[751] | 3300 | EmptyArcCnr(hwnd);
|
---|
[551] | 3301 | break;
|
---|
[2] | 3302 | }
|
---|
[705] | 3303 | if (dcd && dcd->oldproc){
|
---|
| 3304 | return dcd->oldproc(hwnd, msg, mp1, mp2);
|
---|
| 3305 | }
|
---|
| 3306 | else
|
---|
| 3307 | return PFNWPCnr(hwnd, msg, mp1, mp2);
|
---|
[2] | 3308 | }
|
---|
| 3309 |
|
---|
[942] | 3310 | MRESULT EXPENTRY ArcCnrMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 3311 | MPARAM mp2)
|
---|
| 3312 | {
|
---|
| 3313 | PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
| 3314 | static short sLastMenuitem;
|
---|
| 3315 |
|
---|
| 3316 | switch (msg) {
|
---|
| 3317 | case WM_MOUSEMOVE: {
|
---|
| 3318 | if (fOtherHelp) {
|
---|
[953] | 3319 | RECTL rectl;
|
---|
| 3320 | SHORT i, sCurrentMenuitem;
|
---|
| 3321 | SHORT MenuItems = 10;
|
---|
| 3322 | SHORT asMenuIDs[10] = {IDM_VIEW,
|
---|
| 3323 | IDM_DELETE,
|
---|
| 3324 | IDM_EXEC,
|
---|
| 3325 | IDM_EXTRACT,
|
---|
| 3326 | IDM_TEST,
|
---|
| 3327 | IDM_VIRUSSCAN,
|
---|
| 3328 | IDM_RESCAN,
|
---|
| 3329 | IDM_WALKDIR,
|
---|
| 3330 | IDM_FILTER,
|
---|
| 3331 | 0};
|
---|
| 3332 | char *szHelpString = NULL;
|
---|
[942] | 3333 |
|
---|
| 3334 |
|
---|
[953] | 3335 | for (i=0; i<MenuItems; i++) {
|
---|
| 3336 | sCurrentMenuitem = asMenuIDs[i];
|
---|
| 3337 | oldMenuProc(hwnd,MM_QUERYITEMRECT,
|
---|
| 3338 | MPFROM2SHORT(asMenuIDs[i], FALSE),
|
---|
| 3339 | &rectl);
|
---|
[942] | 3340 |
|
---|
[953] | 3341 | if (MOUSEMSG(&msg)->x > rectl.xLeft &&
|
---|
| 3342 | MOUSEMSG(&msg)->x < rectl.xRight &&
|
---|
| 3343 | MOUSEMSG(&msg)->y > rectl.yBottom &&
|
---|
| 3344 | MOUSEMSG(&msg)->y < rectl.yTop)
|
---|
| 3345 | break;
|
---|
| 3346 | } // for
|
---|
[942] | 3347 |
|
---|
| 3348 |
|
---|
[953] | 3349 | switch (sCurrentMenuitem) {
|
---|
| 3350 | case 0:
|
---|
| 3351 | break;
|
---|
| 3352 | case IDM_VIEW:
|
---|
| 3353 | szHelpString = GetPString(IDS_ARCCNRVIEWMENUHELP);
|
---|
| 3354 | break;
|
---|
| 3355 | case IDM_DELETE:
|
---|
| 3356 | szHelpString = GetPString(IDS_ARCCNRDELETEMENUHELP);
|
---|
| 3357 | break;
|
---|
| 3358 | case IDM_EXEC:
|
---|
| 3359 | szHelpString = GetPString(IDS_ARCCNREXECMENUHELP);
|
---|
| 3360 | break;
|
---|
| 3361 | case IDM_EXTRACT:
|
---|
| 3362 | szHelpString = GetPString(IDS_ARCCNREXTRACTMENUHELP);
|
---|
| 3363 | break;
|
---|
| 3364 | case IDM_TEST:
|
---|
| 3365 | szHelpString = GetPString(IDS_ARCCNRTESTMENUHELP);
|
---|
| 3366 | break;
|
---|
| 3367 | case IDM_VIRUSSCAN:
|
---|
| 3368 | szHelpString = GetPString(IDS_ARCCNRVIRUSMENUHELP);
|
---|
| 3369 | break;
|
---|
| 3370 | case IDM_RESCAN:
|
---|
| 3371 | szHelpString = GetPString(IDS_ARCCNRRESCANMENUHELP);
|
---|
| 3372 | break;
|
---|
| 3373 | case IDM_WALKDIR:
|
---|
| 3374 | szHelpString = GetPString(IDS_ARCCNRWALKDIRMENUHELP);
|
---|
| 3375 | break;
|
---|
| 3376 | case IDM_FILTER:
|
---|
| 3377 | szHelpString = GetPString(IDS_ARCCNRFILTERMENUHELP);
|
---|
| 3378 | break;
|
---|
| 3379 | default:
|
---|
| 3380 | break;
|
---|
| 3381 | }
|
---|
[942] | 3382 |
|
---|
[953] | 3383 | if (sLastMenuitem != sCurrentMenuitem && szHelpString) {
|
---|
| 3384 | sLastMenuitem = sCurrentMenuitem;
|
---|
| 3385 | MakeBubble(hwnd, TRUE, szHelpString);
|
---|
| 3386 | }
|
---|
| 3387 | else if (hwndBubble && !sCurrentMenuitem){
|
---|
| 3388 | sLastMenuitem = sCurrentMenuitem;
|
---|
| 3389 | WinDestroyWindow(hwndBubble);
|
---|
| 3390 | }
|
---|
[942] | 3391 | }
|
---|
| 3392 | }
|
---|
| 3393 | }
|
---|
| 3394 | return oldMenuProc(hwnd, msg, mp1, mp2);
|
---|
| 3395 | }
|
---|
| 3396 |
|
---|
[551] | 3397 | HWND StartArcCnr(HWND hwndParent, HWND hwndCaller, CHAR * arcname, INT flags,
|
---|
| 3398 | ARC_TYPE * sinfo)
|
---|
[212] | 3399 | {
|
---|
[2] | 3400 | /*
|
---|
| 3401 | * bitmapped flags:
|
---|
| 3402 | * 1 = am extracted from another archive
|
---|
| 3403 | * 4 = don't kill proc on close
|
---|
| 3404 | */
|
---|
| 3405 |
|
---|
[551] | 3406 | HWND hwndFrame = (HWND) 0, hwndClient;
|
---|
| 3407 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
|
---|
| 3408 | FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
|
---|
| 3409 | USHORT id;
|
---|
| 3410 | DIRCNRDATA *dcd;
|
---|
| 3411 | ARC_TYPE *info = sinfo;
|
---|
| 3412 | CHAR title[MAXNAMEL + 1] = "AV/2 - ";
|
---|
| 3413 | CHAR fullname[CCHMAXPATH + 8], *p, temp;
|
---|
[2] | 3414 | static USHORT idinc = 0;
|
---|
| 3415 |
|
---|
[423] | 3416 | if (!idinc)
|
---|
[2] | 3417 | idinc = (rand() % 256);
|
---|
[551] | 3418 | if (ParentIsDesktop(hwndParent, hwndParent))
|
---|
[2] | 3419 | FrameFlags |= (FCF_TASKLIST | FCF_MENU);
|
---|
[423] | 3420 | if (arcname) {
|
---|
[2] | 3421 | DosError(FERR_DISABLEHARDERR);
|
---|
[423] | 3422 | if (DosQueryPathInfo(arcname,
|
---|
[551] | 3423 | FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
|
---|
| 3424 | strcpy(fullname, arcname);
|
---|
[2] | 3425 | p = fullname;
|
---|
[551] | 3426 | while (*p) {
|
---|
[423] | 3427 | if (*p == '/')
|
---|
[551] | 3428 | *p = '\\';
|
---|
[2] | 3429 | p++;
|
---|
| 3430 | }
|
---|
[423] | 3431 | if (!info)
|
---|
[551] | 3432 | info = find_type(fullname, arcsighead);
|
---|
[423] | 3433 | if (!info)
|
---|
[2] | 3434 | return hwndFrame;
|
---|
[551] | 3435 | if (strlen(title) + strlen(fullname) > MAXNAMEL) {
|
---|
| 3436 | p = title + strlen(title);
|
---|
| 3437 | strncpy(p, fullname, MAXNAMEL / 2 - 5);
|
---|
| 3438 | strcpy(p + MAXNAMEL / 2 - 5, "...");
|
---|
| 3439 | strcat(title, fullname + strlen(fullname) - (MAXNAMEL / 2 - 5));
|
---|
[460] | 3440 | }
|
---|
[551] | 3441 | else {
|
---|
| 3442 | strcat(title, fullname);
|
---|
[460] | 3443 | }
|
---|
[2] | 3444 | hwndFrame = WinCreateStdWindow(hwndParent,
|
---|
[551] | 3445 | WS_VISIBLE,
|
---|
| 3446 | &FrameFlags,
|
---|
[593] | 3447 | WC_ARCCONTAINER,
|
---|
[551] | 3448 | title,
|
---|
| 3449 | WS_VISIBLE | fwsAnimate,
|
---|
| 3450 | FM3ModHandle, ARC_FRAME, &hwndClient);
|
---|
[423] | 3451 | if (hwndFrame && hwndClient) {
|
---|
[2] | 3452 | id = ARC_FRAME + idinc++;
|
---|
[423] | 3453 | if (idinc > 512)
|
---|
[551] | 3454 | idinc = 0;
|
---|
| 3455 | WinSetWindowUShort(hwndFrame, QWS_ID, id);
|
---|
[1017] | 3456 | # ifdef FORTIFY
|
---|
| 3457 | Fortify_EnterScope();
|
---|
| 3458 | # endif
|
---|
[551] | 3459 | dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
|
---|
[358] | 3460 | if (!dcd) {
|
---|
[551] | 3461 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 3462 | hwndFrame = (HWND) 0;
|
---|
[358] | 3463 | }
|
---|
| 3464 | else {
|
---|
[551] | 3465 | dcd->size = sizeof(DIRCNRDATA);
|
---|
| 3466 | dcd->id = id;
|
---|
| 3467 | dcd->type = ARC_FRAME;
|
---|
| 3468 | save_dir2(dcd->workdir);
|
---|
| 3469 | if (dcd->workdir[strlen(dcd->workdir) - 1] != '\\')
|
---|
| 3470 | strcat(dcd->workdir, "\\");
|
---|
| 3471 | sprintf(dcd->workdir + strlen(dcd->workdir), "%s.%03x",
|
---|
| 3472 | ArcTempRoot, (clock() & 4095));
|
---|
| 3473 | strcpy(dcd->arcname, fullname);
|
---|
| 3474 | if (*extractpath) {
|
---|
| 3475 | if (!strcmp(extractpath, "*")) {
|
---|
| 3476 | p = strrchr(fullname, '\\');
|
---|
| 3477 | if (p) {
|
---|
| 3478 | if (p < fullname + 3)
|
---|
| 3479 | p++;
|
---|
| 3480 | temp = *p;
|
---|
| 3481 | *p = 0;
|
---|
| 3482 | strcpy(dcd->directory, fullname);
|
---|
| 3483 | *p = temp;
|
---|
| 3484 | }
|
---|
| 3485 | }
|
---|
| 3486 | else
|
---|
| 3487 | strcpy(dcd->directory, extractpath);
|
---|
| 3488 | }
|
---|
| 3489 | if (!*dcd->directory && *lastextractpath) {
|
---|
| 3490 | DosEnterCritSec();
|
---|
| 3491 | strcpy(dcd->directory, lastextractpath);
|
---|
| 3492 | DosExitCritSec();
|
---|
| 3493 | }
|
---|
| 3494 | if (!*dcd->directory) {
|
---|
| 3495 | if (!ParentIsDesktop(hwndParent, hwndParent))
|
---|
| 3496 | TopWindowName(hwndParent, hwndCaller, dcd->directory);
|
---|
| 3497 | if (!*dcd->directory) {
|
---|
| 3498 | p = strrchr(fullname, '\\');
|
---|
| 3499 | if (p) {
|
---|
| 3500 | if (p < fullname + 3)
|
---|
| 3501 | p++;
|
---|
| 3502 | *p = 0;
|
---|
| 3503 | strcpy(dcd->directory, fullname);
|
---|
| 3504 | }
|
---|
| 3505 | }
|
---|
| 3506 | }
|
---|
| 3507 | if (!*dcd->directory ||
|
---|
| 3508 | IsFile(dcd->directory) ||
|
---|
| 3509 | (isalpha(*dcd->directory) &&
|
---|
| 3510 | (driveflags[toupper(*dcd->directory) - 'A'] &
|
---|
| 3511 | DRIVE_NOTWRITEABLE)))
|
---|
| 3512 | save_dir2(dcd->directory);
|
---|
[562] | 3513 | dcd->hwndParent = hwndParent ? hwndParent : HWND_DESKTOP;
|
---|
[551] | 3514 | dcd->hwndFrame = hwndFrame;
|
---|
| 3515 | dcd->hwndClient = hwndClient;
|
---|
[562] | 3516 | dcd->amextracted = (flags & 1) != 0;
|
---|
| 3517 | dcd->dontclose = (flags & 4) != 0;
|
---|
[551] | 3518 | dcd->info = info;
|
---|
| 3519 | dcd->sortFlags = DefArcSortFlags;
|
---|
| 3520 | {
|
---|
| 3521 | PFNWP oldproc;
|
---|
[2] | 3522 |
|
---|
[551] | 3523 | oldproc = WinSubclassWindow(hwndFrame, (PFNWP) ArcFrameWndProc);
|
---|
| 3524 | WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
|
---|
[358] | 3525 | }
|
---|
[551] | 3526 | dcd->hwndCnr = WinCreateWindow(hwndClient,
|
---|
| 3527 | WC_CONTAINER,
|
---|
| 3528 | NULL,
|
---|
| 3529 | CCS_AUTOPOSITION | CCS_MINIICONS |
|
---|
| 3530 | CCS_MINIRECORDCORE | ulCnrType |
|
---|
| 3531 | WS_VISIBLE,
|
---|
| 3532 | 0,
|
---|
| 3533 | 0,
|
---|
| 3534 | 0,
|
---|
| 3535 | 0,
|
---|
| 3536 | hwndClient,
|
---|
| 3537 | HWND_TOP, (ULONG) ARC_CNR, NULL, NULL);
|
---|
| 3538 | if (!dcd->hwndCnr) {
|
---|
| 3539 | Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
|
---|
| 3540 | IDS_WINCREATEWINDOW);
|
---|
| 3541 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
---|
[1017] | 3542 | xfree(dcd, pszSrcFile, __LINE__);
|
---|
| 3543 | # ifdef FORTIFY
|
---|
| 3544 | Fortify_LeaveScope();
|
---|
| 3545 | # endif
|
---|
[551] | 3546 | hwndFrame = (HWND) 0;
|
---|
| 3547 | }
|
---|
[358] | 3548 | else {
|
---|
[551] | 3549 | WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
|
---|
| 3550 | dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
|
---|
| 3551 | (PFNWP) ArcCnrWndProc);
|
---|
| 3552 | {
|
---|
| 3553 | USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
|
---|
| 3554 | DIR_FILTER, DIR_FOLDERICON, 0
|
---|
| 3555 | };
|
---|
[2] | 3556 |
|
---|
[551] | 3557 | CommonCreateTextChildren(dcd->hwndClient,
|
---|
[593] | 3558 | WC_ARCSTATUS, ids);
|
---|
[551] | 3559 | }
|
---|
| 3560 | WinEnableWindow(WinWindowFromID(dcd->hwndClient, DIR_VIEW), FALSE);
|
---|
| 3561 | dcd->hwndExtract = WinCreateWindow(dcd->hwndClient,
|
---|
| 3562 | WC_ENTRYFIELD,
|
---|
| 3563 | NULL,
|
---|
| 3564 | ES_AUTOSCROLL,
|
---|
| 3565 | 0,
|
---|
| 3566 | 0,
|
---|
| 3567 | 0,
|
---|
| 3568 | 0,
|
---|
| 3569 | dcd->hwndClient,
|
---|
| 3570 | HWND_TOP,
|
---|
| 3571 | ARC_EXTRACTDIR, NULL, NULL);
|
---|
| 3572 | WinSendMsg(dcd->hwndExtract,
|
---|
| 3573 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 3574 | WinSetWindowText(dcd->hwndExtract, dcd->directory);
|
---|
| 3575 | if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
|
---|
| 3576 | WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
|
---|
[953] | 3577 | if (FrameFlags & FCF_MENU) {
|
---|
| 3578 | PFNWP oldmenuproc;
|
---|
| 3579 | HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
|
---|
[942] | 3580 |
|
---|
| 3581 | oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) ArcCnrMenuProc);
|
---|
| 3582 | WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
|
---|
[551] | 3583 | if (!fToolbar) {
|
---|
[2] | 3584 |
|
---|
[551] | 3585 | if (hwndMenu) {
|
---|
| 3586 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3587 | MPFROM2SHORT(IDM_VIEW, FALSE), MPVOID);
|
---|
| 3588 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3589 | MPFROM2SHORT(IDM_EXEC, FALSE), MPVOID);
|
---|
| 3590 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3591 | MPFROM2SHORT(IDM_RESCAN, FALSE), MPVOID);
|
---|
| 3592 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3593 | MPFROM2SHORT(IDM_DELETE, FALSE), MPVOID);
|
---|
| 3594 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3595 | MPFROM2SHORT(IDM_EXTRACT, FALSE), MPVOID);
|
---|
| 3596 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3597 | MPFROM2SHORT(IDM_TEST, FALSE), MPVOID);
|
---|
| 3598 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3599 | MPFROM2SHORT(IDM_VIRUSSCAN, FALSE), MPVOID);
|
---|
| 3600 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3601 | MPFROM2SHORT(IDM_WALKDIR, FALSE), MPVOID);
|
---|
| 3602 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
| 3603 | MPFROM2SHORT(IDM_FILTER, FALSE), MPVOID);
|
---|
| 3604 | }
|
---|
| 3605 | }
|
---|
| 3606 | }
|
---|
| 3607 | if (FrameFlags & FCF_TASKLIST) {
|
---|
[2] | 3608 |
|
---|
[551] | 3609 | SWP swp, swpD;
|
---|
| 3610 | ULONG size = sizeof(swp);
|
---|
| 3611 | LONG cxScreen, cyScreen;
|
---|
[2] | 3612 |
|
---|
[551] | 3613 | WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
|
---|
| 3614 | if (PrfQueryProfileData(fmprof,
|
---|
| 3615 | appname, "AV2SizePos", &swpD, &size)) {
|
---|
| 3616 | cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
|
---|
| 3617 | cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
|
---|
| 3618 | if (swp.x + swpD.cx > cxScreen)
|
---|
| 3619 | swp.x = cxScreen - swpD.cx;
|
---|
| 3620 | if (swp.y + swpD.cy > cyScreen)
|
---|
| 3621 | swp.y = cyScreen - swpD.cy;
|
---|
| 3622 | swp.cx = swpD.cx;
|
---|
| 3623 | swp.cy = swpD.cy;
|
---|
| 3624 | }
|
---|
| 3625 | WinSetWindowPos(hwndFrame,
|
---|
| 3626 | HWND_TOP,
|
---|
| 3627 | swp.x,
|
---|
| 3628 | swp.y,
|
---|
| 3629 | swp.cx,
|
---|
| 3630 | swp.cy,
|
---|
| 3631 | SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
|
---|
| 3632 | SWP_ACTIVATE);
|
---|
| 3633 | }
|
---|
| 3634 | }
|
---|
[2] | 3635 | }
|
---|
| 3636 | }
|
---|
| 3637 | }
|
---|
| 3638 | return hwndFrame;
|
---|
| 3639 | }
|
---|
[793] | 3640 |
|
---|
| 3641 | #pragma alloc_text(ARCCNRS,ArcCnrWndProc,ArcObjWndProc,ArcClientWndProc,BldQuotedFullPathName)
|
---|
| 3642 | #pragma alloc_text(ARCCNRS,ArcTextProc,FillArcCnr,ArcFilter,BldQuotedFileName)
|
---|
| 3643 | #pragma alloc_text(ARCCNRS,ArcSort,ArcFrameWndProc,IsArcThere,ArcErrProc)
|
---|
| 3644 | #pragma alloc_text(STARTUP,StartArcCnr)
|
---|