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