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