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