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