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