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