source: trunk/dll/misc.c@ 1020

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

Fix dircnr to follow "subject column" preference on open; match query & save profile key names for "details" settings.

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