source: trunk/dll/arccnrs.c@ 1515

Last change on this file since 1515 was 1515, checked in by John Small, 15 years ago

Ticket 422: Change WinSendMsg to PostMsg in response to WM_SETFOCUS. Stops a
hang under unusual circumstances.

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