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