source: trunk/dll/arccnrs.c@ 1272

Last change on this file since 1272 was 1272, checked in by Gregg Young, 17 years ago

Remove priority_bumped from WaitChildThread and added some comments (Ticket 58)

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