source: trunk/dll/misc.c@ 1358

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

Comments for CS 1354/55

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 75.6 KB
RevLine 
[70]1/***********************************************************************
2
3 $Id: misc.c 1358 2008-12-27 00:03:08Z gyoung $
4
[406]5 Misc GUI support functions
[70]6
7 Copyright (c) 1993-98 M. Kimes
[907]8 Copyright (c) 2003, 2008 Steven H. Levine
[70]9
[161]10 11 Jun 03 SHL Add JFS and FAT32 support
11 01 Aug 04 SHL Rework lstrip/rstrip usage
12 01 Aug 04 SHL LoadLibPath: avoid buffer overflow
[198]13 07 Jun 05 SHL Drop obsoletes
[231]14 24 Jul 05 SHL Beautify
[245]15 24 Jul 05 SHL Correct longname display option
[350]16 17 Jul 06 SHL Use Runtime_Error
[369]17 26 Jul 06 SHL Use chop_at_crnl
[397]18 27 Jul 06 SHL Comments, apply indent
[406]19 29 Jul 06 SHL Use xfgets_bstripcr
[451]20 16 Aug 06 SHL Comments
[468]21 31 Aug 06 SHL disable_menuitem: rework args to match name - sheesh
[526]22 10 Oct 06 GKY Add NDFS32 support
[552]23 18 Feb 07 GKY More drive type and drive icon support
[688]24 10 Jun 07 GKY Add IsFm2Window as part of work around PM drag limit
[730]25 05 Jul 07 GKY Fix menu removals for WORKPLACE_PROCESS=YES
[737]26 23 Jul 07 SHL Sync with CNRITEM updates (ticket#24)
[751]27 31 Jul 07 SHL Clean up and report errors (ticket#24)
[756]28 03 Aug 07 GKY Direct editting fixed (ticket#24)
[773]29 06 Aug 07 SHL Use BldQuotedFileName
[775]30 06 Aug 07 GKY Increase Subject EA to 1024
31 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
[787]32 14 Aug 07 SHL Delete obsoletes
33 14 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
[827]34 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
[860]35 05 Nov 07 GKY Use commafmtULL to display file sizes for large file support
[872]36 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
[921]37 12 Jan 08 SHL Document SetConditionalCascade
[940]38 13 Jan 08 GKY Get Subjectwidth/Subjectleft working in the collector.
[998]39 19 Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen
[940]40 21 Jan 08 GKY Stop reallocating NullStr by direct editing of empty subject and longname strings.
[985]41 29 Feb 08 GKY Use xfree where appropriate
[998]42 08 Mar 08 JBS Ticket 230: Replace prefixless INI keys for default directory containers with
[1159]43 keys using a "DirCnr." prefix
[1026]44 19 Jun 08 JBS Ticket 239: Fix LoadDetailsSwitches so INI file is read correctly and details
[1159]45 switches are set correctly.
[1065]46 11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
[1159]47 all the details view settings (both the global variables and those in the
48 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
[1077]49 17 Jul 08 SHL Add GetTidForWindow for Fortify support
[1084]50 20 Jul 08 GKY Add save/append filename to clipboard.
51 Change menu wording to make these easier to find
[1112]52 23 Aug 08 GKY Add CheckDriveSpaceAvail To pre check drive space to prevent failures
[1358]53 25 Dec 08 GKY Add code to allow write verify to be turned off on a per drive basis
[70]54
55***********************************************************************/
56
[907]57#include <stdlib.h>
58#include <string.h>
59#include <ctype.h>
60#include <share.h>
[1159]61#include <malloc.h> // _heapmin
[907]62
[2]63#define INCL_DOS
64#define INCL_WIN
65#define INCL_GPI
[841]66#define INCL_LONGLONG
[2]67
[1182]68#include "fm3dll.h"
[1225]69#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
70#include "misc.h"
[1210]71#include "killproc.h" // Data declaration(s)
72#include "comp.h" // Data declaration(s)
73#include "treecnr.h" // Data declaration(s)
74#include "mainwnd.h" // Data declaration(s)
75#include "init.h" // Data declaration(s)
76#include "dircnrs.h" // Data declaration(s)
77#include "newview.h" // Data declarations
78#include "collect.h" // data declaration(s)
79#include "notebook.h" // data declaration(s)
80#include "arccnrs.h"
[2]81#include "fm3dlg.h"
82#include "fm3str.h"
[1159]83#include "pathutil.h" // BldQuotedFileName
84#include "errutil.h" // Dos_Error...
85#include "strutil.h" // GetPString
86#include "command.h" // LINKCMDS
87#include "cmdline.h" // CmdLineDlgProc
88#include "defview.h" // QuickView
89#include "copyf.h" // WriteLongName
90#include "strips.h" // chop_at_crnl
[1182]91#include "valid.h" // CheckDrive
92#include "presparm.h" // CopyPresParams
93#include "systemf.h" // ExecOnList
94#include "viewer.h" // StartMLEEditor
95#include "subj.h" // Subject
96#include "wrappers.h" // xDosSetPathInfo
97#include "commafmt.h" // CommaFmtULL
[1159]98#include "fortify.h"
[1354]99#include "info.h" // driveflags
[2]100
[1225]101#define CONTAINER_COLUMNS 13 /* Number of columns in details view */
102#define MS_POPUP 0x00000010L
103
[1210]104// Data definitions
105#pragma data_seg(GLOBAL1)
106HWND CollectorDirMenu;
107HWND CollectorFileMenu;
108HWND DirMenu;
109HWND FileMenu;
110HWND TreeMenu;
111BOOL fDefaultDeletePerm;
112BOOL fWorkPlace;
113
114#pragma data_seg(GLOBAL4)
115ULONG numswitches;
116HSWITCH switches[499];
117
[2]118#pragma data_seg(DATA1)
[350]119static PSZ pszSrcFile = __FILE__;
120
[2]121#ifndef BEGIN_LIBPATH
[1159]122#define BEGIN_LIBPATH 1
[2]123#endif
[231]124
[2]125#ifndef END_LIBPATH
[1159]126#define END_LIBPATH 2
[2]127#endif
[231]128
[2]129#ifndef ORD_DOS32QUERYEXTLIBPATH
[231]130#define ORD_DOS32QUERYEXTLIBPATH 874
[2]131#endif
132
[687]133BOOL IsFm2Window(HWND hwnd, BOOL chkTid)
134{
135 PIB *ppib;
136 TIB *ptib;
[751]137 BOOL yes;
138 APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
[687]139
[733]140 if (rc) {
[687]141 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1159]142 "DosGetInfoBlocks");
[751]143 yes = FALSE;
[733]144 }
[687]145 else {
146 PID pid;
147 TID tid;
148
[751]149 // Check window owned by FM2 process
150 // Check say same thread too, if requested
151 // OK for window to be dead - just return FALSE
152 yes = WinQueryWindowProcess(hwnd, &pid, &tid) &&
[1159]153 pid == ppib->pib_ulpid &&
154 (!chkTid || tid == ptib->tib_ptib2->tib2_ultid);
[687]155 }
[751]156 return yes;
[687]157}
158
[1077]159#ifdef FORTIFY
160
161/**
[1078]162 * Return thread ordinal for fm/2 window
[1077]163 * window must exist and must be created by fm/2
164 * @param hwnd is window handle
[1078]165 * @returns thread ordinal or -1 if error
[1077]166 */
167
168INT GetTidForWindow(HWND hwnd)
169{
170 PIB *ppib;
171 TIB *ptib;
[1078]172 LONG ordinal = -1;
[1077]173 APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
174
175 if (rc) {
176 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1159]177 "DosGetInfoBlocks");
[1077]178 }
179 else {
180 PID pid;
181 TID tid;
182 if (!WinQueryWindowProcess(hwnd, &pid, &tid))
[1159]183 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryWindowProcess failed for %X", hwnd);
[1077]184 else if (pid != ppib->pib_ulpid)
[1159]185 Runtime_Error(pszSrcFile, __LINE__, "hwnd %X not created by fm/2", hwnd);
[1077]186 else
[1159]187 ordinal = ptib->tib_ptib2->tib2_ultid;
[1077]188 }
[1078]189 return ordinal;
[1077]190}
191
[1078]192/**
193 * Return thread ordinal for current thread
194 * @returns thread ordinal or -1 if error
195 */
196
197INT GetTidForThread(VOID)
198{
199 PIB *ppib;
200 TIB *ptib;
201 LONG ordinal = -1;
202 APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
203
204 if (rc) {
205 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1159]206 "DosGetInfoBlocks");
[1078]207 }
208 else
209 ordinal = ptib->tib_ptib2->tib2_ultid;
210
211 return ordinal;
212}
213
[1077]214#endif // FORTIFY
215
[231]216VOID SetShiftState(VOID)
217{
[397]218 shiftstate = 0;
219 if (WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
220 shiftstate |= KC_CTRL;
221 if (WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
222 shiftstate |= KC_SHIFT;
223 if (WinGetKeyState(HWND_DESKTOP, VK_ALT) & 0x8000)
224 shiftstate |= KC_ALT;
[2]225}
226
[231]227void EmphasizeButton(HWND hwnd, BOOL on)
228{
[397]229 HPS hps = DrgGetPS(hwnd);
[2]230
[397]231 // fixme to complain?
232 if (hps) {
233 POINTL ptl;
234 SWP swp;
[2]235
[397]236 WinQueryWindowPos(hwnd, &swp);
237 ptl.x = 1;
238 ptl.y = 1;
239 GpiMove(hps, &ptl);
[787]240 GpiSetColor(hps, on ? CLR_BLACK : CLR_PALEGRAY);
[397]241 ptl.x = swp.cx - 2;
242 ptl.y = swp.cy - 2;
243 GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
244 DrgReleasePS(hps);
[551]245 if (remove) //fixme always true
[397]246 WinInvalidateRect(hwnd, NULL, FALSE);
247 }
[2]248}
249
[231]250void DrawTargetEmphasis(HWND hwnd, BOOL on)
251{
[397]252 HPS hps = DrgGetPS(WinQueryWindow(hwnd, QW_PARENT));
[551]253
[397]254 if (hps) {
[787]255 BoxWindow(hwnd, hps, on ? CLR_BLACK : CLR_PALEGRAY);
[397]256 DrgReleasePS(hps);
257 }
[2]258}
259
[231]260void BoxWindow(HWND hwnd, HPS hps, LONG color)
261{
[397]262 POINTL ptl;
263 SWP swp;
264 BOOL releaseme = FALSE;
[2]265
[397]266 if (!hps) {
267 hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
268 releaseme = TRUE;
269 }
270 if (hps && WinQueryWindowPos(hwnd, &swp)) {
271 ptl.x = swp.x - 2;
272 ptl.y = swp.y - 2;
273 GpiMove(hps, &ptl);
274 GpiSetColor(hps, color);
275 ptl.x = swp.x + swp.cx + 1;
276 ptl.y = swp.y + swp.cy + 1;
277 GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
278 }
279 if (releaseme && hps)
280 WinReleasePS(hps);
[2]281}
282
[231]283void PaintSTextWindow(HWND hwnd, HPS hps)
284{
[397]285 /*
286 * paint a text window such that the rightmost part of the text is
287 * always visible even if the text length exceeds the length of the
288 * window -- otherwise, paint the window so that it is left-justified
289 * and vertically centered.
290 */
[2]291
[397]292 char *s = NULL;
293 long len;
294 POINTL aptl[TXTBOX_COUNT], ptl;
295 RECTL rcl;
296 char *p;
297 BOOL releaseme = FALSE;
[2]298
[397]299 if (!hps) {
300 releaseme = TRUE;
301 hps = WinGetPS(hwnd);
302 }
303 if (hps) {
304 WinQueryWindowRect(hwnd, &rcl);
305 WinFillRect(hps, &rcl, CLR_PALEGRAY);
306 len = WinQueryWindowTextLength(hwnd);
307 if (len)
308 s = xmalloc(len + 1, pszSrcFile, __LINE__);
309 if (s) {
310 *s = 0;
311 WinQueryWindowText(hwnd, CCHMAXPATH, s);
312 if (*s) {
[1159]313 rcl.xRight -= 3;
314 p = s;
315 GpiQueryTextBox(hps, 3, "...", TXTBOX_COUNT, aptl);
316 len = aptl[TXTBOX_TOPRIGHT].x;
317 do {
318 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
319 if (aptl[TXTBOX_TOPRIGHT].x > (rcl.xRight - (p != s ? len : 0)))
320 p++;
321 else
322 break;
323 }
324 while (*p);
325 if (*p) {
326 GpiSetMix(hps, FM_OVERPAINT);
327 GpiSetColor(hps, CLR_BLACK);
328 ptl.x = 3;
329 ptl.y = ((rcl.yTop / 2) -
330 ((aptl[TXTBOX_TOPRIGHT].y +
331 aptl[TXTBOX_BOTTOMLEFT].y) / 2));
332 GpiMove(hps, &ptl);
333 if (p != s)
334 GpiCharString(hps, 3, "...");
335 GpiCharString(hps, strlen(p), p);
336 }
[397]337 }
[1039]338 free(s);
[231]339 }
[397]340 if (releaseme)
341 WinReleasePS(hps);
342 }
[2]343}
344
[231]345VOID PaintRecessedWindow(HWND hwnd, HPS hps, BOOL outtie, BOOL dbl)
346{
[397]347 /*
348 * paint a recessed box around the window
349 * two pixels width required around window for painting...
350 */
351 BOOL releaseme = FALSE;
[2]352
[397]353 if (!hps) {
354 hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
355 releaseme = TRUE;
356 }
357 if (hps) {
[2]358
[397]359 POINTL ptl;
360 SWP swp;
[2]361
[397]362 WinQueryWindowPos(hwnd, &swp);
363 ptl.x = swp.x - 1;
364 ptl.y = swp.y - 1;
365 GpiMove(hps, &ptl);
366 if (!outtie)
367 GpiSetColor(hps, CLR_WHITE);
368 else
369 GpiSetColor(hps, CLR_DARKGRAY);
370 ptl.x = swp.x + swp.cx;
371 GpiLine(hps, &ptl);
372 ptl.y = swp.y + swp.cy;
373 GpiLine(hps, &ptl);
374 if (dbl) {
375 ptl.x = swp.x - 2;
376 ptl.y = swp.y - 2;
377 GpiMove(hps, &ptl);
378 ptl.x = swp.x + swp.cx + 1;
379 GpiLine(hps, &ptl);
380 ptl.y = swp.y + swp.cy + 1;
381 GpiLine(hps, &ptl);
[2]382 }
[397]383 if (!outtie)
384 GpiSetColor(hps, CLR_DARKGRAY);
385 else
386 GpiSetColor(hps, CLR_WHITE);
387 if (dbl) {
388 ptl.x = swp.x - 2;
389 GpiLine(hps, &ptl);
390 ptl.y = swp.y - 2;
391 GpiLine(hps, &ptl);
392 ptl.x = swp.x + swp.cx;
393 ptl.y = swp.y + swp.cy;
394 GpiMove(hps, &ptl);
395 }
396 ptl.x = swp.x - 1;
397 GpiLine(hps, &ptl);
398 ptl.y = swp.y - 1;
399 GpiLine(hps, &ptl);
400 GpiSetColor(hps, CLR_PALEGRAY);
401 ptl.x = swp.x - (2 + (dbl != FALSE));
402 ptl.y = swp.y - (2 + (dbl != FALSE));
403 GpiMove(hps, &ptl);
404 ptl.x = swp.x + swp.cx + (1 + (dbl != FALSE));
405 GpiLine(hps, &ptl);
406 ptl.y = swp.y + swp.cy + (1 + (dbl != FALSE));
407 GpiLine(hps, &ptl);
408 ptl.x = swp.x - (2 + (dbl != FALSE));
409 GpiLine(hps, &ptl);
410 ptl.y = swp.y - (2 + (dbl != FALSE));
411 GpiLine(hps, &ptl);
412 if (releaseme)
413 WinReleasePS(hps);
414 }
[2]415}
416
[231]417BOOL AdjustCnrColVis(HWND hwndCnr, CHAR * title, BOOL visible, BOOL toggle)
418{
[551]419 PFIELDINFO pfi = (PFIELDINFO) WinSendMsg(hwndCnr,
[1159]420 CM_QUERYDETAILFIELDINFO,
421 MPVOID, MPFROMSHORT(CMA_FIRST));
[551]422
[397]423 while (pfi) {
424 if (!strcmp(pfi->pTitleData, title)) {
425 if (toggle) {
[1159]426 if (pfi->flData & CFA_INVISIBLE)
427 pfi->flData &= (~CFA_INVISIBLE);
428 else
429 pfi->flData |= CFA_INVISIBLE;
430 return !(pfi->flData & CFA_INVISIBLE);
[397]431 }
432 else {
[1159]433 if (visible)
434 pfi->flData &= (~CFA_INVISIBLE);
435 else
436 pfi->flData |= CFA_INVISIBLE;
[397]437 }
438 return TRUE;
[2]439 }
[397]440 pfi = pfi->pNextFieldInfo;
441 }
442 return FALSE;
[2]443}
444
[231]445BOOL AdjustCnrColRO(HWND hwndCnr, CHAR * title, BOOL readonly, BOOL toggle)
[70]446{
[551]447 PFIELDINFO pfi = (PFIELDINFO) WinSendMsg(hwndCnr,
[1159]448 CM_QUERYDETAILFIELDINFO,
449 MPVOID, MPFROMSHORT(CMA_FIRST));
[551]450
[397]451 while (pfi) {
452 if (!strcmp(pfi->pTitleData, title)) {
453 if (toggle) {
[1159]454 if (pfi->flData & CFA_FIREADONLY)
455 pfi->flData &= (~CFA_FIREADONLY);
456 else
457 pfi->flData |= CFA_FIREADONLY;
458 return (pfi->flData & CFA_FIREADONLY);
[397]459 }
460 else {
[1159]461 if (!readonly)
462 pfi->flData &= (~CFA_FIREADONLY);
463 else
464 pfi->flData |= CFA_FIREADONLY;
[397]465 }
466 return TRUE;
[2]467 }
[397]468 pfi = pfi->pNextFieldInfo;
469 }
470 return FALSE;
[2]471}
472
[1065]473VOID AdjustCnrColsForFSType(HWND hwndCnr, CHAR * directory, DETAILS_SETTINGS * pds)
[231]474{
[397]475 CHAR FileSystem[CCHMAXPATH];
476 INT x;
477 BOOL hasCreateDT;
478 BOOL hasAccessDT;
479 BOOL hasLongNames;
[2]480
[397]481 if (!directory || !*directory)
482 return;
483 x = CheckDrive(toupper(*directory), FileSystem, NULL);
484 if (x != -1) {
485 if (!stricmp(FileSystem, HPFS) ||
[1159]486 !stricmp(FileSystem, JFS) ||
487 !stricmp(FileSystem, FAT32) ||
488 !stricmp(FileSystem, RAMFS) ||
489 !stricmp(FileSystem, NDFS32) ||
490 !stricmp(FileSystem, NTFS) ||
491 !stricmp(FileSystem, HPFS386)) {
[397]492 hasCreateDT = TRUE;
493 hasAccessDT = TRUE;
494 hasLongNames = TRUE;
[2]495 }
[552]496 else if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS)) {
[397]497 hasCreateDT = TRUE;
498 hasAccessDT = FALSE;
499 hasLongNames = FALSE;
[2]500 }
[397]501 else {
502 // Assume FAT
503 hasCreateDT = FALSE;
504 hasAccessDT = FALSE;
505 hasLongNames = FALSE;
506 }
507 }
508 else {
509 // Assume FAT
510 hasCreateDT = FALSE;
511 hasAccessDT = FALSE;
512 hasLongNames = FALSE;
513 }
[787]514 AdjustCnrColVis(hwndCnr,
[1159]515 GetPString(IDS_LADATE),
516 pds->detailsladate ? hasAccessDT : FALSE,
517 FALSE);
[787]518 AdjustCnrColVis(hwndCnr,
[1159]519 GetPString(IDS_LATIME),
520 pds->detailslatime ? hasAccessDT : FALSE,
521 FALSE);
[787]522 AdjustCnrColVis(hwndCnr,
[1159]523 GetPString(IDS_CRDATE),
524 pds->detailscrdate ? hasCreateDT : FALSE,
525 FALSE);
[787]526 AdjustCnrColVis(hwndCnr,
[1159]527 GetPString(IDS_CRTIME),
528 pds->detailscrtime ? hasCreateDT : FALSE,
529 FALSE);
[787]530 AdjustCnrColVis(hwndCnr,
[1159]531 GetPString(IDS_LNAME),
532 pds->detailslongname ? hasLongNames : FALSE,
533 FALSE);
[397]534 WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
[2]535}
536
[1065]537VOID AdjustCnrColsForPref(HWND hwndCnr, CHAR * directory, DETAILS_SETTINGS * pds,
[1159]538 BOOL compare)
[231]539{
[2]540
[751]541 AdjustCnrColVis(hwndCnr,
[1159]542 compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ),
543 pds->detailssubject,
544 FALSE);
[751]545
[1065]546 AdjustCnrColVis(hwndCnr, GetPString(IDS_ATTR), pds->detailsattr, FALSE);
547 AdjustCnrColVis(hwndCnr, GetPString(IDS_ICON), pds->detailsicon, FALSE);
548 AdjustCnrColVis(hwndCnr, GetPString(IDS_LWDATE), pds->detailslwdate, FALSE);
549 AdjustCnrColVis(hwndCnr, GetPString(IDS_LWTIME), pds->detailslwtime, FALSE);
550 AdjustCnrColVis(hwndCnr, GetPString(IDS_EA), pds->detailsea, FALSE);
551 AdjustCnrColVis(hwndCnr, GetPString(IDS_SIZE), pds->detailssize, FALSE);
[751]552
[397]553 if (!directory) {
[1065]554 AdjustCnrColVis(hwndCnr, GetPString(IDS_LADATE), pds->detailsladate, FALSE);
555 AdjustCnrColVis(hwndCnr, GetPString(IDS_LATIME), pds->detailslatime, FALSE);
556 AdjustCnrColVis(hwndCnr, GetPString(IDS_CRDATE), pds->detailscrdate, FALSE);
557 AdjustCnrColVis(hwndCnr, GetPString(IDS_CRTIME), pds->detailscrtime, FALSE);
558 AdjustCnrColVis(hwndCnr, GetPString(IDS_LNAME), pds->detailslongname, FALSE);
[397]559 WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
560 }
561 else
[1065]562 AdjustCnrColsForFSType(hwndCnr, directory, pds);
[2]563}
564
[751]565BOOL SetCnrCols(HWND hwndCnr, BOOL isCompCnr)
[231]566{
[397]567 BOOL fSuccess = TRUE;
568 PFIELDINFO pfi, pfiLastLeftCol, pfiIconCol;
[2]569
[397]570 // Allocate storage for container column data
[2]571
[397]572 pfi = WinSendMsg(hwndCnr, CM_ALLOCDETAILFIELDINFO,
[1159]573 MPFROMLONG(CONTAINER_COLUMNS), NULL);
[2]574
[751]575 if (!pfi) {
576 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCDETAILFIELDINFO");
577 fSuccess = FALSE;
578 }
579 else {
[2]580
[397]581 PFIELDINFO pfiFirst;
582 FIELDINFOINSERT fii;
[2]583
[397]584 // Store original value of pfi so we won't lose it when it changes.
585 // This will be needed on the CM_INSERTDETAILFIELDINFO message.
[2]586
[397]587 pfiFirst = pfi;
[2]588
[397]589 // Fill in column information for the icon column
[2]590
[397]591 pfi->flData = CFA_BITMAPORICON | CFA_CENTER | CFA_FIREADONLY;
592 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
593 pfi->pTitleData = GetPString(IDS_ICON);
594 pfi->offStruct = FIELDOFFSET(MINIRECORDCORE, hptrIcon);
[2]595
[397]596 pfiIconCol = pfi;
[2]597
[397]598 // Fill in column information for the file name. Note that we are
[737]599 // using the pszDisplayName variable rather than pszFileName. We do this
600 // because the container does not always display the full path file name.
[2]601
[397]602 pfi = pfi->pNextFieldInfo;
[856]603
[397]604 pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
[792]605 pfi->flTitle = CFA_LEFT;
[397]606 pfi->pTitleData = GetPString(IDS_FILENAME);
[737]607 pfi->offStruct = FIELDOFFSET(CNRITEM, pszDisplayName);
[2]608
[397]609 // Fill in column information for the longname.
[2]610
[397]611 pfi = pfi->pNextFieldInfo;
612 pfi->flData = CFA_STRING | CFA_LEFT;
[792]613 pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
[397]614 pfi->pTitleData = GetPString(IDS_LNAME);
[762]615 pfi->offStruct = FIELDOFFSET(CNRITEM, pszLongName);
[2]616
[397]617 // Fill in column info for subjects
[2]618
[1065]619 if (dsDirCnrDefault.fSubjectInLeftPane) {
[796]620 pfi = pfi->pNextFieldInfo;
621 pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
622 if (isCompCnr)
[1159]623 pfi->flData |= CFA_FIREADONLY;
[796]624 pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
625 pfi->pTitleData = isCompCnr ? GetPString(IDS_STATUS) :
[1159]626 GetPString(IDS_SUBJ);
[796]627 pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject);
[1065]628 pfi->cxWidth = dsDirCnrDefault.SubjectDisplayWidth;
[2]629
[796]630 // Store the current pfi value as that will be used to indicate the
631 // last column in the lefthand container window (we have a splitbar)
[792]632
[796]633 pfiLastLeftCol = pfi;
634 }
635 else {
636 // Store the current pfi value as that will be used to indicate the
637 // last column in the lefthand container window (we have a splitbar)
[792]638
[796]639 pfiLastLeftCol = pfi;
640 pfi = pfi->pNextFieldInfo;
641 pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
642 if (isCompCnr)
[1159]643 pfi->flData |= CFA_FIREADONLY;
[796]644 pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
645 pfi->pTitleData = isCompCnr ? GetPString(IDS_STATUS) :
[1159]646 GetPString(IDS_SUBJ);
[796]647 pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject);
[1065]648 pfi->cxWidth = dsDirCnrDefault.SubjectDisplayWidth;
[796]649 }
650
[397]651 // Fill in column information for the file size
[2]652
653
[859]654 pfi = pfi->pNextFieldInfo;
655 pfi->flData = CFA_STRING | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
656 pfi->flTitle = CFA_CENTER;
657 pfi->pTitleData = GetPString(IDS_SIZE);
658 pfi->offStruct = FIELDOFFSET(CNRITEM, pszFmtFileSize);
659
660
[397]661 // Fill in the column information for the file's ea size
[2]662
[397]663 pfi = pfi->pNextFieldInfo;
664 pfi->flData = CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
665 pfi->flTitle = CFA_CENTER;
666 pfi->pTitleData = GetPString(IDS_EA);
667 pfi->offStruct = FIELDOFFSET(CNRITEM, easize);
[2]668
[397]669 // Fill in the column information for the file attribute
[2]670
[397]671 pfi = pfi->pNextFieldInfo;
672 pfi->flData = CFA_STRING | CFA_CENTER | CFA_SEPARATOR | CFA_FIREADONLY;
673 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
674 pfi->pTitleData = GetPString(IDS_ATTR);
675 pfi->offStruct = FIELDOFFSET(CNRITEM, pszDispAttr);
[2]676
[397]677 // Fill in column information for last write file date
[2]678
[397]679 pfi = pfi->pNextFieldInfo;
680 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
681 pfi->flTitle = CFA_CENTER;
682 pfi->pTitleData = GetPString(IDS_LWDATE);
683 pfi->offStruct = FIELDOFFSET(CNRITEM, date);
[2]684
[397]685 // Fill in column information for the last write file time
[2]686
[397]687 pfi = pfi->pNextFieldInfo;
688 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
689 pfi->flTitle = CFA_CENTER;
690 pfi->pTitleData = GetPString(IDS_LWTIME);
691 pfi->offStruct = FIELDOFFSET(CNRITEM, time);
[2]692
[397]693 // Fill in column information for last access file date
[2]694
[397]695 pfi = pfi->pNextFieldInfo;
696 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
697 pfi->flTitle = CFA_CENTER;
698 pfi->pTitleData = GetPString(IDS_LADATE);
699 pfi->offStruct = FIELDOFFSET(CNRITEM, ladate);
[2]700
[397]701 // Fill in column information for the last access file time
[2]702
[397]703 pfi = pfi->pNextFieldInfo;
704 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
705 pfi->flTitle = CFA_CENTER;
706 pfi->pTitleData = GetPString(IDS_LATIME);
707 pfi->offStruct = FIELDOFFSET(CNRITEM, latime);
[2]708
[397]709 // Fill in column information for create file date
[2]710
[397]711 pfi = pfi->pNextFieldInfo;
712 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
713 pfi->flTitle = CFA_CENTER;
714 pfi->pTitleData = GetPString(IDS_CRDATE);
715 pfi->offStruct = FIELDOFFSET(CNRITEM, crdate);
[2]716
[397]717 // Fill in column information for the create file time
[2]718
[397]719 pfi = pfi->pNextFieldInfo;
720 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_FIREADONLY;
721 pfi->flTitle = CFA_CENTER;
722 pfi->pTitleData = GetPString(IDS_CRTIME);
723 pfi->offStruct = FIELDOFFSET(CNRITEM, crtime);
[2]724
[397]725 // Use the CM_INSERTDETAILFIELDINFO message to tell the container
726 // all the column information it needs to function properly. Place
727 // this column info first in the column list and update the display
728 // after they are inserted (fInvalidateFieldInfo = TRUE)
[2]729
[397]730 (void)memset(&fii, 0, sizeof(FIELDINFOINSERT));
[2]731
[397]732 fii.cb = sizeof(FIELDINFOINSERT);
733 fii.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
734 fii.cFieldInfoInsert = (SHORT) CONTAINER_COLUMNS;
735 fii.fInvalidateFieldInfo = TRUE;
[2]736
[397]737 if (!WinSendMsg(hwndCnr, CM_INSERTDETAILFIELDINFO, MPFROMP(pfiFirst),
[1159]738 MPFROMP(&fii))) {
[751]739 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_INSERTDETAILFIELDINFO");
[397]740 fSuccess = FALSE;
[751]741 }
[397]742 }
[2]743
[397]744 if (fSuccess) {
[2]745
[397]746 CNRINFO cnri;
747 ULONG size;
[2]748
[397]749 // Tell the container about the splitbar and where it goes
[2]750
[397]751 cnri.cb = sizeof(CNRINFO);
752 cnri.pFieldInfoLast = pfiLastLeftCol;
753 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
754 cnri.pFieldInfoObject = pfiIconCol;
755 size = sizeof(LONG);
756 PrfQueryProfileData(fmprof,
[1159]757 appname, "CnrSplitBar", &cnri.xVertSplitbar, &size);
[397]758 if (cnri.xVertSplitbar <= 0)
759 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
760 if (!WinSendMsg(hwndCnr, CM_SETCNRINFO, MPFROMP(&cnri),
[1159]761 MPFROMLONG(CMA_PFIELDINFOLAST | CMA_PFIELDINFOOBJECT |
762 CMA_XVERTSPLITBAR))) {
[751]763 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_SETCNRINFO");
[397]764 fSuccess = FALSE;
[751]765 }
[397]766 }
[2]767
[397]768 return fSuccess;
[2]769}
770
[231]771MRESULT CnrDirectEdit(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[161]772{
[397]773 switch (SHORT2FROMMP(mp1)) {
774 case CN_BEGINEDIT:
775 if (mp2) {
776 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
777 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
[2]778
[397]779 if (pci &&
[1159]780 (INT) pci != -1 &&
781 !IsRoot(pci->pszFileName) &&
782 !(pci->flags & RECFLAGS_ENV) && !(pci->flags & RECFLAGS_UNDERENV)) {
783 if (!pfi || pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName)) {
784 PostMsg(hwnd, UM_FIXEDITNAME, MPFROMP(pci->pszFileName), MPVOID);
785 }
786 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, pszSubject))
787 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(1048), MPVOID);
788 else
789 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
[397]790 }
791 else
[1159]792 PostMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
[397]793 }
794 break;
[2]795
[397]796 case CN_REALLOCPSZ:
797 if (mp2) {
798 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
799 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
[689]800 CHAR szData[CCHMAXPATH], testname[CCHMAXPATH];
[397]801 HWND hwndMLE = WinWindowFromID(hwnd, CID_MLE);
[1354]802 BOOL fResetVerify = FALSE;
[2]803
[730]804 if (pci && (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
[1159]805 if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszSubject)) {
[2]806
[1159]807 APIRET rc;
808 EAOP2 eaop;
809 PFEA2LIST pfealist = NULL;
810 CHAR szSubject[1048];
811 ULONG ealen;
812 USHORT len;
813 CHAR *eaval;
814 LONG retlen;
815 PSZ psz;
[2]816
[1159]817 retlen = WinQueryWindowText(hwndMLE, sizeof(szSubject), szSubject);
818 szSubject[retlen + 1] = 0;
819 bstrip(szSubject);
820 if (pci->pszSubject != NullStr) {
821 if (retlen == 0) {
822 psz = pci->pszSubject;
823 pci->pszSubject = NullStr;
824 xfree(psz, pszSrcFile, __LINE__);
825 }
826 else
827 pci->pszSubject = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__);
828 }
829 else {
830 pci->pszSubject = xmalloc(retlen + 1, pszSrcFile, __LINE__);
831 if (!pci->pszSubject)
832 return FALSE;
833 }
834 len = strlen(szSubject);
835 if (len)
836 ealen = sizeof(FEA2LIST) + 9 + len + 4;
837 else
838 ealen = sizeof(FEALIST) + 9;
839 rc = DosAllocMem((PPVOID) & pfealist, ealen + 64,
840 OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE);
841 if (rc)
842 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile,
843 __LINE__, GetPString(IDS_OUTOFMEMORY));
844 else {
845 memset(pfealist, 0, ealen + 1);
846 pfealist->cbList = ealen;
847 pfealist->list[0].oNextEntryOffset = 0;
848 pfealist->list[0].fEA = 0;
849 pfealist->list[0].cbName = 8;
850 strcpy(pfealist->list[0].szName, SUBJECT);
851 if (len) {
852 eaval = pfealist->list[0].szName + 9;
853 *(USHORT *) eaval = (USHORT) EAT_ASCII;
854 eaval += sizeof(USHORT);
855 *(USHORT *) eaval = (USHORT) len;
856 eaval += sizeof(USHORT);
857 memcpy(eaval, szSubject, len);
858 pfealist->list[0].cbValue = len + (sizeof(USHORT) * 2);
859 }
860 else
861 pfealist->list[0].cbValue = 0;
862 eaop.fpGEA2List = (PGEA2LIST) 0;
863 eaop.fpFEA2List = pfealist;
864 eaop.oError = 0;
865 rc = xDosSetPathInfo(pci->pszFileName, FIL_QUERYEASIZE,
866 &eaop, sizeof(eaop), DSPI_WRTTHRU);
867 DosFreeMem(pfealist);
868 if (rc)
869 return FALSE;
870 }
871 return (MRESULT) TRUE;
872 }
873 else if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszLongName)) {
[2]874
[1159]875 CHAR longname[CCHMAXPATHCOMP];
876 LONG retlen;
877 PSZ psz;
[2]878
[1159]879 *longname = 0;
880 retlen = WinQueryWindowText(hwndMLE, sizeof(longname), longname);
881 longname[retlen + 1] = 0;
882 chop_at_crnl(longname);
883 bstrip(longname);
884 WinSetWindowText(hwndMLE, longname);
885 if (pci->pszLongName != NullStr) {
886 if (retlen == 0) {
887 psz = pci->pszLongName;
888 pci->pszLongName = NullStr;
889 xfree(psz, pszSrcFile, __LINE__);
890 }
891 else
892 pci->pszLongName = xrealloc(pci->pszLongName, retlen + 1, pszSrcFile, __LINE__);
893 }
894 else {
895 pci->pszLongName = xmalloc(retlen + 1, pszSrcFile, __LINE__);
896 if (!pci->pszLongName)
897 return FALSE;
898 }
899 return (MRESULT) WriteLongName(pci->pszFileName, longname);
900 }
901 else {
902 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
903 if (strchr(szData, '?') ||
904 strchr(szData, '*') || IsRoot(pci->pszFileName))
905 return (MRESULT) FALSE;
906 /* If the text changed, rename the file system object. */
907 chop_at_crnl(szData);
908 bstrip(szData);
909 if (!IsFullName(szData))
910 Runtime_Error(pszSrcFile, __LINE__, "bad name");
911 else {
912 if (DosQueryPathInfo(szData,
913 FIL_QUERYFULLNAME,
914 testname, sizeof(testname)))
915 return FALSE;
916 if (DosQueryPathInfo(pci->pszFileName,
917 FIL_QUERYFULLNAME,
918 szData,
919 sizeof(szData)))
920 {
921 pci->pszFileName = xrealloc(pci->pszFileName, sizeof(szData), pszSrcFile, __LINE__);
922 strcpy(szData, pci->pszFileName);
923 }
924 WinSetWindowText(hwndMLE, szData);
925 if (strcmp(szData, testname)) {
926 if (stricmp(szData, testname) && IsFile(testname) != -1) {
927 DosBeep(50, 100); /* exists; disallow */
928 return (MRESULT) FALSE;
929 }
[1354]930 if (fVerify && (driveflags[toupper(*szData) - 'A'] & DRIVE_WRITEVERIFYOFF ||
931 driveflags[toupper(*testname) - 'A'] & DRIVE_WRITEVERIFYOFF)) {
932 DosSetVerify(FALSE);
933 fResetVerify = TRUE;
934 }
[1159]935 if (docopyf(MOVE, szData, "%s", testname))
936 Runtime_Error(pszSrcFile, __LINE__, "docopyf");
937 else {
938 CHAR *filename;
[2]939
[1159]940 filename = xstrdup(testname, pszSrcFile, __LINE__);
941 if (filename) {
942 if (!PostMsg(hwnd,
943 UM_FIXEDITNAME, MPVOID, MPFROMP(filename)))
944 free(filename);
945 }
946 if (stricmp(testname, pci->pszFileName)) {
947 PostMsg(hwnd, UM_FIXEDITNAME, MPFROMLONG(-1), MPFROMP(pci));
948 filename = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
949 if (filename) {
950 if (!PostMsg(hwnd,
951 UM_FIXEDITNAME, MPVOID, MPFROMP(filename)))
952 free(filename);
953 }
954 }
955 }
[1354]956 if (fResetVerify) {
957 DosSetVerify(fVerify);
958 fResetVerify = FALSE;
959 }
[1159]960 }
961 }
962 }
[397]963 }
964 }
965 return FALSE;
[2]966
[397]967 case CN_ENDEDIT:
968 if (mp2) {
969 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
970 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
[2]971
[730]972 if (pci && (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
[1159]973 WinSendMsg(hwnd,
974 CM_INVALIDATERECORD,
975 MPFROMP(&pci),
976 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
977 if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName))
978 PostMsg(hwnd, UM_SORTRECORD, MPVOID, MPVOID);
[397]979 }
980 else {
[1159]981 USHORT cmd = 0;
[2]982
[1159]983 if (!pfi || pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName))
984 cmd = IDM_SORTSMARTNAME;
985 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, cbFile))
986 cmd = IDM_SORTSIZE;
987 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, easize))
988 cmd = IDM_SORTEASIZE;
989 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, date))
990 cmd = IDM_SORTLWDATE;
991 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, time))
992 cmd = IDM_SORTLWDATE;
993 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, ladate))
994 cmd = IDM_SORTLADATE;
995 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, latime))
996 cmd = IDM_SORTLADATE;
997 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, crdate))
998 cmd = IDM_SORTCRDATE;
999 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, crtime))
1000 cmd = IDM_SORTCRDATE;
1001 if (cmd)
1002 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
[397]1003 }
[231]1004 }
[397]1005 break;
1006 }
1007 return (MRESULT) - 1;
[2]1008}
1009
[231]1010BOOL SetMenuCheck(HWND hwndMenu, USHORT id, BOOL * bool, BOOL toggle,
[1159]1011 CHAR * savename)
[231]1012{
[397]1013 if (toggle) {
[787]1014 *bool = *bool ? FALSE : TRUE;
[397]1015 if (savename && *savename)
1016 PrfWriteProfileData(fmprof, appname, savename, bool, sizeof(BOOL));
1017 }
1018 WinSendMsg(hwndMenu, MM_SETITEMATTR,
[1159]1019 MPFROM2SHORT(id, 1),
1020 MPFROM2SHORT(MIA_CHECKED, (*bool ? MIA_CHECKED : 0)));
[397]1021 return *bool;
[2]1022}
1023
[468]1024//== disable_menuitem() disable or enable_menuitem ==
1025
1026VOID disable_menuitem(HWND hwndMenu, USHORT id, BOOL disable)
[231]1027{
[397]1028 WinSendMsg(hwndMenu, MM_SETITEMATTR,
[1159]1029 MPFROM2SHORT(id, TRUE),
1030 MPFROM2SHORT(MIA_DISABLED, (disable ? MIA_DISABLED : 0)));
[2]1031}
1032
[451]1033//== ViewHelp() invoke view.exe, return TRUE if OK ==
1034
[231]1035BOOL ViewHelp(CHAR * filename)
1036{
[397]1037 CHAR s[CCHMAXPATH + 81];
[891]1038 CHAR szQuotedFileName[CCHMAXPATH];
[397]1039 FILE *fp;
1040 INT ret = -1;
[2]1041
[397]1042 fp = _fsopen(filename, "rb", SH_DENYNO);
1043 if (fp) {
1044 *s = 0;
1045 fread(s, 1, 3, fp);
1046 if (*s != 'H' || s[1] != 'S' || s[2] != 'P') {
1047 fclose(fp);
1048 return FALSE;
[2]1049 }
[397]1050 fclose(fp);
[888]1051 ret = runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
[1159]1052 NULL, NULL,
1053 "VIEW.EXE \"%s\"",
1054 BldQuotedFileName(szQuotedFileName, filename));
[397]1055 }
[2]1056
[397]1057 return (ret != -1);
[2]1058}
1059
[451]1060//== ExecFile() run file, return 1 if OK 0 if skipped -1 if can't run ==
1061
[231]1062INT ExecFile(HWND hwnd, CHAR * filename)
1063{
[397]1064 EXECARGS ex;
[989]1065 CHAR path[CCHMAXPATH], *p;
1066 PSZ pszCmdLine;
[397]1067 APIRET ret;
1068 static INT lastflags = 0;
[2]1069
[397]1070 strcpy(path, filename);
1071 p = strrchr(path, '\\');
1072 if (!p)
1073 p = strrchr(path, ':');
1074 if (p) {
1075 if (*p == ':') {
1076 p++;
1077 *p = '\\';
1078 p++;
[2]1079 }
[397]1080 *p = 0;
1081 }
1082 else
1083 *path = 0;
[989]1084 pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1085 if (pszCmdLine) {
1086 BldQuotedFileName(pszCmdLine, filename);
1087 memset(&ex, 0, sizeof(ex));
1088 ex.flags = lastflags;
1089 ex.commandline = pszCmdLine;
1090 *ex.path = 0;
1091 *ex.environment = 0;
1092 ret = WinDlgBox(HWND_DESKTOP, hwnd, CmdLineDlgProc, FM3ModHandle,
[1159]1093 EXEC_FRAME, &ex);
[989]1094 if (ret == 1) {
1095 lastflags = ex.flags;
1096 return runemf2(ex.flags, hwnd, pszSrcFile, __LINE__, path,
[1159]1097 *ex.environment ? ex.environment : NULL,
1098 "%s", pszCmdLine) != -1;
[989]1099 }
1100 else if (ret != 0)
1101 return -1;
[1039]1102 free(pszCmdLine);
[397]1103 }
1104 return 0;
[2]1105}
1106
[1065]1107VOID SetDetailsSwitches(HWND hwnd, DETAILS_SETTINGS * pds)
[231]1108{
[1065]1109 WinCheckMenuItem(hwnd, IDM_SHOWLNAMES, pds->detailslongname);
1110 WinCheckMenuItem(hwnd, IDM_SHOWSUBJECT, pds->detailssubject);
1111 WinCheckMenuItem(hwnd, IDM_SHOWEAS, pds->detailsea);
1112 WinCheckMenuItem(hwnd, IDM_SHOWSIZE, pds->detailssize);
1113 WinCheckMenuItem(hwnd, IDM_SHOWICON, pds->detailsicon);
1114 WinCheckMenuItem(hwnd, IDM_SHOWLWDATE, pds->detailslwdate);
1115 WinCheckMenuItem(hwnd, IDM_SHOWLWTIME, pds->detailslwtime);
1116 WinCheckMenuItem(hwnd, IDM_SHOWLADATE, pds->detailsladate);
1117 WinCheckMenuItem(hwnd, IDM_SHOWLATIME, pds->detailslatime);
1118 WinCheckMenuItem(hwnd, IDM_SHOWCRDATE, pds->detailscrdate);
1119 WinCheckMenuItem(hwnd, IDM_SHOWCRTIME, pds->detailscrtime);
1120 WinCheckMenuItem(hwnd, IDM_SHOWATTR, pds->detailsattr);
[2]1121}
1122
[231]1123VOID AdjustDetailsSwitches(HWND hwnd, HWND hwndMenu, USHORT cmd,
[1159]1124 CHAR * directory, CHAR * keyroot,
1125 DETAILS_SETTINGS * pds, BOOL compare)
[231]1126{
[397]1127 BOOL *bool = NULL;
[2]1128
[397]1129 switch (cmd) {
1130 case IDM_SHOWLNAMES:
[1065]1131 bool = &pds->detailslongname;
[397]1132 break;
1133 case IDM_SHOWSUBJECT:
[1065]1134 bool = &pds->detailssubject;
[397]1135 break;
1136 case IDM_SHOWEAS:
[1065]1137 bool = &pds->detailsea;
[397]1138 break;
1139 case IDM_SHOWSIZE:
[1065]1140 bool = &pds->detailssize;
[397]1141 break;
1142 case IDM_SHOWICON:
[1065]1143 bool = &pds->detailsicon;
[397]1144 break;
1145 case IDM_SHOWLWDATE:
[1065]1146 bool = &pds->detailslwdate;
[397]1147 break;
1148 case IDM_SHOWLWTIME:
[1065]1149 bool = &pds->detailslwtime;
[397]1150 break;
1151 case IDM_SHOWLADATE:
[1065]1152 bool = &pds->detailsladate;
[397]1153 break;
1154 case IDM_SHOWLATIME:
[1065]1155 bool = &pds->detailslatime;
[397]1156 break;
1157 case IDM_SHOWCRDATE:
[1065]1158 bool = &pds->detailscrdate;
[397]1159 break;
1160 case IDM_SHOWCRTIME:
[1065]1161 bool = &pds->detailscrtime;
[397]1162 break;
1163 case IDM_SHOWATTR:
[1065]1164 bool = &pds->detailsattr;
[397]1165 break;
1166 default:
[231]1167 if (hwndMenu)
[1065]1168 SetDetailsSwitches(hwndMenu, pds);
[397]1169 return;
1170 }
1171 if (bool)
[787]1172 *bool = *bool ? FALSE : TRUE;
[397]1173 if (hwnd)
[1065]1174 AdjustCnrColsForPref(hwnd, directory, pds, compare);
[397]1175 if (hwndMenu)
[1065]1176 SetDetailsSwitches(hwndMenu, pds);
[2]1177}
1178
[921]1179/**
1180 * Set default menu item to invoke for top level conditional cascade menu
1181 * @param def is default menu id (i.e. IDM_...)
1182 */
1183
[231]1184VOID SetConditionalCascade(HWND hwndMenu, USHORT id, USHORT def)
1185{
[397]1186 MENUITEM mi;
[2]1187
[397]1188 mi.iPosition = MIT_END;
[921]1189 mi.hItem = 0;
1190 mi.hwndSubMenu = (HWND)0;
[397]1191 mi.afAttribute = 0;
1192 mi.afStyle = MIS_TEXT;
[921]1193 if (WinSendMsg(hwndMenu,
[1159]1194 MM_QUERYITEM,
1195 MPFROM2SHORT(id, TRUE),
1196 MPFROMP(&mi)))
[921]1197 {
[397]1198 WinSetWindowBits(mi.hwndSubMenu, QWL_STYLE, MS_CONDITIONALCASCADE,
[1159]1199 MS_CONDITIONALCASCADE);
[397]1200 WinSendMsg(mi.hwndSubMenu, MM_SETDEFAULTITEMID, MPFROMSHORT(def), MPVOID);
1201 WinCheckMenuItem(mi.hwndSubMenu, def, TRUE);
1202 }
[2]1203}
1204
[231]1205VOID SetSortChecks(HWND hwndMenu, INT sortflags)
1206{
[397]1207 WinCheckMenuItem(hwndMenu, IDM_SORTNONE, FALSE);
1208 WinCheckMenuItem(hwndMenu, IDM_SORTFIRST, FALSE);
1209 WinCheckMenuItem(hwndMenu, IDM_SORTLAST, FALSE);
1210 WinCheckMenuItem(hwndMenu, IDM_SORTSIZE, FALSE);
1211 WinCheckMenuItem(hwndMenu, IDM_SORTEASIZE, FALSE);
1212 WinCheckMenuItem(hwndMenu, IDM_SORTLWDATE, FALSE);
1213 WinCheckMenuItem(hwndMenu, IDM_SORTLADATE, FALSE);
1214 WinCheckMenuItem(hwndMenu, IDM_SORTCRDATE, FALSE);
1215 WinCheckMenuItem(hwndMenu, IDM_SORTFILENAME, FALSE);
1216 WinCheckMenuItem(hwndMenu, IDM_SORTNAME, FALSE);
1217 WinCheckMenuItem(hwndMenu, IDM_SORTSUBJECT, FALSE);
1218 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSFIRST, FALSE);
1219 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSLAST, FALSE);
1220 WinCheckMenuItem(hwndMenu, IDM_SORTREVERSE, FALSE);
1221 if (sortflags & SORT_FIRSTEXTENSION)
1222 WinCheckMenuItem(hwndMenu, IDM_SORTFIRST, TRUE);
1223 else if (sortflags & SORT_LASTEXTENSION)
1224 WinCheckMenuItem(hwndMenu, IDM_SORTLAST, TRUE);
1225 else if (sortflags & SORT_SIZE)
1226 WinCheckMenuItem(hwndMenu, IDM_SORTSIZE, TRUE);
1227 else if (sortflags & SORT_EASIZE)
1228 WinCheckMenuItem(hwndMenu, IDM_SORTEASIZE, TRUE);
1229 else if (sortflags & SORT_LWDATE)
1230 WinCheckMenuItem(hwndMenu, IDM_SORTLWDATE, TRUE);
1231 else if (sortflags & SORT_LADATE)
1232 WinCheckMenuItem(hwndMenu, IDM_SORTLADATE, TRUE);
1233 else if (sortflags & SORT_CRDATE)
1234 WinCheckMenuItem(hwndMenu, IDM_SORTCRDATE, TRUE);
1235 else if (sortflags & SORT_FILENAME)
1236 WinCheckMenuItem(hwndMenu, IDM_SORTFILENAME, TRUE);
1237 else if (sortflags & SORT_NOSORT)
1238 WinCheckMenuItem(hwndMenu, IDM_SORTNONE, TRUE);
1239 else if (sortflags & SORT_SUBJECT)
1240 WinCheckMenuItem(hwndMenu, IDM_SORTSUBJECT, TRUE);
1241 else
1242 WinCheckMenuItem(hwndMenu, IDM_SORTNAME, TRUE);
1243 if (sortflags & SORT_DIRSFIRST)
1244 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSFIRST, TRUE);
1245 else if (sortflags & SORT_DIRSLAST)
1246 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSLAST, TRUE);
1247 if (sortflags & SORT_REVERSE)
1248 WinCheckMenuItem(hwndMenu, IDM_SORTREVERSE, TRUE);
[2]1249}
1250
[231]1251VOID FcloseFile(FILE * fp)
1252{
[397]1253 /* for use by apps that don't use the DLLs runtime library */
1254 fclose(fp);
[2]1255}
1256
[231]1257VOID SetupCommandMenu(HWND hwndMenu, HWND hwndCnr)
1258{
[397]1259 MENUITEM mi, mit;
1260 INT x;
1261 SHORT numitems;
1262 LINKCMDS *info;
[2]1263
[397]1264 if (!cmdloaded)
1265 load_commands();
1266 mi.iPosition = MIT_END;
1267 mi.hwndSubMenu = (HWND) 0;
1268 mi.hItem = 0L;
1269 mi.afAttribute = 0;
1270 mi.afStyle = MIS_TEXT;
1271 memset(&mit, 0, sizeof(MENUITEM));
1272 if (WinQueryWindowUShort(hwndMenu, QWS_ID) == IDM_COMMANDSMENU)
1273 mit.hwndSubMenu = hwndMenu;
1274 else
1275 WinSendMsg(hwndMenu, MM_QUERYITEM,
[1159]1276 MPFROM2SHORT(IDM_COMMANDSMENU, TRUE), MPFROMP(&mit));
[397]1277 if (mit.hwndSubMenu) {
1278 numitems = (SHORT) WinSendMsg(mit.hwndSubMenu, MM_QUERYITEMCOUNT,
[1159]1279 MPVOID, MPVOID);
[397]1280 WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM, MPFROMSHORT(-1), MPVOID);
1281 for (x = 0; x < numitems; x++)
1282 WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM,
[1159]1283 MPFROMSHORT((SHORT) (x + IDM_COMMANDSTART)), MPVOID);
[397]1284 if (hwndCnr && cmdhead) {
1285 x = 0;
1286 info = cmdhead;
1287 while (info) {
[2]1288
[1159]1289 CHAR s[CCHMAXPATH + 24];
[2]1290
[1159]1291 sprintf(s,
1292 "%s%s%s",
1293 info->title,
1294 x < 20 ? "\tCtrl + " : NullStr,
1295 x < 20 && x > 9 ? "Shift + " : NullStr);
1296 if (x < 20)
1297 sprintf(&s[strlen(s)], "%d",
1298 ((x % 10) + 1) == 10 ? 0 : (x % 10) + 1);
1299 mi.id = IDM_COMMANDSTART + x;
1300 mi.afAttribute = (info->flags & ONCE ? MIA_CHECKED : 0) |
1301 (info->flags & PROMPT ? MIA_FRAMED : 0);
1302 mi.afStyle = MIS_TEXT;
1303 if (!(x % 24) && x && info->next)
1304 mi.afStyle |= MIS_BREAK;
1305 WinSendMsg(mit.hwndSubMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(s));
1306 x++;
1307 info = info->next;
[397]1308 }
[2]1309 }
[397]1310 }
[2]1311}
1312
[1065]1313VOID LoadDetailsSwitches(CHAR * keyroot, DETAILS_SETTINGS * pds)
[231]1314{
[397]1315 ULONG size;
1316 CHAR s[CCHMAXPATH], *eos = s;
[2]1317
[997]1318 strcpy(s, keyroot);
1319 strcat(s, ".");
1320 eos = &s[strlen(s)];
[1065]1321 strcpy(eos, "DetailsLongname");
1322 pds->detailslongname = dsDirCnrDefault.detailslongname;
[397]1323 size = sizeof(BOOL);
[1065]1324 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslongname, &size);
[1030]1325 strcpy(eos, "DetailsSubject");
[1065]1326 pds->detailssubject = dsDirCnrDefault.detailssubject;
[397]1327 size = sizeof(BOOL);
[1065]1328 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailssubject, &size);
[1030]1329 strcpy(eos, "DetailsEA");
[1065]1330 pds->detailsea = dsDirCnrDefault.detailsea;
[397]1331 size = sizeof(BOOL);
[1065]1332 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsea, &size);
[1030]1333 strcpy(eos, "DetailsSize");
[1065]1334 pds->detailssize = dsDirCnrDefault.detailssize;
[397]1335 size = sizeof(BOOL);
[1065]1336 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailssize, &size);
[1030]1337 strcpy(eos, "DetailsIcon");
[1065]1338 pds->detailsicon = dsDirCnrDefault.detailsicon;
[397]1339 size = sizeof(BOOL);
[1065]1340 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsicon, &size);
[1030]1341 strcpy(eos, "DetailsAttr");
[1065]1342 pds->detailsattr = dsDirCnrDefault.detailsattr;
[397]1343 size = sizeof(BOOL);
[1065]1344 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsattr, &size);
[1030]1345 strcpy(eos, "DetailsCRDate");
[1065]1346 pds->detailscrdate = dsDirCnrDefault.detailscrdate;
[397]1347 size = sizeof(BOOL);
[1065]1348 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailscrdate, &size);
[1030]1349 strcpy(eos, "DetailsCRTime");
[1065]1350 pds->detailscrtime = dsDirCnrDefault.detailscrtime;
[397]1351 size = sizeof(BOOL);
[1065]1352 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailscrtime, &size);
[1030]1353 strcpy(eos, "DetailsLWDate");
[1065]1354 pds->detailslwdate = dsDirCnrDefault.detailslwdate;
[397]1355 size = sizeof(BOOL);
[1065]1356 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslwdate, &size);
[1030]1357 strcpy(eos, "DetailsLWTime");
[1065]1358 pds->detailslwtime = dsDirCnrDefault.detailslwtime;
[397]1359 size = sizeof(BOOL);
[1065]1360 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslwtime, &size);
[1030]1361 strcpy(eos, "DetailsLADate");
[1065]1362 pds->detailsladate = dsDirCnrDefault.detailsladate;
[397]1363 size = sizeof(BOOL);
[1065]1364 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsladate, &size);
[1030]1365 strcpy(eos, "DetailsLATime");
[1065]1366 pds->detailslatime = dsDirCnrDefault.detailslatime;
[397]1367 size = sizeof(BOOL);
[1065]1368 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslatime, &size);
[1030]1369 strcpy(eos, "SubjectInLeftPane");
[1065]1370 pds->fSubjectInLeftPane = dsDirCnrDefault.fSubjectInLeftPane;
[922]1371 size = sizeof(BOOL);
[1065]1372 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->fSubjectInLeftPane, &size);
[1030]1373 strcpy(eos, "SubjectLengthMax");
[1065]1374 pds->fSubjectLengthMax = dsDirCnrDefault.fSubjectLengthMax;
[922]1375 size = sizeof(BOOL);
[1065]1376 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->fSubjectLengthMax, &size);
1377 if (pds->fSubjectLengthMax)
1378 pds->SubjectDisplayWidth = 0;
[922]1379 else {
[1065]1380 strcpy(eos, "SubjectDisplayWidth");
1381 pds->SubjectDisplayWidth = dsDirCnrDefault.SubjectDisplayWidth;
1382 size = sizeof(ULONG);
1383 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->SubjectDisplayWidth, &size);
1384 if (pds->SubjectDisplayWidth < 50)
1385 pds->SubjectDisplayWidth = 0;
1386 else if (pds->SubjectDisplayWidth > 1000)
1387 pds->SubjectDisplayWidth = 1000;
[922]1388 }
[2]1389}
1390
[231]1391HWND FindDirCnr(HWND hwndParent)
1392{
[397]1393 HWND found, hwndDir = (HWND) 0;
1394 HENUM henum;
[2]1395
[397]1396 henum = WinBeginEnumWindows(hwndParent);
1397 while ((found = WinGetNextWindow(henum)) != NULLHANDLE) {
1398 hwndDir = WinWindowFromID(found, FID_CLIENT);
1399 if (hwndDir) {
1400 hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
1401 if (hwndDir)
[1159]1402 break;
[397]1403 hwndDir = (HWND) 0;
[2]1404 }
[397]1405 }
1406 WinEndEnumWindows(henum);
[2]1407
[397]1408 return hwndDir;
[2]1409}
1410
[231]1411VOID HeapThread(VOID * dummy)
1412{
[397]1413 ULONG postcount;
1414 APIRET rc;
[2]1415
[397]1416 rc = DosCreateEventSem(NULL, &CompactSem, 0L, FALSE);
1417 if (rc)
1418 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1159]1419 "DosCreateEventSem");
[397]1420 else {
1421 priority_normal();
1422 for (;;) {
1423 if (DosWaitEventSem(CompactSem, SEM_INDEFINITE_WAIT))
[1159]1424 break;
[397]1425 _heapmin();
1426 DosResetEventSem(CompactSem, &postcount);
[2]1427 }
[397]1428 }
[2]1429}
1430
[231]1431VOID FixSwitchList(HWND hwnd, CHAR * text)
1432{
[397]1433 HSWITCH hswitch;
1434 SWCNTRL swctl;
[2]1435
[397]1436 hswitch = WinQuerySwitchHandle(hwnd, 0);
1437 if (hswitch) {
1438 if (!WinQuerySwitchEntry(hswitch, &swctl)) {
1439 strcpy(swctl.szSwtitle, "FM/2");
1440 WinChangeSwitchEntry(hswitch, &swctl);
[2]1441 }
[397]1442 }
[2]1443}
1444
[231]1445VOID QuickPopup(HWND hwnd, DIRCNRDATA * dcd, HWND hwndMenu, USHORT id)
1446{
[397]1447 dcd->hwndLastMenu = hwndMenu;
1448 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
1449 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
[1159]1450 MPFROM2SHORT(TRUE, CRA_SOURCE));
[397]1451 dcd->cnremphasized = TRUE;
1452 }
1453 if (dcd->flWindowAttr & CV_MINI)
1454 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
1455 if (!WinPopupMenu(hwnd, hwnd, dcd->hwndLastMenu,
[1159]1456 8, 8, 0,
1457 PU_HCONSTRAIN | PU_VCONSTRAIN |
1458 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
[397]1459 if (dcd->cnremphasized) {
1460 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
[1159]1461 MPFROM2SHORT(FALSE, CRA_SOURCE));
[397]1462 dcd->cnremphasized = FALSE;
[2]1463 }
[397]1464 }
1465 else
1466 WinSendMsg(dcd->hwndLastMenu, MM_SELECTITEM,
[1159]1467 MPFROM2SHORT(id, TRUE), MPFROM2SHORT(0, FALSE));
[2]1468}
1469
[231]1470PMINIRECORDCORE CurrentRecord(HWND hwndCnr)
1471{
[787]1472 SHORT attrib = fSelectedAlways ? CRA_SELECTED : CRA_CURSORED;
[397]1473 PMINIRECORDCORE pmi;
[2]1474
[397]1475 for (;;) {
1476 pmi = (PMINIRECORDCORE) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
[1159]1477 MPFROMLONG(CMA_FIRST),
1478 MPFROMSHORT(attrib));
[930]1479 if ((!pmi || (INT) pmi == -1) && attrib == CRA_SELECTED) /* punt */
[397]1480 attrib = CRA_CURSORED;
1481 else
1482 break;
1483 }
[787]1484 return ((INT)pmi == -1) ? NULL : pmi;
[2]1485}
1486
[231]1487BOOL PostMsg(HWND h, ULONG msg, MPARAM mp1, MPARAM mp2)
1488{
[397]1489 BOOL rc = WinPostMsg(h, msg, mp1, mp2);
[2]1490
[397]1491 if (!rc) {
[2]1492
[882]1493 // If window owned by some other process or some other thread?
1494 if (!IsFm2Window(h, 1)) {
1495 QMSG qmsg;
1496 for (;;) {
[1159]1497 DosSleep(1);
1498 rc = WinPostMsg(h, msg, mp1, mp2);
1499 if (rc)
1500 break; // OK
1501 if (!WinIsWindow((HAB) 0, h))
1502 break; // Window gone
1503 if (WinPeekMsg((HAB) 0, &qmsg, (HWND) 0, 0, 0, PM_NOREMOVE))
1504 break; // Queue has message(s)
1505 } // for
[2]1506 }
[882]1507 }
[397]1508 return rc;
[2]1509}
1510
[231]1511VOID OpenEdit(HWND hwnd)
1512{
[397]1513 CNREDITDATA ced;
1514 PCNRITEM pci;
1515 PFIELDINFO pfi;
[2]1516
[397]1517 pci = (PCNRITEM) WinSendMsg(hwnd,
[1159]1518 CM_QUERYRECORDEMPHASIS,
1519 MPFROMLONG(CMA_FIRST),
1520 MPFROMSHORT(CRA_CURSORED));
[397]1521 if (pci && (INT) pci != -1) {
1522 memset(&ced, 0, sizeof(ced));
1523 ced.cb = sizeof(ced);
1524 ced.hwndCnr = hwnd;
1525 ced.id = WinQueryWindowUShort(hwnd, QWS_ID);
1526 ced.pRecord = (PRECORDCORE) pci;
1527 pfi = (PFIELDINFO) WinSendMsg(hwnd,
[1159]1528 CM_QUERYDETAILFIELDINFO,
1529 MPVOID, MPFROMSHORT(CMA_FIRST));
[397]1530 if (!pfi)
1531 WinSendMsg(hwnd, CM_OPENEDIT, MPFROMP(&ced), MPVOID);
1532 else {
1533 while (pfi && (INT) pfi != -1 &&
[1159]1534 pfi->offStruct != FIELDOFFSET(CNRITEM, pszFileName))
1535 pfi = (PFIELDINFO) WinSendMsg(hwnd,
1536 CM_QUERYDETAILFIELDINFO,
1537 MPFROMP(pfi), MPFROMSHORT(CMA_NEXT));
[397]1538 if (pfi && (INT) pfi != -1) {
[1159]1539 ced.pFieldInfo = pfi;
1540 {
1541 CNRINFO cnri;
[2]1542
[1159]1543 memset(&cnri, 0, sizeof(CNRINFO));
1544 cnri.cb = sizeof(CNRINFO);
1545 WinSendMsg(hwnd,
1546 CM_QUERYCNRINFO,
1547 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1548 if (cnri.flWindowAttr & CV_DETAIL)
1549 ced.id = CID_LEFTDVWND;
1550 }
1551 WinSendMsg(hwnd, CM_OPENEDIT, MPFROMP(&ced), MPVOID);
[397]1552 }
[2]1553 }
[397]1554 }
[2]1555}
1556
1557#ifdef NEVER
[231]1558VOID QuickView(HWND hwnd, CHAR * filename)
1559{
[397]1560 if (filename && IsFile(filename) == 1) {
1561 if (TestBinary(filename) && *binview) {
[2]1562
[397]1563 CHAR *list[2];
[2]1564
[397]1565 list[0] = filename;
1566 list[1] = NULL;
[888]1567 ExecOnList(hwnd, binview, WINDOWED | SEPARATE, NULL, list, NULL,
[1159]1568 pszSrcFile, __LINE__);
[397]1569 return;
1570 }
1571 else if (*viewer) {
[2]1572
[397]1573 CHAR *list[2];
[2]1574
[397]1575 list[0] = filename;
1576 list[1] = NULL;
[787]1577 ExecOnList(hwnd, viewer,
[1159]1578 WINDOWED | SEPARATE | (fViewChild ? CHILD : 0),
1579 NULL, list, NULL, pszSrcFile, __LINE__);
[397]1580 return;
[2]1581 }
[397]1582 StartMLEEditor(HWND_DESKTOP, 5, filename, (HWND) 0);
1583 }
[2]1584}
1585
[231]1586VOID QuickEdit(HWND hwnd, CHAR * filename)
1587{
[397]1588 if (filename && IsFile(filename) == 1) {
1589 if (TestBinary(filename) && *bined) {
[2]1590
[397]1591 CHAR *list[2];
[2]1592
[397]1593 list[0] = filename;
1594 list[1] = NULL;
[888]1595 ExecOnList(hwnd, bined, WINDOWED | SEPARATE, NULL, list, NULL,
[1159]1596 pszSrcFile, __LINE__);
[397]1597 return;
1598 }
1599 else if (*editor) {
[2]1600
[397]1601 CHAR *list[2];
[2]1602
[397]1603 list[0] = filename;
1604 list[1] = NULL;
[888]1605 ExecOnList(hwnd, editor, WINDOWED | SEPARATE, NULL, list, NULL,
[1159]1606 pszSrcFile, __LINE__);
[397]1607 return;
[2]1608 }
[397]1609 StartMLEEditor(HWND_DESKTOP, 4, filename, (HWND) 0);
1610 }
[2]1611}
1612#endif
1613
[231]1614VOID PortholeInit(HWND hwndNew, MPARAM mp1, MPARAM mp2)
1615{
[397]1616 static HWND DefMenu = (HWND) 0;
1617 HWND hwndMenu = (HWND) mp2;
[2]1618
[397]1619 {
1620 ULONG style;
1621
1622 style = WinQueryWindowULong(hwndMenu, QWL_STYLE);
1623 if (!(style & MS_ACTIONBAR))
1624 return;
1625 }
1626
1627 switch (SHORT1FROMMP(mp1)) {
1628 case 0:
[231]1629 {
[397]1630 HWND hwndNow;
1631 MENUITEM mi;
1632 ULONG ulStyle;
[2]1633
[397]1634 memset(&mi, 0, sizeof(mi));
1635 mi.iPosition = MIT_END;
1636 mi.afStyle = MIS_TEXT;
1637 WinSendMsg(hwndMenu, MM_QUERYITEM,
[1159]1638 MPFROM2SHORT(IDM_FILESMENU, TRUE), MPFROMP(&mi));
[397]1639 if (!DefMenu)
[1159]1640 DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
[397]1641 hwndNow = mi.hwndSubMenu;
1642 mi.hwndSubMenu = hwndNew;
1643 if (!mi.hwndSubMenu)
[1159]1644 mi.hwndSubMenu = DefMenu;
[397]1645 WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
1646 WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
1647 WinSetOwner(mi.hwndSubMenu, hwndMenu);
1648 WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
1649 WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_FILESMENU);
1650 mi.afStyle = MIS_SUBMENU;
1651 ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
1652 ulStyle &= -WS_SAVEBITS;
1653 ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
1654 WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
1655 WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
[231]1656 }
[397]1657 break;
[2]1658
[397]1659 case 1:
[231]1660 {
[397]1661 HWND hwndNow;
1662 MENUITEM mi;
1663 ULONG ulStyle;
[2]1664
[397]1665 memset(&mi, 0, sizeof(mi));
1666 mi.iPosition = MIT_END;
1667 mi.afStyle = MIS_TEXT;
1668 WinSendMsg(hwndMenu, MM_QUERYITEM,
[1159]1669 MPFROM2SHORT(IDM_VIEWSMENU, TRUE), MPFROMP(&mi));
[397]1670 if (!DefMenu)
[1159]1671 DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
[397]1672 hwndNow = mi.hwndSubMenu;
1673 mi.hwndSubMenu = hwndNew;
1674 if (!mi.hwndSubMenu)
[1159]1675 mi.hwndSubMenu = DefMenu;
[397]1676 WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
1677 WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
1678 WinSetOwner(mi.hwndSubMenu, hwndMenu);
1679 WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
1680 WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_VIEWSMENU);
1681 mi.afStyle = MIS_SUBMENU;
1682 ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
1683 ulStyle &= -WS_SAVEBITS;
1684 ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
1685 WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
1686 WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
[231]1687 }
[397]1688 break;
1689 }
[2]1690}
1691
[872]1692HWND CheckMenu(HWND hwnd, HWND * hwndMenu, USHORT id)
[231]1693{
[397]1694 /* load and adjust menus as required */
1695 if (!*hwndMenu || !WinIsWindow((HAB) 0, *hwndMenu)) {
1696 *hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
[877]1697 CopyPresParams(*hwndMenu, hwnd);
[397]1698 if (hwndMenu == &DirMenu) {
1699 WinSetWindowUShort(DirMenu, QWS_ID, IDM_FILESMENU);
1700 SetConditionalCascade(DirMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1701 SetConditionalCascade(DirMenu, IDM_COPYMENU, IDM_COPY);
1702 SetConditionalCascade(DirMenu, IDM_MOVEMENU, IDM_MOVE);
1703 SetConditionalCascade(DirMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1704 SetConditionalCascade(DirMenu, IDM_VIEWSUBMENU, IDM_INFO);
1705 SetConditionalCascade(DirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1706 SetConditionalCascade(DirMenu, IDM_DELETESUBMENU,
[1159]1707 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1708 SetConditionalCascade(DirMenu, IDM_MISCSUBMENU, IDM_SIZES);
1709 SetConditionalCascade(DirMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
1710 if (fWorkPlace) {
[1159]1711 WinSendMsg(DirMenu, MM_DELETEITEM,
1712 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1713 WinSendMsg(DirMenu, MM_DELETEITEM,
1714 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]1715 }
[2]1716 }
[397]1717 else if (hwndMenu == &TreeMenu) {
1718 WinSetWindowUShort(TreeMenu, QWS_ID, IDM_FILESMENU);
1719 SetConditionalCascade(TreeMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1720 SetConditionalCascade(TreeMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1721 SetConditionalCascade(TreeMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1722 SetConditionalCascade(TreeMenu, IDM_EXPANDSUBMENU, IDM_EXPAND);
1723 SetConditionalCascade(TreeMenu, IDM_MISCSUBMENU, IDM_SIZES);
1724 SetConditionalCascade(TreeMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
1725 if (fWorkPlace) {
[1159]1726 WinSendMsg(TreeMenu, MM_DELETEITEM,
1727 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1728 WinSendMsg(TreeMenu, MM_DELETEITEM,
1729 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]1730 }
1731 }
1732 else if (hwndMenu == &ArcMenu) {
1733 WinSetWindowUShort(ArcMenu, QWS_ID, IDM_FILESMENU);
1734 SetConditionalCascade(ArcMenu, IDM_EXTRACTSUBMENU, IDM_EXTRACT);
1735 SetConditionalCascade(ArcMenu, IDM_EDITSUBMENU, IDM_EDIT);
1736 SetConditionalCascade(ArcMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1737 if (fWorkPlace)
[1159]1738 WinSendMsg(ArcMenu, MM_DELETEITEM,
1739 MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
[397]1740 }
1741 else if (hwndMenu == &FileMenu) {
1742 WinSetWindowUShort(FileMenu, QWS_ID, IDM_FILESMENU);
1743 SetConditionalCascade(FileMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1744 SetConditionalCascade(FileMenu, IDM_COPYMENU, IDM_COPY);
1745 SetConditionalCascade(FileMenu, IDM_MOVEMENU, IDM_MOVE);
1746 SetConditionalCascade(FileMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1747 SetConditionalCascade(FileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1748 SetConditionalCascade(FileMenu, IDM_EDITSUBMENU, IDM_EDIT);
1749 SetConditionalCascade(FileMenu, IDM_COLLECTMENU, IDM_COLLECT);
1750 SetConditionalCascade(FileMenu, IDM_DELETESUBMENU,
[1159]1751 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1752 SetConditionalCascade(FileMenu, IDM_OPENSUBMENU, IDM_OPENDEFAULT);
1753 SetConditionalCascade(FileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
1754 if (fWorkPlace) {
[1159]1755 WinSendMsg(FileMenu, MM_DELETEITEM,
1756 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1757 WinSendMsg(FileMenu, MM_DELETEITEM,
1758 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]1759 }
1760 }
1761 else if (hwndMenu == &DirCnrMenu) {
1762 WinSetWindowUShort(DirCnrMenu, QWS_ID, IDM_VIEWSMENU);
1763 SetConditionalCascade(DirCnrMenu, IDM_MISCSUBMENU, IDM_SIZES);
1764 SetConditionalCascade(DirCnrMenu, IDM_OPENSUBMENU, IDM_OPENSETTINGSME);
1765 if (fWorkPlace)
[1159]1766 WinSendMsg(DirCnrMenu, MM_DELETEITEM,
1767 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
[397]1768 }
[489]1769 else if (hwndMenu == &TreeCnrMenu) {
[397]1770 WinSetWindowUShort(TreeCnrMenu, QWS_ID, IDM_VIEWSMENU);
[468]1771 SetConditionalCascade(TreeCnrMenu, IDM_PARTITIONSMENU, IDM_PARTITION);
1772 }
[397]1773 else if (hwndMenu == &ArcCnrMenu) {
1774 WinSetWindowUShort(ArcCnrMenu, QWS_ID, IDM_VIEWSMENU);
1775 SetConditionalCascade(ArcCnrMenu, IDM_EXTRACTSUBMENU, IDM_ARCEXTRACT);
1776 if (fWorkPlace)
[1159]1777 WinSendMsg(ArcCnrMenu, MM_DELETEITEM,
1778 MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
[397]1779 }
1780 else if (hwndMenu == &CollectorCnrMenu) {
1781 WinSetWindowUShort(CollectorCnrMenu, QWS_ID, IDM_VIEWSMENU);
1782 SetConditionalCascade(CollectorCnrMenu, IDM_COLLECTMENU,
[1159]1783 IDM_COLLECTFROMCLIP);
[397]1784 }
1785 else if (hwndMenu == &CollectorFileMenu) {
1786 WinSetWindowUShort(CollectorFileMenu, QWS_ID, IDM_FILESMENU);
1787 SetConditionalCascade(CollectorFileMenu, IDM_COMMANDSMENU,
[1159]1788 IDM_DOITYOURSELF);
[397]1789 SetConditionalCascade(CollectorFileMenu, IDM_COPYMENU, IDM_COPY);
1790 SetConditionalCascade(CollectorFileMenu, IDM_MOVEMENU, IDM_MOVE);
1791 SetConditionalCascade(CollectorFileMenu, IDM_SAVESUBMENU,
[1084]1792 IDM_SAVETOCLIP);
[397]1793 SetConditionalCascade(CollectorFileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1794 SetConditionalCascade(CollectorFileMenu, IDM_EDITSUBMENU, IDM_EDIT);
1795 SetConditionalCascade(CollectorFileMenu, IDM_DELETESUBMENU,
[1159]1796 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1797 SetConditionalCascade(CollectorFileMenu, IDM_OPENSUBMENU,
[1159]1798 IDM_OPENDEFAULT);
[397]1799 SetConditionalCascade(CollectorFileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
1800 if (fWorkPlace) {
[1159]1801 WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
1802 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1803 WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
1804 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]1805 }
1806 }
1807 else if (hwndMenu == &CollectorDirMenu) {
1808 WinSetWindowUShort(CollectorDirMenu, QWS_ID, IDM_FILESMENU);
1809 SetConditionalCascade(CollectorDirMenu, IDM_COMMANDSMENU,
[1159]1810 IDM_DOITYOURSELF);
[397]1811 SetConditionalCascade(CollectorDirMenu, IDM_COPYMENU, IDM_COPY);
1812 SetConditionalCascade(CollectorDirMenu, IDM_MOVEMENU, IDM_MOVE);
1813 SetConditionalCascade(CollectorDirMenu, IDM_SAVESUBMENU,
[1084]1814 IDM_SAVETOCLIP);
[397]1815 SetConditionalCascade(CollectorDirMenu, IDM_VIEWSUBMENU, IDM_INFO);
1816 SetConditionalCascade(CollectorDirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1817 SetConditionalCascade(CollectorDirMenu, IDM_DELETESUBMENU,
[1159]1818 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1819 SetConditionalCascade(CollectorDirMenu, IDM_MISCSUBMENU, IDM_SIZES);
1820 SetConditionalCascade(CollectorDirMenu, IDM_OPENSUBMENU,
[1159]1821 IDM_OPENWINDOW);
[397]1822 if (fWorkPlace) {
[1159]1823 WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
1824 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1825 WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
1826 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]1827 }
1828 }
1829 else if (hwndMenu == &MainPopupMenu) {
1830 WinSetWindowUShort(MainPopupMenu, QWS_ID, IDM_MAINPOPUP);
1831 SetConditionalCascade(MainPopupMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
1832 SetConditionalCascade(MainPopupMenu, IDM_AUTOVIEWSUBMENU, IDM_AUTOVIEW);
1833 }
1834 }
[877]1835 CopyPresParams(*hwndMenu, hwnd);
[397]1836 return *hwndMenu;
[2]1837}
1838
[231]1839SHORT AddToListboxBottom(HWND hwnd, CHAR * str)
1840{
[397]1841 SHORT ln;
[2]1842
[397]1843 ln = (SHORT) WinSendMsg(hwnd, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
[1159]1844 MPFROMP(str));
[397]1845 if (ln)
1846 WinSendMsg(hwnd, LM_SELECTITEM, MPFROM2SHORT(ln, 0), MPVOID);
1847 return ln;
[2]1848}
1849
[231]1850VOID SetSysMenu(HWND hwndSysMenu)
1851{
[397]1852 CHAR s[128], *p;
[2]1853
[397]1854 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1159]1855 MPFROM2SHORT(SC_RESTORE, 128), MPFROMP(s))) {
[397]1856 p = strchr(s, '\t');
1857 if (p) {
1858 p++;
1859 strcpy(p, "Ctrl+Alt+F5");
1860 WinSetMenuItemText(hwndSysMenu, SC_RESTORE, s);
[2]1861 }
[397]1862 }
1863 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1159]1864 MPFROM2SHORT(SC_CLOSE, 128), MPFROMP(s))) {
[397]1865 p = strchr(s, '\t');
1866 if (p) {
1867 p++;
1868 strcpy(p, "Ctrl+Alt+F4");
1869 WinSetMenuItemText(hwndSysMenu, SC_CLOSE, s);
[2]1870 }
[397]1871 }
1872 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1159]1873 MPFROM2SHORT(SC_MOVE, 128), MPFROMP(s))) {
[397]1874 p = strchr(s, '\t');
1875 if (p) {
1876 p++;
1877 strcpy(p, "Ctrl+Alt+F7");
1878 WinSetMenuItemText(hwndSysMenu, SC_MOVE, s);
[2]1879 }
[397]1880 }
1881 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1159]1882 MPFROM2SHORT(SC_SIZE, 128), MPFROMP(s))) {
[397]1883 p = strchr(s, '\t');
1884 if (p) {
1885 p++;
1886 strcpy(p, "Ctrl+Alt+F8");
1887 WinSetMenuItemText(hwndSysMenu, SC_SIZE, s);
[2]1888 }
[397]1889 }
1890 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1159]1891 MPFROM2SHORT(SC_MINIMIZE, 128), MPFROMP(s))) {
[397]1892 p = strchr(s, '\t');
1893 if (p) {
1894 p++;
1895 strcpy(p, "Ctrl+Alt+F9");
1896 WinSetMenuItemText(hwndSysMenu, SC_MINIMIZE, s);
[2]1897 }
[397]1898 }
1899 if (WinSendMsg(hwndSysMenu,
[1159]1900 MM_QUERYITEMTEXT,
1901 MPFROM2SHORT(SC_MAXIMIZE, 128), MPFROMP(s))) {
[397]1902 p = strchr(s, '\t');
1903 if (p) {
1904 p++;
1905 strcpy(p, "Ctrl+Alt+F10");
1906 WinSetMenuItemText(hwndSysMenu, SC_MAXIMIZE, s);
[2]1907 }
[397]1908 }
1909 if (WinSendMsg(hwndSysMenu,
[1159]1910 MM_QUERYITEMTEXT, MPFROM2SHORT(SC_HIDE, 128), MPFROMP(s))) {
[397]1911 p = strchr(s, '\t');
1912 if (p) {
1913 p++;
1914 strcpy(p, "Ctrl+Alt+F11");
1915 WinSetMenuItemText(hwndSysMenu, SC_HIDE, s);
[2]1916 }
[397]1917 }
[2]1918}
1919
[231]1920VOID LoadLibPath(CHAR * str, LONG len)
1921{
[397]1922 ULONG ver[2];
1923 CHAR configsys[] = "C:\\CONFIG.SYS";
1924 static CHAR var[8192], beg[16384], end[16384];
1925 BOOL warp;
1926 FILE *fp;
1927 PFN DQELIBPATH = NULL;
1928 HMODULE hmod;
[2]1929
[397]1930 if (str && len) {
1931 *str = 0;
1932 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
[1159]1933 QSV_BOOT_DRIVE, (PVOID) ver, (ULONG) sizeof(ULONG)))
[397]1934 ver[0] = 3L;
1935 *configsys = (CHAR) ver[0] + '@';
1936 if (!DosQuerySysInfo(QSV_VERSION_MAJOR,
[1159]1937 QSV_VERSION_MINOR,
1938 (PVOID) ver, (ULONG) sizeof(ver)) && ver[1] >= 30)
[397]1939 warp = TRUE;
1940 *var = *beg = *end = 0;
1941 if (warp) {
1942 if (!DosLoadModule(var, sizeof(var), "DOSCALL1.DLL", &hmod)) {
[1159]1943 if (!DosQueryProcAddr(hmod,
1944 ORD_DOS32QUERYEXTLIBPATH,
1945 NULL, (PFN *) & DQELIBPATH)) {
1946 DQELIBPATH(beg, BEGIN_LIBPATH);
1947 DQELIBPATH(end, END_LIBPATH);
1948 }
1949 DosFreeModule(hmod);
[397]1950 }
1951 *var = 0;
1952 }
1953 fp = xfopen(configsys, "r", pszSrcFile, __LINE__);
1954 if (fp) {
1955 while (!feof(fp)) {
[1159]1956 if (!xfgets_bstripcr(var, sizeof(var), fp, pszSrcFile, __LINE__))
1957 break;
1958 if (!strnicmp(var, "LIBPATH=", 8)) {
1959 memmove(var, var + 8, strlen(var + 8) + 1);
1960 lstrip(var);
1961 break;
1962 }
[397]1963 }
1964 fclose(fp);
[2]1965 }
[397]1966 strncpy(str, beg, len);
1967 strncat(str, var, len - strlen(str));
1968 strncat(str, end, len - strlen(str));
1969 str[len - 1] = 0;
1970 }
[2]1971}
1972
[231]1973void SetViewMenu(HWND hwndMenu, ULONG flWindowAttr)
1974{
[397]1975 WinCheckMenuItem(hwndMenu, IDM_MINIICONS, ((flWindowAttr & CV_MINI)));
1976 WinCheckMenuItem(hwndMenu, IDM_TEXT, ((flWindowAttr & CV_TEXT)));
1977 WinCheckMenuItem(hwndMenu, IDM_ICON, ((flWindowAttr & CV_ICON) &&
[1159]1978 !(flWindowAttr & CV_TREE)));
[397]1979 WinCheckMenuItem(hwndMenu, IDM_TREEVIEW, ((flWindowAttr & CV_TREE)));
1980 WinCheckMenuItem(hwndMenu, IDM_DETAILS, ((flWindowAttr & CV_DETAIL)));
1981 WinCheckMenuItem(hwndMenu, IDM_NAME, ((flWindowAttr & CV_NAME)));
[2]1982}
1983
[231]1984void SaySort(HWND hwnd, INT sortflags, BOOL archive)
1985{
[397]1986 char *s = NULL;
[2]1987
[397]1988 s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
1989 if (s) {
1990 sprintf(s, "S:%s%s",
[1159]1991 sortflags & SORT_REVERSE ? "^" : NullStr,
1992 (sortflags & SORT_FIRSTEXTENSION) ?
1993 GetPString(IDS_FIRSTX) : (sortflags & SORT_LASTEXTENSION) ?
1994 GetPString(IDS_LASTX) : (sortflags & SORT_SIZE) ?
1995 "Size" : (sortflags & SORT_EASIZE) ?
1996 (archive == 0) ?
1997 GetPString(IDS_EASIZE) : GetPString(IDS_CSIZE) :
1998 (sortflags & SORT_LWDATE) ?
1999 (archive == 0) ?
2000 GetPString(IDS_LWDATE) : GetPString(IDS_DATE) :
2001 (sortflags & SORT_LADATE) ?
2002 GetPString(IDS_LADATE) : (sortflags & SORT_CRDATE) ?
2003 GetPString(IDS_CRDATE) :
2004 (sortflags & SORT_PATHNAME) ?
2005 GetPString(IDS_PATH) : (sortflags & SORT_NOSORT) ?
2006 GetPString(IDS_NONE) : (sortflags & SORT_SUBJECT) ?
2007 GetPString(IDS_SUBJ) : GetPString(IDS_NAME));
[397]2008 WinSetWindowText(hwnd, s);
[1039]2009 free(s);
[397]2010 }
[2]2011}
2012
[231]2013void SayView(HWND hwnd, ULONG flWindowAttr)
2014{
[397]2015 char *s = NULL;
[2]2016
[397]2017 s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
2018 if (s) {
2019 sprintf(s, "V:%s%s",
[1159]2020 (flWindowAttr & CV_TREE) ? GetPString(IDS_TREE) :
2021 (flWindowAttr & CV_NAME) ? GetPString(IDS_NAME) :
2022 (flWindowAttr & CV_DETAIL) ? GetPString(IDS_DETAIL) :
2023 (flWindowAttr & CV_TEXT) ? GetPString(IDS_TEXT) :
2024 GetPString(IDS_ICON),
2025 ((flWindowAttr & CV_MINI) &&
2026 !(flWindowAttr & CV_TEXT)) ? GetPString(IDS_MINI) : NullStr);
[397]2027 WinSetWindowText(hwnd, s);
[1039]2028 free(s);
[397]2029 }
[2]2030}
2031
[231]2032void SayFilter(HWND hwnd, MASK * mask, BOOL archive)
2033{
[397]2034 char *s = NULL;
[2]2035
[397]2036 s = xmalloc(CCHMAXPATH * 2, pszSrcFile, __LINE__);
2037 if (s) {
2038 sprintf(s, "F:%s%s",
[1159]2039 mask->szMask,
2040 (!archive && (mask->attrFile != ALLATTRS ||
2041 mask->antiattr != 0)) ? " " : NullStr,
2042 (!archive && (mask->attrFile != ALLATTRS ||
2043 mask->antiattr !=
2044 0)) ? GetPString(IDS_ATTRTEXT) : NullStr);
[397]2045 if (!s[2])
2046 sprintf(s, "F:%s", GetPString(IDS_ALLTEXT));
2047 WinSetWindowText(hwnd, s);
[1039]2048 free(s);
[397]2049 }
[2]2050}
2051
[231]2052char *GetCmdSpec(BOOL dos)
2053{
[397]2054 char *cmspec;
[2]2055
[397]2056 if (!dos) {
2057 cmspec = getenv("OS2_SHELL");
2058 if (!cmspec)
2059 cmspec = getenv("COMSPEC");
2060 if (!cmspec)
2061 cmspec = "CMD.EXE";
2062 }
2063 else {
2064 cmspec = getenv("DOS_SHELL");
2065 if (!cmspec)
2066 cmspec = "COMMAND.COM";
2067 }
2068 return cmspec;
[2]2069}
2070
[231]2071void Broadcast(HAB hab, HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2072{
[397]2073 if (hwndMain)
2074 WinBroadcastMsg(hwndMain, msg, mp1, mp2, BMSG_SEND | BMSG_FRAMEONLY);
2075 if (hwnd &&
2076 hwnd != HWND_DESKTOP &&
2077 hwnd != hwndMain &&
2078 hwnd != WinQueryDesktopWindow(hab, NULLHANDLE) &&
2079 WinIsWindow(hab, hwnd) && (!hwndMain || !WinIsChild(hwnd, hwndMain)))
2080 WinSendMsg(hwnd, msg, mp1, mp2);
[2]2081}
2082
[231]2083void SetupWinList(HWND hwndMenu, HWND hwndTop, HWND hwndFrame)
2084{
[397]2085 /*
2086 * add switchlist entries to end of pulldown menu
2087 */
[2]2088
[397]2089 SHORT sItemCount, x = 0, y = 0;
2090 MENUITEM mi;
[2]2091
[397]2092 sItemCount = (SHORT) WinSendMsg(hwndMenu,
[1159]2093 MM_QUERYITEMCOUNT, MPVOID, MPVOID);
[2]2094
[397]2095 /* clean out old additions */
2096 while ((SHORT) WinSendMsg(hwndMenu,
[1159]2097 MM_DELETEITEM,
2098 MPFROM2SHORT(IDM_SWITCHSTART + x++,
2099 TRUE), MPVOID) < sItemCount)
[397]2100 sItemCount--;
2101 x = 0;
2102 while ((SHORT) WinSendMsg(hwndMenu,
[1159]2103 MM_DELETEITEM,
2104 MPFROM2SHORT(IDM_WINDOWSTART + x++,
2105 TRUE), MPVOID) < sItemCount)
[397]2106 sItemCount--;
[2]2107
[397]2108 x = 0;
2109 if (hwndTop) {
[2]2110
[397]2111 char wtext[CCHMAXPATH + 8];
2112 HENUM henum;
2113 HWND hwndChild;
[2]2114
[397]2115 /* add children of the main FM/2 client */
2116 henum = WinBeginEnumWindows(hwndTop);
2117 memset(&mi, 0, sizeof(mi));
2118 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2119 if (WinQueryWindowUShort(hwndChild, QWS_ID) && hwndChild != hwndFrame) {
[1159]2120 *wtext = 0;
2121 WinQueryWindowText(hwndChild, CCHMAXPATH + 8, wtext);
2122 if (*wtext) {
2123 wtext[CCHMAXPATH + 7] = 0;
2124 mi.afStyle = MIS_TEXT;
2125 if (!((x + sItemCount) % 28))
2126 mi.afStyle |= MIS_BREAK;
2127 mi.id = IDM_WINDOWSTART + x;
2128 mi.iPosition = MIT_END;
2129 if ((SHORT) WinSendMsg(hwndMenu,
2130 MM_INSERTITEM,
2131 MPFROMP(&mi), MPFROMP(wtext)) >= 0)
2132 x++;
2133 }
[397]2134 }
[2]2135 }
[397]2136 WinEndEnumWindows(henum);
2137 }
[2]2138
[397]2139 /* add external FM/2 windows */
2140 {
2141 PSWBLOCK pswb;
2142 ULONG ulSize, ulcEntries;
2143 HWND hwndTopFrame;
2144 register INT i;
[2]2145
[787]2146 hwndTopFrame = hwndTop ? WinQueryWindow(hwndTop, QW_PARENT) : (HWND)0;
[397]2147 /* Get the switch list information */
2148 x = 0;
2149 ulcEntries = WinQuerySwitchList(0, NULL, 0);
2150 ulSize = sizeof(SWBLOCK) + sizeof(HSWITCH) + (ulcEntries + 4L) *
2151 (LONG) sizeof(SWENTRY);
2152 /* Allocate memory for list */
2153 pswb = xmalloc(ulSize, pszSrcFile, __LINE__);
2154 if (pswb) {
2155 /* Put the info in the list */
2156 ulcEntries = WinQuerySwitchList(0, pswb, ulSize - sizeof(SWENTRY));
2157 /* do the dirty deed */
2158 memset(&mi, 0, sizeof(mi));
2159 for (i = 0; i < pswb->cswentry; i++) {
[1159]2160 if (pswb->aswentry[i].swctl.uchVisibility == SWL_VISIBLE &&
2161 pswb->aswentry[i].swctl.fbJump == SWL_JUMPABLE &&
2162 (pswb->aswentry[i].swctl.idProcess != mypid ||
2163 !hwndFrame ||
2164 pswb->aswentry[i].swctl.hwnd != hwndFrame) &&
2165 (pswb->aswentry[i].swctl.idProcess != mypid ||
2166 !hwndTopFrame ||
2167 pswb->aswentry[i].swctl.hwnd != hwndTopFrame ||
2168 !WinIsChild(hwndFrame, hwndTop))) {
2169 if (!strnicmp(pswb->aswentry[i].swctl.szSwtitle, "AV/2", 4)
2170 || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "File Manager/2")
2171 || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "Collector")
2172 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VTree", 5)
2173 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VDir", 4)
2174 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, FM2Str, 4)) {
2175 mi.afStyle = MIS_TEXT;
2176 if (x && !(x % 28))
2177 mi.afStyle |= MIS_BREAK;
2178 mi.id = IDM_SWITCHSTART + y;
2179 mi.iPosition = MIT_END;
2180 switches[y] = pswb->aswentry[i].hswitch;
2181 if ((SHORT) WinSendMsg(hwndMenu,
2182 MM_INSERTITEM,
2183 MPFROMP(&mi),
2184 MPFROMP(pswb->aswentry[i].
2185 swctl.szSwtitle)) >= 0) {
2186 y++;
2187 x++;
2188 }
2189 }
2190 }
[397]2191 }
2192 numswitches = y;
[1039]2193 free(pswb);
[397]2194 DosPostEventSem(CompactSem);
[2]2195 }
[397]2196 }
[2]2197}
2198
[231]2199BOOL SwitchCommand(HWND hwndMenu, USHORT cmd)
2200{
[397]2201 BOOL ret = FALSE;
[2]2202
[397]2203 if (hwndMain && hwndMenu && cmd >= IDM_WINDOWSTART && cmd < IDM_SWITCHSTART) {
2204 /*
2205 * select a child window (of client)
2206 */
[2]2207
[397]2208 MENUITEM mi;
2209 HWND hwndSubMenu = (HWND) 0, hwndChild;
2210 CHAR s[CCHMAXPATH + 8];
[2]2211
[397]2212 if (WinQueryWindowUShort(hwndMenu, QWS_ID) != IDM_WINDOWSMENU) {
2213 memset(&mi, 0, sizeof(mi));
2214 mi.iPosition = MIT_END;
2215 mi.afStyle = MIS_TEXT;
2216 if (WinSendMsg(hwndMenu,
[1159]2217 MM_QUERYITEM,
2218 MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
2219 hwndSubMenu = mi.hwndSubMenu;
[397]2220 }
2221 else
2222 hwndSubMenu = hwndMenu;
2223 if (hwndSubMenu) {
2224 *s = 0;
2225 if (WinSendMsg(hwndSubMenu,
[1159]2226 MM_QUERYITEMTEXT,
2227 MPFROM2SHORT(cmd, CCHMAXPATH + 8), MPFROMP(s)) && *s) {
[2]2228
[1159]2229 HENUM henum;
2230 CHAR checkText[CCHMAXPATH + 8];
2231 SWP swp;
[2]2232
[1159]2233 s[CCHMAXPATH + 7] = 0;
2234 henum = WinBeginEnumWindows(hwndMain);
2235 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2236 if (WinQueryWindowUShort(hwndChild, QWS_ID)) {
2237 *checkText = 0;
2238 WinQueryWindowText(hwndChild, CCHMAXPATH + 8, checkText);
2239 checkText[CCHMAXPATH + 7] = 0;
2240 if (!stricmp(checkText, s)) {
2241 if (WinQueryWindowPos(hwndChild, &swp)) {
2242 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE))
2243 WinSetWindowPos(hwndChild,
2244 HWND_TOP,
2245 0, 0, 0, 0, SWP_RESTORE | SWP_ZORDER);
2246 }
2247 WinSetActiveWindow(HWND_DESKTOP, hwndChild);
2248 ret = TRUE;
2249 break;
2250 }
2251 }
2252 }
2253 WinEndEnumWindows(henum);
[397]2254 }
[2]2255 }
[397]2256 }
2257 else if (cmd >= IDM_SWITCHSTART && cmd < IDM_SWITCHSTART + 499) {
2258 if (cmd - IDM_SWITCHSTART < numswitches) {
2259 WinSwitchToProgram(switches[cmd - IDM_SWITCHSTART]);
2260 ret = TRUE;
[2]2261 }
[397]2262 }
[2]2263
[397]2264 return ret;
[2]2265}
[787]2266
[1112]2267/** CheckDriveSpaceAvail
2268 * Take space needed and checks that drive has at least 1000 bits in excess of the required space.
2269 * Returns 0 if sufficient space is available; 1 if the drive is full & 2 on abort of operation
2270 * when the drive would have less than ullFreeSpaceWhenComplete remaining or has insufficient space.
2271 */
2272
2273INT CheckDriveSpaceAvail(CHAR *pTargetPath, ULONGLONG ullSpaceNeeded,
2274 ULONGLONG ullFreeSpaceWhenComplete)
2275{
2276 FSALLOCATE fsa;
2277 ULONGLONG ullFreeQty;
2278 APIRET ret;
2279
2280 DosQueryFSInfo(toupper(*pTargetPath) - 'A' + 1, FSIL_ALLOC, &fsa, sizeof(FSALLOCATE));
2281 ullFreeQty = (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector);
2282 if (ullFreeQty > ullSpaceNeeded + ullFreeSpaceWhenComplete)
2283 return 0;
2284 else if (ullFreeQty < ullSpaceNeeded + 1024) {
2285 CHAR szKB[20];
2286
[1120]2287 CommaFmtULL(szKB, sizeof(szKB),
2288 ullFreeQty - ullSpaceNeeded, ' ');
[1112]2289 if (ullFreeSpaceWhenComplete == 0) {
2290 saymsg(MB_OK,
[1159]2291 HWND_DESKTOP,
2292 NullStr,
[1112]2293 GetPString(IDS_DRIVESPACELIMITEDTMPSAVE),
[1120]2294 pTargetPath);
[1112]2295 return 0;
2296 }
2297 else {
[1118]2298 if (ullFreeQty > ullSpaceNeeded) {
[1112]2299 ret = saymsg(MB_YESNO,
2300 HWND_DESKTOP,
2301 NullStr,
2302 GetPString(IDS_DRIVESPACELIMITED),
2303 pTargetPath,
2304 szKB);
2305 if (ret == MBID_YES)
2306 return 0;
2307 else
2308 return 2;
2309 }
2310 else {
2311 saymsg(MB_OK,
2312 HWND_DESKTOP,
2313 NullStr,
2314 GetPString(IDS_DRIVESPACEEXCEEDED),
2315 pTargetPath);
2316 return 2;
2317 }
2318 }
2319 }
2320 else
2321 return 1;
2322}
2323
[787]2324#pragma alloc_text(MAINWND5,SetSysMenu)
2325#pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow,IsFm2Window)
2326#pragma alloc_text(MISC1,FixSwitchList,FindDirCnr,CurrentRecord,SetShiftState,AddToListboxBottom)
[1112]2327#pragma alloc_text(MISC1,CheckDriveSpaceAvail)
[1077]2328
2329#ifdef FORTIFY
2330#pragma alloc_text(MISC1,GetTidForWindow)
2331#endif // FORTIFY
2332
[787]2333#pragma alloc_text(CNR_MISC1,AdjustCnrColVis,AdjustCnrColsForFSType)
2334#pragma alloc_text(CNR_MISC1,AdjustCnrColsForPref,SetCnrCols)
2335#pragma alloc_text(CNR_MISC2,CnrDirectEdit,OpenEdit)
2336#pragma alloc_text(MISC2,SetMenuCheck,disable_menuitem,SetSortChecks)
2337#pragma alloc_text(MISC2,SetDetailsSwitches,SetViewMenu)
2338#pragma alloc_text(MISC3,SetupCommandMenu,AdjustDetailsSwitches)
2339#pragma alloc_text(MISC3,ViewHelp,GetCmdSpec)
2340#pragma alloc_text(MISC3,ExecFile,SetConditionalCascade,LoadDetailsSwitches)
2341#pragma alloc_text(MISC4,PortholeInit,CheckMenu,Broadcast,SetupWinList,SwitchCommand)
2342#pragma alloc_text(MISC6,DrawTargetEmphasis,EmphasizeButton)
2343#pragma alloc_text(MISC_LIBPATH,LoadLibPath)
2344#pragma alloc_text(MISC_SAY,SayView,SaySort,SayFilter)
2345
Note: See TracBrowser for help on using the repository browser.