source: trunk/dll/arccnrs.c@ 1413

Last change on this file since 1413 was 1413, checked in by Gregg Young, 16 years ago

Fixed select/deselect mask and filtering for wildcards without \ or / in them for archives with path names.

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