source: trunk/dll/misc.c@ 239

Last change on this file since 239 was 231, checked in by root, 20 years ago

Beautify

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