source: trunk/dll/misc.c@ 856

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

Use CommaFmtULL to display large file sizes (Ticket 41). Remove autoset of to no large file support.

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