source: trunk/dll/arccnrs.c@ 1270

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

Comments and code cleanup for WaitChildThread solution to hang cused by viewer opening before archiver process closes (Ticket 58)

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