source: trunk/dll/misc.c@ 1394

Last change on this file since 1394 was 1394, checked in by Steven Levine, 17 years ago

Ticket 340: Convert GetPString to use STRINGTABLE.

Drop fm3dll.str and mkstr.exe from makefiles and wpi builders

Convert many functions to expect PCSZ arguments.
Correct walk, compare and dirsizes dialog setups to ignore saved dialog size
Drop copyright.c logic from makefile

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