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