source: trunk/dll/misc.c@ 888

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

runemf2 now quotes executable strings if needed (Ticket 180); it also reports where it was called from on errors

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