source: trunk/dll/arccnrs.c@ 1269

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

Added a thread to monitor completion of unarchive to send message to open viewer fix memory allocate/free issues. It appears that it fixes ticket 58

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