source: trunk/dll/misc.c@ 849

Last change on this file since 849 was 841, checked in by Gregg Young, 18 years ago

This implements large file support; The wrappers to allow WARP3 compatibility are not done so this will not run on Warp3or Warp 4 pre fixpack 12(?)

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