source: trunk/dll/arccnrs.c@ 1544

Last change on this file since 1544 was 1544, checked in by Gregg Young, 15 years ago

Changes to fopen and _fsopen to allow FM2 to be loaded in high memory

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