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