source: trunk/dll/misc.c@ 827

Last change on this file since 827 was 827, checked in by Steven Levine, 18 years ago

Future proof xDosSetPathInfo
Clean up callers

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