source: trunk/dll/misc.c@ 826

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

Add xDosSetPathInfo to work around FILESTATUSx buffer crossing 64k boundry

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 63.9 KB
Line 
1
2/***********************************************************************
3
4 $Id: misc.c 826 2007-09-01 21:50:33Z 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 Add xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
36
37***********************************************************************/
38
39#define INCL_DOS
40#define INCL_WIN
41#define INCL_GPI
42#include <os2.h>
43
44#include <stdarg.h>
45#include <stdio.h>
46#include <stdlib.h>
47#include <string.h>
48#include <ctype.h>
49#include <share.h>
50#include <malloc.h> // headmin
51
52#include "fm3dll.h"
53#include "fm3dlg.h"
54#include "fm3str.h"
55
56#pragma data_seg(DATA1)
57
58static PSZ pszSrcFile = __FILE__;
59
60#ifndef BEGIN_LIBPATH
61#define BEGIN_LIBPATH 1
62#endif
63
64#ifndef END_LIBPATH
65#define END_LIBPATH 2
66#endif
67
68#ifndef ORD_DOS32QUERYEXTLIBPATH
69#define ORD_DOS32QUERYEXTLIBPATH 874
70#endif
71
72BOOL IsFm2Window(HWND hwnd, BOOL chkTid)
73{
74 PIB *ppib;
75 TIB *ptib;
76 BOOL yes;
77 APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
78
79 if (rc) {
80 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
81 "DosGetInfoBlocks");
82 yes = FALSE;
83 }
84 else {
85 PID pid;
86 TID tid;
87
88 // Check window owned by FM2 process
89 // Check say same thread too, if requested
90 // OK for window to be dead - just return FALSE
91 yes = WinQueryWindowProcess(hwnd, &pid, &tid) &&
92 pid == ppib->pib_ulpid &&
93 (!chkTid || tid == ptib->tib_ptib2->tib2_ultid);
94 }
95 return yes;
96}
97
98VOID SetShiftState(VOID)
99{
100 shiftstate = 0;
101 if (WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
102 shiftstate |= KC_CTRL;
103 if (WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
104 shiftstate |= KC_SHIFT;
105 if (WinGetKeyState(HWND_DESKTOP, VK_ALT) & 0x8000)
106 shiftstate |= KC_ALT;
107}
108
109void EmphasizeButton(HWND hwnd, BOOL on)
110{
111 HPS hps = DrgGetPS(hwnd);
112
113 // fixme to complain?
114 if (hps) {
115 POINTL ptl;
116 SWP swp;
117
118 WinQueryWindowPos(hwnd, &swp);
119 ptl.x = 1;
120 ptl.y = 1;
121 GpiMove(hps, &ptl);
122 GpiSetColor(hps, on ? CLR_BLACK : CLR_PALEGRAY);
123 ptl.x = swp.cx - 2;
124 ptl.y = swp.cy - 2;
125 GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
126 DrgReleasePS(hps);
127 if (remove) //fixme always true
128 WinInvalidateRect(hwnd, NULL, FALSE);
129 }
130}
131
132void DrawTargetEmphasis(HWND hwnd, BOOL on)
133{
134 HPS hps = DrgGetPS(WinQueryWindow(hwnd, QW_PARENT));
135
136 if (hps) {
137 BoxWindow(hwnd, hps, on ? CLR_BLACK : CLR_PALEGRAY);
138 DrgReleasePS(hps);
139 }
140}
141
142void BoxWindow(HWND hwnd, HPS hps, LONG color)
143{
144 POINTL ptl;
145 SWP swp;
146 BOOL releaseme = FALSE;
147
148 if (!hps) {
149 hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
150 releaseme = TRUE;
151 }
152 if (hps && WinQueryWindowPos(hwnd, &swp)) {
153 ptl.x = swp.x - 2;
154 ptl.y = swp.y - 2;
155 GpiMove(hps, &ptl);
156 GpiSetColor(hps, color);
157 ptl.x = swp.x + swp.cx + 1;
158 ptl.y = swp.y + swp.cy + 1;
159 GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
160 }
161 if (releaseme && hps)
162 WinReleasePS(hps);
163}
164
165void PaintSTextWindow(HWND hwnd, HPS hps)
166{
167 /*
168 * paint a text window such that the rightmost part of the text is
169 * always visible even if the text length exceeds the length of the
170 * window -- otherwise, paint the window so that it is left-justified
171 * and vertically centered.
172 */
173
174 char *s = NULL;
175 long len;
176 POINTL aptl[TXTBOX_COUNT], ptl;
177 RECTL rcl;
178 char *p;
179 BOOL releaseme = FALSE;
180
181 if (!hps) {
182 releaseme = TRUE;
183 hps = WinGetPS(hwnd);
184 }
185 if (hps) {
186 WinQueryWindowRect(hwnd, &rcl);
187 WinFillRect(hps, &rcl, CLR_PALEGRAY);
188 len = WinQueryWindowTextLength(hwnd);
189 if (len)
190 s = xmalloc(len + 1, pszSrcFile, __LINE__);
191 if (s) {
192 *s = 0;
193 WinQueryWindowText(hwnd, CCHMAXPATH, s);
194 if (*s) {
195 rcl.xRight -= 3;
196 p = s;
197 GpiQueryTextBox(hps, 3, "...", TXTBOX_COUNT, aptl);
198 len = aptl[TXTBOX_TOPRIGHT].x;
199 do {
200 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
201 if (aptl[TXTBOX_TOPRIGHT].x > (rcl.xRight - (p != s ? len : 0)))
202 p++;
203 else
204 break;
205 }
206 while (*p);
207 if (*p) {
208 GpiSetMix(hps, FM_OVERPAINT);
209 GpiSetColor(hps, CLR_BLACK);
210 ptl.x = 3;
211 ptl.y = ((rcl.yTop / 2) -
212 ((aptl[TXTBOX_TOPRIGHT].y +
213 aptl[TXTBOX_BOTTOMLEFT].y) / 2));
214 GpiMove(hps, &ptl);
215 if (p != s)
216 GpiCharString(hps, 3, "...");
217 GpiCharString(hps, strlen(p), p);
218 }
219 }
220 free(s);
221 }
222 if (releaseme)
223 WinReleasePS(hps);
224 }
225}
226
227VOID PaintRecessedWindow(HWND hwnd, HPS hps, BOOL outtie, BOOL dbl)
228{
229 /*
230 * paint a recessed box around the window
231 * two pixels width required around window for painting...
232 */
233 BOOL releaseme = FALSE;
234
235 if (!hps) {
236 hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
237 releaseme = TRUE;
238 }
239 if (hps) {
240
241 POINTL ptl;
242 SWP swp;
243
244 WinQueryWindowPos(hwnd, &swp);
245 ptl.x = swp.x - 1;
246 ptl.y = swp.y - 1;
247 GpiMove(hps, &ptl);
248 if (!outtie)
249 GpiSetColor(hps, CLR_WHITE);
250 else
251 GpiSetColor(hps, CLR_DARKGRAY);
252 ptl.x = swp.x + swp.cx;
253 GpiLine(hps, &ptl);
254 ptl.y = swp.y + swp.cy;
255 GpiLine(hps, &ptl);
256 if (dbl) {
257 ptl.x = swp.x - 2;
258 ptl.y = swp.y - 2;
259 GpiMove(hps, &ptl);
260 ptl.x = swp.x + swp.cx + 1;
261 GpiLine(hps, &ptl);
262 ptl.y = swp.y + swp.cy + 1;
263 GpiLine(hps, &ptl);
264 }
265 if (!outtie)
266 GpiSetColor(hps, CLR_DARKGRAY);
267 else
268 GpiSetColor(hps, CLR_WHITE);
269 if (dbl) {
270 ptl.x = swp.x - 2;
271 GpiLine(hps, &ptl);
272 ptl.y = swp.y - 2;
273 GpiLine(hps, &ptl);
274 ptl.x = swp.x + swp.cx;
275 ptl.y = swp.y + swp.cy;
276 GpiMove(hps, &ptl);
277 }
278 ptl.x = swp.x - 1;
279 GpiLine(hps, &ptl);
280 ptl.y = swp.y - 1;
281 GpiLine(hps, &ptl);
282 GpiSetColor(hps, CLR_PALEGRAY);
283 ptl.x = swp.x - (2 + (dbl != FALSE));
284 ptl.y = swp.y - (2 + (dbl != FALSE));
285 GpiMove(hps, &ptl);
286 ptl.x = swp.x + swp.cx + (1 + (dbl != FALSE));
287 GpiLine(hps, &ptl);
288 ptl.y = swp.y + swp.cy + (1 + (dbl != FALSE));
289 GpiLine(hps, &ptl);
290 ptl.x = swp.x - (2 + (dbl != FALSE));
291 GpiLine(hps, &ptl);
292 ptl.y = swp.y - (2 + (dbl != FALSE));
293 GpiLine(hps, &ptl);
294 if (releaseme)
295 WinReleasePS(hps);
296 }
297}
298
299BOOL AdjustCnrColVis(HWND hwndCnr, CHAR * title, BOOL visible, BOOL toggle)
300{
301 PFIELDINFO pfi = (PFIELDINFO) WinSendMsg(hwndCnr,
302 CM_QUERYDETAILFIELDINFO,
303 MPVOID, MPFROMSHORT(CMA_FIRST));
304
305 while (pfi) {
306 if (!strcmp(pfi->pTitleData, title)) {
307 if (toggle) {
308 if (pfi->flData & CFA_INVISIBLE)
309 pfi->flData &= (~CFA_INVISIBLE);
310 else
311 pfi->flData |= CFA_INVISIBLE;
312 return !(pfi->flData & CFA_INVISIBLE);
313 }
314 else {
315 if (visible)
316 pfi->flData &= (~CFA_INVISIBLE);
317 else
318 pfi->flData |= CFA_INVISIBLE;
319 }
320 return TRUE;
321 }
322 pfi = pfi->pNextFieldInfo;
323 }
324 return FALSE;
325}
326
327BOOL AdjustCnrColRO(HWND hwndCnr, CHAR * title, BOOL readonly, BOOL toggle)
328{
329 PFIELDINFO pfi = (PFIELDINFO) WinSendMsg(hwndCnr,
330 CM_QUERYDETAILFIELDINFO,
331 MPVOID, MPFROMSHORT(CMA_FIRST));
332
333 while (pfi) {
334 if (!strcmp(pfi->pTitleData, title)) {
335 if (toggle) {
336 if (pfi->flData & CFA_FIREADONLY)
337 pfi->flData &= (~CFA_FIREADONLY);
338 else
339 pfi->flData |= CFA_FIREADONLY;
340 return (pfi->flData & CFA_FIREADONLY);
341 }
342 else {
343 if (!readonly)
344 pfi->flData &= (~CFA_FIREADONLY);
345 else
346 pfi->flData |= CFA_FIREADONLY;
347 }
348 return TRUE;
349 }
350 pfi = pfi->pNextFieldInfo;
351 }
352 return FALSE;
353}
354
355VOID AdjustCnrColsForFSType(HWND hwndCnr, CHAR * directory, DIRCNRDATA * dcd)
356{
357 CHAR FileSystem[CCHMAXPATH];
358 INT x;
359 BOOL hasCreateDT;
360 BOOL hasAccessDT;
361 BOOL hasLongNames;
362 BOOL *pBool;
363
364 if (!directory || !*directory)
365 return;
366 x = CheckDrive(toupper(*directory), FileSystem, NULL);
367 if (x != -1) {
368 if (!stricmp(FileSystem, HPFS) ||
369 !stricmp(FileSystem, JFS) ||
370 !stricmp(FileSystem, FAT32) ||
371 !stricmp(FileSystem, RAMFS) ||
372 !stricmp(FileSystem, NDFS32) ||
373 !stricmp(FileSystem, NTFS) ||
374 !stricmp(FileSystem, HPFS386)) {
375 hasCreateDT = TRUE;
376 hasAccessDT = TRUE;
377 hasLongNames = TRUE;
378 }
379 else if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS)) {
380 hasCreateDT = TRUE;
381 hasAccessDT = FALSE;
382 hasLongNames = FALSE;
383 }
384 else {
385 // Assume FAT
386 hasCreateDT = FALSE;
387 hasAccessDT = FALSE;
388 hasLongNames = FALSE;
389 }
390 }
391 else {
392 // Assume FAT
393 hasCreateDT = FALSE;
394 hasAccessDT = FALSE;
395 hasLongNames = FALSE;
396 }
397 pBool = dcd ? &dcd->detailsladate : &detailsladate;
398 AdjustCnrColVis(hwndCnr,
399 GetPString(IDS_LADATE),
400 *pBool ? hasAccessDT : FALSE,
401 FALSE);
402 pBool = dcd ? &dcd->detailslatime : &detailslatime;
403 AdjustCnrColVis(hwndCnr,
404 GetPString(IDS_LATIME),
405 *pBool ? hasAccessDT : FALSE,
406 FALSE);
407 pBool = dcd ? &dcd->detailscrdate : &detailscrdate;
408 AdjustCnrColVis(hwndCnr,
409 GetPString(IDS_CRDATE),
410 *pBool ? hasCreateDT : FALSE,
411 FALSE);
412 pBool = dcd ? &dcd->detailscrtime : &detailscrtime;
413 AdjustCnrColVis(hwndCnr,
414 GetPString(IDS_CRTIME),
415 *pBool ? hasCreateDT : FALSE,
416 FALSE);
417 pBool = dcd ? &dcd->detailslongname : &detailslongname;
418 AdjustCnrColVis(hwndCnr,
419 GetPString(IDS_LNAME),
420 *pBool ? hasLongNames : FALSE,
421 FALSE);
422 WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
423}
424
425VOID AdjustCnrColsForPref(HWND hwndCnr, CHAR * directory, DIRCNRDATA * dcd,
426 BOOL compare)
427{
428 BOOL *bool;
429
430 bool = dcd ? &dcd->detailssubject : &detailssubject;
431 AdjustCnrColVis(hwndCnr,
432 compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ),
433 *bool,
434 FALSE);
435
436 bool = dcd ? &dcd->detailsattr : &detailsattr;
437 AdjustCnrColVis(hwndCnr, GetPString(IDS_ATTR), *bool, FALSE);
438 bool = dcd ? &dcd->detailsicon : &detailsicon;
439 AdjustCnrColVis(hwndCnr, GetPString(IDS_ICON), *bool, FALSE);
440 bool = dcd ? &dcd->detailslwdate : &detailslwdate;
441 AdjustCnrColVis(hwndCnr, GetPString(IDS_LWDATE), *bool, FALSE);
442 bool = dcd ? &dcd->detailslwtime : &detailslwtime;
443 AdjustCnrColVis(hwndCnr, GetPString(IDS_LWTIME), *bool, FALSE);
444 bool = dcd ? &dcd->detailsea : &detailsea;
445 AdjustCnrColVis(hwndCnr, GetPString(IDS_EA), *bool, FALSE);
446 bool = dcd ? &dcd->detailssize : &detailssize;
447 AdjustCnrColVis(hwndCnr, GetPString(IDS_SIZE), *bool, FALSE);
448
449 if (!directory) {
450 bool = dcd ? &dcd->detailsladate : &detailsladate;
451 AdjustCnrColVis(hwndCnr, GetPString(IDS_LADATE), *bool, FALSE);
452 bool = dcd ? &dcd->detailslatime : &detailslatime;
453 AdjustCnrColVis(hwndCnr, GetPString(IDS_LATIME), *bool, FALSE);
454 bool = dcd ? &dcd->detailscrdate : &detailscrdate;
455 AdjustCnrColVis(hwndCnr, GetPString(IDS_CRDATE), *bool, FALSE);
456 bool = dcd ? &dcd->detailscrtime : &detailscrtime;
457 AdjustCnrColVis(hwndCnr, GetPString(IDS_CRTIME), *bool, FALSE);
458 bool = dcd ? &dcd->detailslongname : &detailslongname;
459 AdjustCnrColVis(hwndCnr, GetPString(IDS_LNAME), *bool, FALSE);
460 WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
461 }
462 else
463 AdjustCnrColsForFSType(hwndCnr, directory, dcd);
464}
465
466BOOL SetCnrCols(HWND hwndCnr, BOOL isCompCnr)
467{
468 BOOL fSuccess = TRUE;
469 PFIELDINFO pfi, pfiLastLeftCol, pfiIconCol;
470
471 // Allocate storage for container column data
472
473 pfi = WinSendMsg(hwndCnr, CM_ALLOCDETAILFIELDINFO,
474 MPFROMLONG(CONTAINER_COLUMNS), NULL);
475
476 if (!pfi) {
477 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCDETAILFIELDINFO");
478 fSuccess = FALSE;
479 }
480 else {
481
482 PFIELDINFO pfiFirst;
483 FIELDINFOINSERT fii;
484
485 // Store original value of pfi so we won't lose it when it changes.
486 // This will be needed on the CM_INSERTDETAILFIELDINFO message.
487
488 pfiFirst = pfi;
489
490 // Fill in column information for the icon column
491
492 pfi->flData = CFA_BITMAPORICON | CFA_CENTER | CFA_FIREADONLY;
493 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
494 pfi->pTitleData = GetPString(IDS_ICON);
495 pfi->offStruct = FIELDOFFSET(MINIRECORDCORE, hptrIcon);
496
497 pfiIconCol = pfi;
498
499 // Fill in column information for the file name. Note that we are
500 // using the pszDisplayName variable rather than pszFileName. We do this
501 // because the container does not always display the full path file name.
502
503 pfi = pfi->pNextFieldInfo;
504 pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
505 pfi->flTitle = CFA_LEFT;
506 pfi->pTitleData = GetPString(IDS_FILENAME);
507 pfi->offStruct = FIELDOFFSET(CNRITEM, pszDisplayName);
508
509 // Fill in column information for the longname.
510
511 pfi = pfi->pNextFieldInfo;
512 pfi->flData = CFA_STRING | CFA_LEFT;
513 pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
514 pfi->pTitleData = GetPString(IDS_LNAME);
515 pfi->offStruct = FIELDOFFSET(CNRITEM, pszLongName);
516
517 // Fill in column info for subjects
518
519 if (fSubjectInLeftPane) {
520 pfi = pfi->pNextFieldInfo;
521 pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
522 if (isCompCnr)
523 pfi->flData |= CFA_FIREADONLY;
524 pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
525 pfi->pTitleData = isCompCnr ? GetPString(IDS_STATUS) :
526 GetPString(IDS_SUBJ);
527 pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject);
528 pfi->cxWidth = SubjectDisplayWidth;
529
530 // Store the current pfi value as that will be used to indicate the
531 // last column in the lefthand container window (we have a splitbar)
532
533 pfiLastLeftCol = pfi;
534 }
535 else {
536 // Store the current pfi value as that will be used to indicate the
537 // last column in the lefthand container window (we have a splitbar)
538
539 pfiLastLeftCol = pfi;
540 pfi = pfi->pNextFieldInfo;
541 pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
542 if (isCompCnr)
543 pfi->flData |= CFA_FIREADONLY;
544 pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
545 pfi->pTitleData = isCompCnr ? GetPString(IDS_STATUS) :
546 GetPString(IDS_SUBJ);
547 pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject);
548 pfi->cxWidth = SubjectDisplayWidth;
549 }
550
551 // Fill in column information for the file size
552
553 pfi = pfi->pNextFieldInfo;
554 pfi->flData = CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
555 pfi->flTitle = CFA_CENTER;
556 pfi->pTitleData = GetPString(IDS_SIZE);
557 pfi->offStruct = FIELDOFFSET(CNRITEM, cbFile);
558
559 // Fill in the column information for the file's ea size
560
561 pfi = pfi->pNextFieldInfo;
562 pfi->flData = CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
563 pfi->flTitle = CFA_CENTER;
564 pfi->pTitleData = GetPString(IDS_EA);
565 pfi->offStruct = FIELDOFFSET(CNRITEM, easize);
566
567 // Fill in the column information for the file attribute
568
569 pfi = pfi->pNextFieldInfo;
570 pfi->flData = CFA_STRING | CFA_CENTER | CFA_SEPARATOR | CFA_FIREADONLY;
571 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
572 pfi->pTitleData = GetPString(IDS_ATTR);
573 pfi->offStruct = FIELDOFFSET(CNRITEM, pszDispAttr);
574
575 // Fill in column information for last write file date
576
577 pfi = pfi->pNextFieldInfo;
578 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
579 pfi->flTitle = CFA_CENTER;
580 pfi->pTitleData = GetPString(IDS_LWDATE);
581 pfi->offStruct = FIELDOFFSET(CNRITEM, date);
582
583 // Fill in column information for the last write file time
584
585 pfi = pfi->pNextFieldInfo;
586 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
587 pfi->flTitle = CFA_CENTER;
588 pfi->pTitleData = GetPString(IDS_LWTIME);
589 pfi->offStruct = FIELDOFFSET(CNRITEM, time);
590
591 // Fill in column information for last access file date
592
593 pfi = pfi->pNextFieldInfo;
594 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
595 pfi->flTitle = CFA_CENTER;
596 pfi->pTitleData = GetPString(IDS_LADATE);
597 pfi->offStruct = FIELDOFFSET(CNRITEM, ladate);
598
599 // Fill in column information for the last access file time
600
601 pfi = pfi->pNextFieldInfo;
602 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
603 pfi->flTitle = CFA_CENTER;
604 pfi->pTitleData = GetPString(IDS_LATIME);
605 pfi->offStruct = FIELDOFFSET(CNRITEM, latime);
606
607 // Fill in column information for create file date
608
609 pfi = pfi->pNextFieldInfo;
610 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
611 pfi->flTitle = CFA_CENTER;
612 pfi->pTitleData = GetPString(IDS_CRDATE);
613 pfi->offStruct = FIELDOFFSET(CNRITEM, crdate);
614
615 // Fill in column information for the create file time
616
617 pfi = pfi->pNextFieldInfo;
618 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_FIREADONLY;
619 pfi->flTitle = CFA_CENTER;
620 pfi->pTitleData = GetPString(IDS_CRTIME);
621 pfi->offStruct = FIELDOFFSET(CNRITEM, crtime);
622
623 // Use the CM_INSERTDETAILFIELDINFO message to tell the container
624 // all the column information it needs to function properly. Place
625 // this column info first in the column list and update the display
626 // after they are inserted (fInvalidateFieldInfo = TRUE)
627
628 (void)memset(&fii, 0, sizeof(FIELDINFOINSERT));
629
630 fii.cb = sizeof(FIELDINFOINSERT);
631 fii.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
632 fii.cFieldInfoInsert = (SHORT) CONTAINER_COLUMNS;
633 fii.fInvalidateFieldInfo = TRUE;
634
635 if (!WinSendMsg(hwndCnr, CM_INSERTDETAILFIELDINFO, MPFROMP(pfiFirst),
636 MPFROMP(&fii))) {
637 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_INSERTDETAILFIELDINFO");
638 fSuccess = FALSE;
639 }
640 }
641
642 if (fSuccess) {
643
644 CNRINFO cnri;
645 ULONG size;
646
647 // Tell the container about the splitbar and where it goes
648
649 cnri.cb = sizeof(CNRINFO);
650 cnri.pFieldInfoLast = pfiLastLeftCol;
651 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
652 cnri.pFieldInfoObject = pfiIconCol;
653 size = sizeof(LONG);
654 PrfQueryProfileData(fmprof,
655 appname, "CnrSplitBar", &cnri.xVertSplitbar, &size);
656 if (cnri.xVertSplitbar <= 0)
657 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
658 if (!WinSendMsg(hwndCnr, CM_SETCNRINFO, MPFROMP(&cnri),
659 MPFROMLONG(CMA_PFIELDINFOLAST | CMA_PFIELDINFOOBJECT |
660 CMA_XVERTSPLITBAR))) {
661 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_SETCNRINFO");
662 fSuccess = FALSE;
663 }
664 }
665
666 return fSuccess;
667}
668
669MRESULT CnrDirectEdit(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
670{
671 switch (SHORT2FROMMP(mp1)) {
672 case CN_BEGINEDIT:
673 if (mp2) {
674 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
675 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
676
677 if (pci &&
678 (INT) pci != -1 &&
679 !IsRoot(pci->pszFileName) &&
680 !(pci->flags & RECFLAGS_ENV) && !(pci->flags & RECFLAGS_UNDERENV)) {
681 if (!pfi || pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName)) {
682 PostMsg(hwnd, UM_FIXEDITNAME, MPFROMP(pci->pszFileName), MPVOID);
683 }
684 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, pszSubject))
685 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(40), MPVOID);
686 else
687 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
688 }
689 else
690 PostMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
691 }
692 break;
693
694 case CN_REALLOCPSZ:
695 if (mp2) {
696 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
697 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
698 CHAR szData[CCHMAXPATH], testname[CCHMAXPATH];
699 HWND hwndMLE = WinWindowFromID(hwnd, CID_MLE);
700
701 if (pci && (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
702 if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszSubject)) {
703
704 APIRET rc;
705 EAOP2 eaop;
706 PFEA2LIST pfealist = NULL;
707 CHAR szSubject[1048];
708 ULONG ealen;
709 USHORT len;
710 CHAR *eaval;
711 LONG retlen;
712
713 retlen = WinQueryWindowText(hwndMLE, sizeof(szSubject), szSubject);
714 szSubject[retlen + 1] = 0;
715 //chop_at_crnl(szSubject);
716 bstrip(szSubject);
717 pci->pszSubject = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__);
718 WinSetWindowText(hwndMLE, szSubject);
719 len = strlen(szSubject);
720 if (len)
721 ealen = sizeof(FEA2LIST) + 9 + len + 4;
722 else
723 ealen = sizeof(FEALIST) + 9;
724 rc = DosAllocMem((PPVOID) & pfealist, ealen + 64,
725 OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE);
726 if (rc)
727 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile,
728 __LINE__, GetPString(IDS_OUTOFMEMORY));
729 else {
730 memset(pfealist, 0, ealen + 1);
731 pfealist->cbList = ealen;
732 pfealist->list[0].oNextEntryOffset = 0;
733 pfealist->list[0].fEA = 0;
734 pfealist->list[0].cbName = 8;
735 strcpy(pfealist->list[0].szName, SUBJECT);
736 if (len) {
737 eaval = pfealist->list[0].szName + 9;
738 *(USHORT *) eaval = (USHORT) EAT_ASCII;
739 eaval += sizeof(USHORT);
740 *(USHORT *) eaval = (USHORT) len;
741 eaval += sizeof(USHORT);
742 memcpy(eaval, szSubject, len);
743 pfealist->list[0].cbValue = len + (sizeof(USHORT) * 2);
744 }
745 else
746 pfealist->list[0].cbValue = 0;
747 eaop.fpGEA2List = (PGEA2LIST) 0;
748 eaop.fpFEA2List = pfealist;
749 eaop.oError = 0L;
750 rc = xDosSetPathInfo(pci->pszFileName,
751 FIL_QUERYEASIZE,
752 (PVOID) & eaop, sizeof(EAOP2), DSPI_WRTTHRU);
753 DosFreeMem(pfealist);
754 if (rc)
755 return FALSE;
756 }
757 return (MRESULT) TRUE;
758 }
759 else if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszLongName)) {
760
761 CHAR longname[CCHMAXPATHCOMP];
762 LONG retlen;
763
764 *longname = 0;
765 retlen = WinQueryWindowText(hwndMLE, sizeof(longname), longname);
766 longname[retlen + 1] = 0;
767 //chop_at_crnl(longname);
768 pci->pszLongName = xrealloc(pci->pszLongName, retlen + 1, pszSrcFile, __LINE__);
769 WinSetWindowText(hwndMLE, longname);
770 pci->pszFileName = xrealloc(pci->pszFileName, retlen + 1, pszSrcFile, __LINE__);
771 return (MRESULT) WriteLongName(pci->pszFileName, longname);
772 }
773 else {
774 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
775 if (strchr(szData, '?') ||
776 strchr(szData, '*') || IsRoot(pci->pszFileName))
777 return (MRESULT) FALSE;
778 /* If the text changed, rename the file system object. */
779 chop_at_crnl(szData);
780 bstrip(szData);
781 if (!IsFullName(szData))
782 Runtime_Error(pszSrcFile, __LINE__, "bad name");
783 else {
784 if (DosQueryPathInfo(szData,
785 FIL_QUERYFULLNAME,
786 testname, sizeof(testname)))
787 return FALSE;
788 if (DosQueryPathInfo(pci->pszFileName,
789 FIL_QUERYFULLNAME, szData, sizeof(szData))){
790 pci->pszFileName = xrealloc(pci->pszFileName, sizeof(szData), pszSrcFile, __LINE__);
791 strcpy(szData, pci->pszFileName);
792 }
793 WinSetWindowText(hwndMLE, szData);
794 if (strcmp(szData, testname)) {
795 if (stricmp(szData, testname) && IsFile(testname) != -1) {
796 DosBeep(50, 100); /* exists; disallow */
797 return (MRESULT) FALSE;
798 }
799 if (docopyf(MOVE, szData, "%s", testname))
800 Runtime_Error(pszSrcFile, __LINE__, "docopyf");
801 else {
802 CHAR *filename;
803
804 filename = xstrdup(testname, pszSrcFile, __LINE__);
805 if (filename) {
806 if (!PostMsg(hwnd,
807 UM_FIXEDITNAME, MPVOID, MPFROMP(filename)))
808 free(filename);
809 }
810 if (stricmp(testname, pci->pszFileName)) {
811 PostMsg(hwnd, UM_FIXEDITNAME, MPFROMLONG(-1), MPFROMP(pci));
812 filename = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
813 if (filename) {
814 if (!PostMsg(hwnd,
815 UM_FIXEDITNAME, MPVOID, MPFROMP(filename)))
816 free(filename);
817 }
818 }
819 }
820 }
821 }
822 }
823 }
824 }
825 return FALSE;
826
827 case CN_ENDEDIT:
828 if (mp2) {
829 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
830 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
831
832 if (pci && (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
833 WinSendMsg(hwnd,
834 CM_INVALIDATERECORD,
835 MPFROMP(&pci),
836 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
837 if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName))
838 PostMsg(hwnd, UM_SORTRECORD, MPVOID, MPVOID);
839 }
840 else {
841 USHORT cmd = 0;
842
843 if (!pfi || pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName))
844 cmd = IDM_SORTSMARTNAME;
845 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, cbFile))
846 cmd = IDM_SORTSIZE;
847 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, easize))
848 cmd = IDM_SORTEASIZE;
849 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, date))
850 cmd = IDM_SORTLWDATE;
851 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, time))
852 cmd = IDM_SORTLWDATE;
853 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, ladate))
854 cmd = IDM_SORTLADATE;
855 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, latime))
856 cmd = IDM_SORTLADATE;
857 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, crdate))
858 cmd = IDM_SORTCRDATE;
859 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, crtime))
860 cmd = IDM_SORTCRDATE;
861 if (cmd)
862 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
863 }
864 }
865 break;
866 }
867 return (MRESULT) - 1;
868}
869
870BOOL SetMenuCheck(HWND hwndMenu, USHORT id, BOOL * bool, BOOL toggle,
871 CHAR * savename)
872{
873 if (toggle) {
874 *bool = *bool ? FALSE : TRUE;
875 if (savename && *savename)
876 PrfWriteProfileData(fmprof, appname, savename, bool, sizeof(BOOL));
877 }
878 WinSendMsg(hwndMenu, MM_SETITEMATTR,
879 MPFROM2SHORT(id, 1),
880 MPFROM2SHORT(MIA_CHECKED, (*bool ? MIA_CHECKED : 0)));
881 return *bool;
882}
883
884//== disable_menuitem() disable or enable_menuitem ==
885
886VOID disable_menuitem(HWND hwndMenu, USHORT id, BOOL disable)
887{
888 WinSendMsg(hwndMenu, MM_SETITEMATTR,
889 MPFROM2SHORT(id, TRUE),
890 MPFROM2SHORT(MIA_DISABLED, (disable ? MIA_DISABLED : 0)));
891}
892
893//== ViewHelp() invoke view.exe, return TRUE if OK ==
894
895BOOL ViewHelp(CHAR * filename)
896{
897 CHAR s[CCHMAXPATH + 81];
898 FILE *fp;
899 INT ret = -1;
900
901 fp = _fsopen(filename, "rb", SH_DENYNO);
902 if (fp) {
903 *s = 0;
904 fread(s, 1, 3, fp);
905 if (*s != 'H' || s[1] != 'S' || s[2] != 'P') {
906 fclose(fp);
907 return FALSE;
908 }
909 fclose(fp);
910 ret = runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, NULL, NULL,
911 "VIEW.EXE \"%s\"", filename);
912 }
913
914 return (ret != -1);
915}
916
917//== ExecFile() run file, return 1 if OK 0 if skipped -1 if can't run ==
918
919INT ExecFile(HWND hwnd, CHAR * filename)
920{
921 EXECARGS ex;
922 CHAR cl[1001], path[CCHMAXPATH], *p;
923 APIRET ret;
924 static INT lastflags = 0;
925
926 strcpy(path, filename);
927 p = strrchr(path, '\\');
928 if (!p)
929 p = strrchr(path, ':');
930 if (p) {
931 if (*p == ':') {
932 p++;
933 *p = '\\';
934 p++;
935 }
936 *p = 0;
937 }
938 else
939 *path = 0;
940 *cl = 0;
941 BldQuotedFileName(cl, filename);
942 // *cl = 0;
943 // if (needs_quoting(filename))
944 // strcat(cl, "\"");
945 // strcat(cl, filename);
946 // if (needs_quoting(filename))
947 // strcat(cl, "\"");
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, 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 return;
1484 }
1485 else if (*viewer) {
1486
1487 CHAR *list[2];
1488
1489 list[0] = filename;
1490 list[1] = NULL;
1491 ExecOnList(hwnd, viewer,
1492 WINDOWED | SEPARATE | (fViewChild ? CHILD : 0),
1493 NULL, list, NULL);
1494 return;
1495 }
1496 StartMLEEditor(HWND_DESKTOP, 5, filename, (HWND) 0);
1497 }
1498}
1499
1500VOID QuickEdit(HWND hwnd, CHAR * filename)
1501{
1502 if (filename && IsFile(filename) == 1) {
1503 if (TestBinary(filename) && *bined) {
1504
1505 CHAR *list[2];
1506
1507 list[0] = filename;
1508 list[1] = NULL;
1509 ExecOnList(hwnd, bined, WINDOWED | SEPARATE, NULL, list, NULL);
1510 return;
1511 }
1512 else if (*editor) {
1513
1514 CHAR *list[2];
1515
1516 list[0] = filename;
1517 list[1] = NULL;
1518 ExecOnList(hwnd, editor, WINDOWED | SEPARATE, NULL, list, NULL);
1519 return;
1520 }
1521 StartMLEEditor(HWND_DESKTOP, 4, filename, (HWND) 0);
1522 }
1523}
1524#endif
1525
1526VOID PortholeInit(HWND hwndNew, MPARAM mp1, MPARAM mp2)
1527{
1528 static HWND DefMenu = (HWND) 0;
1529 HWND hwndMenu = (HWND) mp2;
1530
1531 {
1532 ULONG style;
1533
1534 style = WinQueryWindowULong(hwndMenu, QWL_STYLE);
1535 if (!(style & MS_ACTIONBAR))
1536 return;
1537 }
1538
1539 switch (SHORT1FROMMP(mp1)) {
1540 case 0:
1541 {
1542 HWND hwndNow;
1543 MENUITEM mi;
1544 ULONG ulStyle;
1545
1546 memset(&mi, 0, sizeof(mi));
1547 mi.iPosition = MIT_END;
1548 mi.afStyle = MIS_TEXT;
1549 WinSendMsg(hwndMenu, MM_QUERYITEM,
1550 MPFROM2SHORT(IDM_FILESMENU, TRUE), MPFROMP(&mi));
1551 if (!DefMenu)
1552 DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
1553 hwndNow = mi.hwndSubMenu;
1554 mi.hwndSubMenu = hwndNew;
1555 if (!mi.hwndSubMenu)
1556 mi.hwndSubMenu = DefMenu;
1557 WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
1558 WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
1559 WinSetOwner(mi.hwndSubMenu, hwndMenu);
1560 WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
1561 WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_FILESMENU);
1562 mi.afStyle = MIS_SUBMENU;
1563 ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
1564 ulStyle &= -WS_SAVEBITS;
1565 ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
1566 WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
1567 WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
1568 }
1569 break;
1570
1571 case 1:
1572 {
1573 HWND hwndNow;
1574 MENUITEM mi;
1575 ULONG ulStyle;
1576
1577 memset(&mi, 0, sizeof(mi));
1578 mi.iPosition = MIT_END;
1579 mi.afStyle = MIS_TEXT;
1580 WinSendMsg(hwndMenu, MM_QUERYITEM,
1581 MPFROM2SHORT(IDM_VIEWSMENU, TRUE), MPFROMP(&mi));
1582 if (!DefMenu)
1583 DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
1584 hwndNow = mi.hwndSubMenu;
1585 mi.hwndSubMenu = hwndNew;
1586 if (!mi.hwndSubMenu)
1587 mi.hwndSubMenu = DefMenu;
1588 WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
1589 WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
1590 WinSetOwner(mi.hwndSubMenu, hwndMenu);
1591 WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
1592 WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_VIEWSMENU);
1593 mi.afStyle = MIS_SUBMENU;
1594 ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
1595 ulStyle &= -WS_SAVEBITS;
1596 ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
1597 WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
1598 WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
1599 }
1600 break;
1601 }
1602}
1603
1604HWND CheckMenu(HWND * hwndMenu, USHORT id)
1605{
1606 /* load and adjust menus as required */
1607 if (!*hwndMenu || !WinIsWindow((HAB) 0, *hwndMenu)) {
1608 *hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
1609 if (hwndMenu == &DirMenu) {
1610 WinSetWindowUShort(DirMenu, QWS_ID, IDM_FILESMENU);
1611 SetConditionalCascade(DirMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1612 SetConditionalCascade(DirMenu, IDM_COPYMENU, IDM_COPY);
1613 SetConditionalCascade(DirMenu, IDM_MOVEMENU, IDM_MOVE);
1614 SetConditionalCascade(DirMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1615 SetConditionalCascade(DirMenu, IDM_VIEWSUBMENU, IDM_INFO);
1616 SetConditionalCascade(DirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1617 SetConditionalCascade(DirMenu, IDM_DELETESUBMENU,
1618 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
1619 SetConditionalCascade(DirMenu, IDM_MISCSUBMENU, IDM_SIZES);
1620 SetConditionalCascade(DirMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
1621 if (fWorkPlace) {
1622 WinSendMsg(DirMenu, MM_DELETEITEM,
1623 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1624 WinSendMsg(DirMenu, MM_DELETEITEM,
1625 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1626 }
1627 }
1628 else if (hwndMenu == &TreeMenu) {
1629 WinSetWindowUShort(TreeMenu, QWS_ID, IDM_FILESMENU);
1630 SetConditionalCascade(TreeMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1631 SetConditionalCascade(TreeMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1632 SetConditionalCascade(TreeMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1633 SetConditionalCascade(TreeMenu, IDM_EXPANDSUBMENU, IDM_EXPAND);
1634 SetConditionalCascade(TreeMenu, IDM_MISCSUBMENU, IDM_SIZES);
1635 SetConditionalCascade(TreeMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
1636 if (fWorkPlace) {
1637 WinSendMsg(TreeMenu, MM_DELETEITEM,
1638 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1639 WinSendMsg(TreeMenu, MM_DELETEITEM,
1640 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1641 }
1642 }
1643 else if (hwndMenu == &ArcMenu) {
1644 WinSetWindowUShort(ArcMenu, QWS_ID, IDM_FILESMENU);
1645 SetConditionalCascade(ArcMenu, IDM_EXTRACTSUBMENU, IDM_EXTRACT);
1646 SetConditionalCascade(ArcMenu, IDM_EDITSUBMENU, IDM_EDIT);
1647 SetConditionalCascade(ArcMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1648 if (fWorkPlace)
1649 WinSendMsg(ArcMenu, MM_DELETEITEM,
1650 MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
1651 }
1652 else if (hwndMenu == &FileMenu) {
1653 WinSetWindowUShort(FileMenu, QWS_ID, IDM_FILESMENU);
1654 SetConditionalCascade(FileMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1655 SetConditionalCascade(FileMenu, IDM_COPYMENU, IDM_COPY);
1656 SetConditionalCascade(FileMenu, IDM_MOVEMENU, IDM_MOVE);
1657 SetConditionalCascade(FileMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1658 SetConditionalCascade(FileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1659 SetConditionalCascade(FileMenu, IDM_EDITSUBMENU, IDM_EDIT);
1660 SetConditionalCascade(FileMenu, IDM_COLLECTMENU, IDM_COLLECT);
1661 SetConditionalCascade(FileMenu, IDM_DELETESUBMENU,
1662 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
1663 SetConditionalCascade(FileMenu, IDM_OPENSUBMENU, IDM_OPENDEFAULT);
1664 SetConditionalCascade(FileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
1665 if (fWorkPlace) {
1666 WinSendMsg(FileMenu, MM_DELETEITEM,
1667 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1668 WinSendMsg(FileMenu, MM_DELETEITEM,
1669 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1670 }
1671 }
1672 else if (hwndMenu == &DirCnrMenu) {
1673 WinSetWindowUShort(DirCnrMenu, QWS_ID, IDM_VIEWSMENU);
1674 SetConditionalCascade(DirCnrMenu, IDM_MISCSUBMENU, IDM_SIZES);
1675 SetConditionalCascade(DirCnrMenu, IDM_OPENSUBMENU, IDM_OPENSETTINGSME);
1676 if (fWorkPlace)
1677 WinSendMsg(DirCnrMenu, MM_DELETEITEM,
1678 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1679 }
1680 else if (hwndMenu == &TreeCnrMenu) {
1681 WinSetWindowUShort(TreeCnrMenu, QWS_ID, IDM_VIEWSMENU);
1682 SetConditionalCascade(TreeCnrMenu, IDM_PARTITIONSMENU, IDM_PARTITION);
1683 }
1684 else if (hwndMenu == &ArcCnrMenu) {
1685 WinSetWindowUShort(ArcCnrMenu, QWS_ID, IDM_VIEWSMENU);
1686 SetConditionalCascade(ArcCnrMenu, IDM_EXTRACTSUBMENU, IDM_ARCEXTRACT);
1687 if (fWorkPlace)
1688 WinSendMsg(ArcCnrMenu, MM_DELETEITEM,
1689 MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
1690 }
1691 else if (hwndMenu == &CollectorCnrMenu) {
1692 WinSetWindowUShort(CollectorCnrMenu, QWS_ID, IDM_VIEWSMENU);
1693 SetConditionalCascade(CollectorCnrMenu, IDM_COLLECTMENU,
1694 IDM_COLLECTFROMCLIP);
1695 }
1696 else if (hwndMenu == &CollectorFileMenu) {
1697 WinSetWindowUShort(CollectorFileMenu, QWS_ID, IDM_FILESMENU);
1698 SetConditionalCascade(CollectorFileMenu, IDM_COMMANDSMENU,
1699 IDM_DOITYOURSELF);
1700 SetConditionalCascade(CollectorFileMenu, IDM_COPYMENU, IDM_COPY);
1701 SetConditionalCascade(CollectorFileMenu, IDM_MOVEMENU, IDM_MOVE);
1702 SetConditionalCascade(CollectorFileMenu, IDM_SAVESUBMENU,
1703 IDM_SAVETOCLIP);
1704 SetConditionalCascade(CollectorFileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1705 SetConditionalCascade(CollectorFileMenu, IDM_EDITSUBMENU, IDM_EDIT);
1706 SetConditionalCascade(CollectorFileMenu, IDM_DELETESUBMENU,
1707 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
1708 SetConditionalCascade(CollectorFileMenu, IDM_OPENSUBMENU,
1709 IDM_OPENDEFAULT);
1710 SetConditionalCascade(CollectorFileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
1711 if (fWorkPlace) {
1712 WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
1713 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1714 WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
1715 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1716 }
1717 }
1718 else if (hwndMenu == &CollectorDirMenu) {
1719 WinSetWindowUShort(CollectorDirMenu, QWS_ID, IDM_FILESMENU);
1720 SetConditionalCascade(CollectorDirMenu, IDM_COMMANDSMENU,
1721 IDM_DOITYOURSELF);
1722 SetConditionalCascade(CollectorDirMenu, IDM_COPYMENU, IDM_COPY);
1723 SetConditionalCascade(CollectorDirMenu, IDM_MOVEMENU, IDM_MOVE);
1724 SetConditionalCascade(CollectorDirMenu, IDM_SAVESUBMENU,
1725 IDM_SAVETOCLIP);
1726 SetConditionalCascade(CollectorDirMenu, IDM_VIEWSUBMENU, IDM_INFO);
1727 SetConditionalCascade(CollectorDirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1728 SetConditionalCascade(CollectorDirMenu, IDM_DELETESUBMENU,
1729 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
1730 SetConditionalCascade(CollectorDirMenu, IDM_MISCSUBMENU, IDM_SIZES);
1731 SetConditionalCascade(CollectorDirMenu, IDM_OPENSUBMENU,
1732 IDM_OPENWINDOW);
1733 if (fWorkPlace) {
1734 WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
1735 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1736 WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
1737 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1738 }
1739 }
1740 else if (hwndMenu == &MainPopupMenu) {
1741 WinSetWindowUShort(MainPopupMenu, QWS_ID, IDM_MAINPOPUP);
1742 SetConditionalCascade(MainPopupMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
1743 SetConditionalCascade(MainPopupMenu, IDM_AUTOVIEWSUBMENU, IDM_AUTOVIEW);
1744 }
1745 }
1746 return *hwndMenu;
1747}
1748
1749SHORT AddToListboxBottom(HWND hwnd, CHAR * str)
1750{
1751 SHORT ln;
1752
1753 ln = (SHORT) WinSendMsg(hwnd, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
1754 MPFROMP(str));
1755 if (ln)
1756 WinSendMsg(hwnd, LM_SELECTITEM, MPFROM2SHORT(ln, 0), MPVOID);
1757 return ln;
1758}
1759
1760VOID SetSysMenu(HWND hwndSysMenu)
1761{
1762 CHAR s[128], *p;
1763
1764 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1765 MPFROM2SHORT(SC_RESTORE, 128), MPFROMP(s))) {
1766 p = strchr(s, '\t');
1767 if (p) {
1768 p++;
1769 strcpy(p, "Ctrl+Alt+F5");
1770 WinSetMenuItemText(hwndSysMenu, SC_RESTORE, s);
1771 }
1772 }
1773 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1774 MPFROM2SHORT(SC_CLOSE, 128), MPFROMP(s))) {
1775 p = strchr(s, '\t');
1776 if (p) {
1777 p++;
1778 strcpy(p, "Ctrl+Alt+F4");
1779 WinSetMenuItemText(hwndSysMenu, SC_CLOSE, s);
1780 }
1781 }
1782 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1783 MPFROM2SHORT(SC_MOVE, 128), MPFROMP(s))) {
1784 p = strchr(s, '\t');
1785 if (p) {
1786 p++;
1787 strcpy(p, "Ctrl+Alt+F7");
1788 WinSetMenuItemText(hwndSysMenu, SC_MOVE, s);
1789 }
1790 }
1791 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1792 MPFROM2SHORT(SC_SIZE, 128), MPFROMP(s))) {
1793 p = strchr(s, '\t');
1794 if (p) {
1795 p++;
1796 strcpy(p, "Ctrl+Alt+F8");
1797 WinSetMenuItemText(hwndSysMenu, SC_SIZE, s);
1798 }
1799 }
1800 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1801 MPFROM2SHORT(SC_MINIMIZE, 128), MPFROMP(s))) {
1802 p = strchr(s, '\t');
1803 if (p) {
1804 p++;
1805 strcpy(p, "Ctrl+Alt+F9");
1806 WinSetMenuItemText(hwndSysMenu, SC_MINIMIZE, s);
1807 }
1808 }
1809 if (WinSendMsg(hwndSysMenu,
1810 MM_QUERYITEMTEXT,
1811 MPFROM2SHORT(SC_MAXIMIZE, 128), MPFROMP(s))) {
1812 p = strchr(s, '\t');
1813 if (p) {
1814 p++;
1815 strcpy(p, "Ctrl+Alt+F10");
1816 WinSetMenuItemText(hwndSysMenu, SC_MAXIMIZE, s);
1817 }
1818 }
1819 if (WinSendMsg(hwndSysMenu,
1820 MM_QUERYITEMTEXT, MPFROM2SHORT(SC_HIDE, 128), MPFROMP(s))) {
1821 p = strchr(s, '\t');
1822 if (p) {
1823 p++;
1824 strcpy(p, "Ctrl+Alt+F11");
1825 WinSetMenuItemText(hwndSysMenu, SC_HIDE, s);
1826 }
1827 }
1828}
1829
1830VOID LoadLibPath(CHAR * str, LONG len)
1831{
1832 ULONG ver[2];
1833 CHAR configsys[] = "C:\\CONFIG.SYS";
1834 static CHAR var[8192], beg[16384], end[16384];
1835 BOOL warp;
1836 FILE *fp;
1837 PFN DQELIBPATH = NULL;
1838 HMODULE hmod;
1839
1840 if (str && len) {
1841 *str = 0;
1842 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
1843 QSV_BOOT_DRIVE, (PVOID) ver, (ULONG) sizeof(ULONG)))
1844 ver[0] = 3L;
1845 *configsys = (CHAR) ver[0] + '@';
1846 if (!DosQuerySysInfo(QSV_VERSION_MAJOR,
1847 QSV_VERSION_MINOR,
1848 (PVOID) ver, (ULONG) sizeof(ver)) && ver[1] >= 30)
1849 warp = TRUE;
1850 *var = *beg = *end = 0;
1851 if (warp) {
1852 if (!DosLoadModule(var, sizeof(var), "DOSCALL1.DLL", &hmod)) {
1853 if (!DosQueryProcAddr(hmod,
1854 ORD_DOS32QUERYEXTLIBPATH,
1855 NULL, (PFN *) & DQELIBPATH)) {
1856 DQELIBPATH(beg, BEGIN_LIBPATH);
1857 DQELIBPATH(end, END_LIBPATH);
1858 }
1859 DosFreeModule(hmod);
1860 }
1861 *var = 0;
1862 }
1863 fp = xfopen(configsys, "r", pszSrcFile, __LINE__);
1864 if (fp) {
1865 while (!feof(fp)) {
1866 if (!xfgets_bstripcr(var, sizeof(var), fp, pszSrcFile, __LINE__))
1867 break;
1868 if (!strnicmp(var, "LIBPATH=", 8)) {
1869 memmove(var, var + 8, strlen(var + 8) + 1);
1870 lstrip(var);
1871 break;
1872 }
1873 }
1874 fclose(fp);
1875 }
1876 strncpy(str, beg, len);
1877 strncat(str, var, len - strlen(str));
1878 strncat(str, end, len - strlen(str));
1879 str[len - 1] = 0;
1880 }
1881}
1882
1883void SetViewMenu(HWND hwndMenu, ULONG flWindowAttr)
1884{
1885 WinCheckMenuItem(hwndMenu, IDM_MINIICONS, ((flWindowAttr & CV_MINI)));
1886 WinCheckMenuItem(hwndMenu, IDM_TEXT, ((flWindowAttr & CV_TEXT)));
1887 WinCheckMenuItem(hwndMenu, IDM_ICON, ((flWindowAttr & CV_ICON) &&
1888 !(flWindowAttr & CV_TREE)));
1889 WinCheckMenuItem(hwndMenu, IDM_TREEVIEW, ((flWindowAttr & CV_TREE)));
1890 WinCheckMenuItem(hwndMenu, IDM_DETAILS, ((flWindowAttr & CV_DETAIL)));
1891 WinCheckMenuItem(hwndMenu, IDM_NAME, ((flWindowAttr & CV_NAME)));
1892}
1893
1894void SaySort(HWND hwnd, INT sortflags, BOOL archive)
1895{
1896 char *s = NULL;
1897
1898 s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
1899 if (s) {
1900 sprintf(s, "S:%s%s",
1901 sortflags & SORT_REVERSE ? "^" : NullStr,
1902 (sortflags & SORT_FIRSTEXTENSION) ?
1903 GetPString(IDS_FIRSTX) : (sortflags & SORT_LASTEXTENSION) ?
1904 GetPString(IDS_LASTX) : (sortflags & SORT_SIZE) ?
1905 "Size" : (sortflags & SORT_EASIZE) ?
1906 (archive == 0) ?
1907 GetPString(IDS_EASIZE) : GetPString(IDS_CSIZE) :
1908 (sortflags & SORT_LWDATE) ?
1909 (archive == 0) ?
1910 GetPString(IDS_LWDATE) : GetPString(IDS_DATE) :
1911 (sortflags & SORT_LADATE) ?
1912 GetPString(IDS_LADATE) : (sortflags & SORT_CRDATE) ?
1913 GetPString(IDS_CRDATE) :
1914 (sortflags & SORT_PATHNAME) ?
1915 GetPString(IDS_PATH) : (sortflags & SORT_NOSORT) ?
1916 GetPString(IDS_NONE) : (sortflags & SORT_SUBJECT) ?
1917 GetPString(IDS_SUBJ) : GetPString(IDS_NAME));
1918 WinSetWindowText(hwnd, s);
1919 free(s);
1920 }
1921}
1922
1923void SayView(HWND hwnd, ULONG flWindowAttr)
1924{
1925 char *s = NULL;
1926
1927 s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
1928 if (s) {
1929 sprintf(s, "V:%s%s",
1930 (flWindowAttr & CV_TREE) ? GetPString(IDS_TREE) :
1931 (flWindowAttr & CV_NAME) ? GetPString(IDS_NAME) :
1932 (flWindowAttr & CV_DETAIL) ? GetPString(IDS_DETAIL) :
1933 (flWindowAttr & CV_TEXT) ? GetPString(IDS_TEXT) :
1934 GetPString(IDS_ICON),
1935 ((flWindowAttr & CV_MINI) &&
1936 !(flWindowAttr & CV_TEXT)) ? GetPString(IDS_MINI) : NullStr);
1937 WinSetWindowText(hwnd, s);
1938 free(s);
1939 }
1940}
1941
1942void SayFilter(HWND hwnd, MASK * mask, BOOL archive)
1943{
1944 char *s = NULL;
1945
1946 s = xmalloc(CCHMAXPATH * 2, pszSrcFile, __LINE__);
1947 if (s) {
1948 sprintf(s, "F:%s%s",
1949 mask->szMask,
1950 (!archive && (mask->attrFile != ALLATTRS ||
1951 mask->antiattr != 0)) ? " " : NullStr,
1952 (!archive && (mask->attrFile != ALLATTRS ||
1953 mask->antiattr !=
1954 0)) ? GetPString(IDS_ATTRTEXT) : NullStr);
1955 if (!s[2])
1956 sprintf(s, "F:%s", GetPString(IDS_ALLTEXT));
1957 WinSetWindowText(hwnd, s);
1958 free(s);
1959 }
1960}
1961
1962char *GetCmdSpec(BOOL dos)
1963{
1964 char *cmspec;
1965
1966 if (!dos) {
1967 cmspec = getenv("OS2_SHELL");
1968 if (!cmspec)
1969 cmspec = getenv("COMSPEC");
1970 if (!cmspec)
1971 cmspec = "CMD.EXE";
1972 }
1973 else {
1974 cmspec = getenv("DOS_SHELL");
1975 if (!cmspec)
1976 cmspec = "COMMAND.COM";
1977 }
1978 return cmspec;
1979}
1980
1981void Broadcast(HAB hab, HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1982{
1983 if (hwndMain)
1984 WinBroadcastMsg(hwndMain, msg, mp1, mp2, BMSG_SEND | BMSG_FRAMEONLY);
1985 if (hwnd &&
1986 hwnd != HWND_DESKTOP &&
1987 hwnd != hwndMain &&
1988 hwnd != WinQueryDesktopWindow(hab, NULLHANDLE) &&
1989 WinIsWindow(hab, hwnd) && (!hwndMain || !WinIsChild(hwnd, hwndMain)))
1990 WinSendMsg(hwnd, msg, mp1, mp2);
1991}
1992
1993void SetupWinList(HWND hwndMenu, HWND hwndTop, HWND hwndFrame)
1994{
1995 /*
1996 * add switchlist entries to end of pulldown menu
1997 */
1998
1999 SHORT sItemCount, x = 0, y = 0;
2000 MENUITEM mi;
2001
2002 sItemCount = (SHORT) WinSendMsg(hwndMenu,
2003 MM_QUERYITEMCOUNT, MPVOID, MPVOID);
2004
2005 /* clean out old additions */
2006 while ((SHORT) WinSendMsg(hwndMenu,
2007 MM_DELETEITEM,
2008 MPFROM2SHORT(IDM_SWITCHSTART + x++,
2009 TRUE), MPVOID) < sItemCount)
2010 sItemCount--;
2011 x = 0;
2012 while ((SHORT) WinSendMsg(hwndMenu,
2013 MM_DELETEITEM,
2014 MPFROM2SHORT(IDM_WINDOWSTART + x++,
2015 TRUE), MPVOID) < sItemCount)
2016 sItemCount--;
2017
2018 x = 0;
2019 if (hwndTop) {
2020
2021 char wtext[CCHMAXPATH + 8];
2022 HENUM henum;
2023 HWND hwndChild;
2024
2025 /* add children of the main FM/2 client */
2026 henum = WinBeginEnumWindows(hwndTop);
2027 memset(&mi, 0, sizeof(mi));
2028 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2029 if (WinQueryWindowUShort(hwndChild, QWS_ID) && hwndChild != hwndFrame) {
2030 *wtext = 0;
2031 WinQueryWindowText(hwndChild, CCHMAXPATH + 8, wtext);
2032 if (*wtext) {
2033 wtext[CCHMAXPATH + 7] = 0;
2034 mi.afStyle = MIS_TEXT;
2035 if (!((x + sItemCount) % 28))
2036 mi.afStyle |= MIS_BREAK;
2037 mi.id = IDM_WINDOWSTART + x;
2038 mi.iPosition = MIT_END;
2039 if ((SHORT) WinSendMsg(hwndMenu,
2040 MM_INSERTITEM,
2041 MPFROMP(&mi), MPFROMP(wtext)) >= 0)
2042 x++;
2043 }
2044 }
2045 }
2046 WinEndEnumWindows(henum);
2047 }
2048
2049 /* add external FM/2 windows */
2050 {
2051 PSWBLOCK pswb;
2052 ULONG ulSize, ulcEntries;
2053 HWND hwndTopFrame;
2054 register INT i;
2055
2056 hwndTopFrame = hwndTop ? WinQueryWindow(hwndTop, QW_PARENT) : (HWND)0;
2057 /* Get the switch list information */
2058 x = 0;
2059 ulcEntries = WinQuerySwitchList(0, NULL, 0);
2060 ulSize = sizeof(SWBLOCK) + sizeof(HSWITCH) + (ulcEntries + 4L) *
2061 (LONG) sizeof(SWENTRY);
2062 /* Allocate memory for list */
2063 pswb = xmalloc(ulSize, pszSrcFile, __LINE__);
2064 if (pswb) {
2065 /* Put the info in the list */
2066 ulcEntries = WinQuerySwitchList(0, pswb, ulSize - sizeof(SWENTRY));
2067 /* do the dirty deed */
2068 memset(&mi, 0, sizeof(mi));
2069 for (i = 0; i < pswb->cswentry; i++) {
2070 if (pswb->aswentry[i].swctl.uchVisibility == SWL_VISIBLE &&
2071 pswb->aswentry[i].swctl.fbJump == SWL_JUMPABLE &&
2072 (pswb->aswentry[i].swctl.idProcess != mypid ||
2073 !hwndFrame ||
2074 pswb->aswentry[i].swctl.hwnd != hwndFrame) &&
2075 (pswb->aswentry[i].swctl.idProcess != mypid ||
2076 !hwndTopFrame ||
2077 pswb->aswentry[i].swctl.hwnd != hwndTopFrame ||
2078 !WinIsChild(hwndFrame, hwndTop))) {
2079 if (!strnicmp(pswb->aswentry[i].swctl.szSwtitle, "AV/2", 4)
2080 || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "File Manager/2")
2081 || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "Collector")
2082 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VTree", 5)
2083 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VDir", 4)
2084 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, FM2Str, 4)) {
2085 mi.afStyle = MIS_TEXT;
2086 if (x && !(x % 28))
2087 mi.afStyle |= MIS_BREAK;
2088 mi.id = IDM_SWITCHSTART + y;
2089 mi.iPosition = MIT_END;
2090 switches[y] = pswb->aswentry[i].hswitch;
2091 if ((SHORT) WinSendMsg(hwndMenu,
2092 MM_INSERTITEM,
2093 MPFROMP(&mi),
2094 MPFROMP(pswb->aswentry[i].
2095 swctl.szSwtitle)) >= 0) {
2096 y++;
2097 x++;
2098 }
2099 }
2100 }
2101 }
2102 numswitches = y;
2103 free(pswb);
2104 DosPostEventSem(CompactSem);
2105 }
2106 }
2107}
2108
2109BOOL SwitchCommand(HWND hwndMenu, USHORT cmd)
2110{
2111 BOOL ret = FALSE;
2112
2113 if (hwndMain && hwndMenu && cmd >= IDM_WINDOWSTART && cmd < IDM_SWITCHSTART) {
2114 /*
2115 * select a child window (of client)
2116 */
2117
2118 MENUITEM mi;
2119 HWND hwndSubMenu = (HWND) 0, hwndChild;
2120 CHAR s[CCHMAXPATH + 8];
2121
2122 if (WinQueryWindowUShort(hwndMenu, QWS_ID) != IDM_WINDOWSMENU) {
2123 memset(&mi, 0, sizeof(mi));
2124 mi.iPosition = MIT_END;
2125 mi.afStyle = MIS_TEXT;
2126 if (WinSendMsg(hwndMenu,
2127 MM_QUERYITEM,
2128 MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
2129 hwndSubMenu = mi.hwndSubMenu;
2130 }
2131 else
2132 hwndSubMenu = hwndMenu;
2133 if (hwndSubMenu) {
2134 *s = 0;
2135 if (WinSendMsg(hwndSubMenu,
2136 MM_QUERYITEMTEXT,
2137 MPFROM2SHORT(cmd, CCHMAXPATH + 8), MPFROMP(s)) && *s) {
2138
2139 HENUM henum;
2140 CHAR checkText[CCHMAXPATH + 8];
2141 SWP swp;
2142
2143 s[CCHMAXPATH + 7] = 0;
2144 henum = WinBeginEnumWindows(hwndMain);
2145 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2146 if (WinQueryWindowUShort(hwndChild, QWS_ID)) {
2147 *checkText = 0;
2148 WinQueryWindowText(hwndChild, CCHMAXPATH + 8, checkText);
2149 checkText[CCHMAXPATH + 7] = 0;
2150 if (!stricmp(checkText, s)) {
2151 if (WinQueryWindowPos(hwndChild, &swp)) {
2152 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE))
2153 WinSetWindowPos(hwndChild,
2154 HWND_TOP,
2155 0, 0, 0, 0, SWP_RESTORE | SWP_ZORDER);
2156 }
2157 WinSetActiveWindow(HWND_DESKTOP, hwndChild);
2158 ret = TRUE;
2159 break;
2160 }
2161 }
2162 }
2163 WinEndEnumWindows(henum);
2164 }
2165 }
2166 }
2167 else if (cmd >= IDM_SWITCHSTART && cmd < IDM_SWITCHSTART + 499) {
2168 if (cmd - IDM_SWITCHSTART < numswitches) {
2169 WinSwitchToProgram(switches[cmd - IDM_SWITCHSTART]);
2170 ret = TRUE;
2171 }
2172 }
2173
2174 return ret;
2175}
2176
2177#pragma alloc_text(MAINWND5,SetSysMenu)
2178#pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow,IsFm2Window)
2179#pragma alloc_text(MISC1,FixSwitchList,FindDirCnr,CurrentRecord,SetShiftState,AddToListboxBottom)
2180#pragma alloc_text(CNR_MISC1,AdjustCnrColVis,AdjustCnrColsForFSType)
2181#pragma alloc_text(CNR_MISC1,AdjustCnrColsForPref,SetCnrCols)
2182#pragma alloc_text(CNR_MISC2,CnrDirectEdit,OpenEdit)
2183#pragma alloc_text(MISC2,SetMenuCheck,disable_menuitem,SetSortChecks)
2184#pragma alloc_text(MISC2,SetDetailsSwitches,SetViewMenu)
2185#pragma alloc_text(MISC3,SetupCommandMenu,AdjustDetailsSwitches)
2186#pragma alloc_text(MISC3,ViewHelp,GetCmdSpec)
2187#pragma alloc_text(MISC3,ExecFile,SetConditionalCascade,LoadDetailsSwitches)
2188#pragma alloc_text(MISC4,PortholeInit,CheckMenu,Broadcast,SetupWinList,SwitchCommand)
2189#pragma alloc_text(MISC6,DrawTargetEmphasis,EmphasizeButton)
2190#pragma alloc_text(MISC_LIBPATH,LoadLibPath)
2191#pragma alloc_text(MISC_SAY,SayView,SaySort,SayFilter)
2192
Note: See TracBrowser for help on using the repository browser.