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