source: trunk/dll/misc.c@ 827

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

Future proof xDosSetPathInfo
Clean up callers

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