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