source: trunk/dll/misc.c@ 989

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

Refactor fm3dll.h to create command.h; broken ini is now replaced with backup or new ini as available; more variable command line ledth changes

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