1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: mainwnd2.c 1009 2008-05-10 07:51:58Z stevenhl $
|
---|
5 |
|
---|
6 | fm/4 main window
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2005, 2008 Steven H. Levine
|
---|
10 |
|
---|
11 | 23 May 05 SHL Use datamin.h
|
---|
12 | 26 May 05 SHL Comments and localize code
|
---|
13 | 06 Aug 05 SHL Renames
|
---|
14 | 02 Jan 06 SHL Use QWL_USER more
|
---|
15 | 02 Jan 06 SHL Map IDM_WINDOWDLG to match IBM_TWODIRS
|
---|
16 | 17 Jul 06 SHL Use Runtime_Error
|
---|
17 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
18 | 12 May 07 SHL Pass ulItemsToUnHilite to UnHilite
|
---|
19 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
20 | 07 Aug 07 SHL Use BldQuotedFileName
|
---|
21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
22 | 10 Jan 08 SHL Sync with CfgDlgProc mods
|
---|
23 | 19 Jan 08 GKY Rework Utilities menu
|
---|
24 | 14 Feb 08 SHL Rework to support settings menu conditional cascade
|
---|
25 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
26 |
|
---|
27 | ***********************************************************************/
|
---|
28 |
|
---|
29 | #include <stdlib.h>
|
---|
30 | #include <string.h>
|
---|
31 | #include <share.h>
|
---|
32 | #include <process.h> // _beginthread
|
---|
33 |
|
---|
34 | #define INCL_DOS
|
---|
35 | #define INCL_WIN
|
---|
36 | #define INCL_GPI
|
---|
37 | #define INCL_LONGLONG
|
---|
38 |
|
---|
39 | #include "fm3dlg.h"
|
---|
40 | #include "fm3str.h"
|
---|
41 | #include "tools.h"
|
---|
42 | #include "datamin.h"
|
---|
43 | #include "comp.h" // COMPARE
|
---|
44 | #include "pathutil.h" // BldQuotedFileName
|
---|
45 | #include "errutil.h" // Dos_Error...
|
---|
46 | #include "strutil.h" // GetPString
|
---|
47 | #include "notebook.h" // CfgDlgProc
|
---|
48 | #include "command.h" // RunCommand
|
---|
49 | #include "fm3dll.h"
|
---|
50 |
|
---|
51 | typedef struct
|
---|
52 | {
|
---|
53 | USHORT size;
|
---|
54 | USHORT dummy;
|
---|
55 | HWND hwndDir1;
|
---|
56 | HWND hwndDir2;
|
---|
57 | HWND hwndCurr;
|
---|
58 | HWND hwndLastDir;
|
---|
59 | HWND hwndMax;
|
---|
60 | }
|
---|
61 | PERSON1DATA;
|
---|
62 |
|
---|
63 | static PSZ pszSrcFile = __FILE__;
|
---|
64 |
|
---|
65 | static MRESULT EXPENTRY MainFrameWndProc2(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
66 | MPARAM mp2)
|
---|
67 | {
|
---|
68 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
69 |
|
---|
70 | switch (msg) {
|
---|
71 | case WM_ADJUSTWINDOWPOS:
|
---|
72 | {
|
---|
73 | SWP *pswp;
|
---|
74 |
|
---|
75 | pswp = (SWP *) mp1;
|
---|
76 | if (pswp->fl & (SWP_SHOW | SWP_RESTORE))
|
---|
77 | PostMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_SIZE, MPVOID, MPVOID);
|
---|
78 | if (fDataMin && !fAmClosing) {
|
---|
79 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
|
---|
80 |
|
---|
81 | SWP swp;
|
---|
82 |
|
---|
83 | WinQueryWindowPos(hwnd, &swp);
|
---|
84 | PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
|
---|
85 | HideNote();
|
---|
86 | }
|
---|
87 | else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
|
---|
88 | if (DataHwnd)
|
---|
89 | PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
90 | }
|
---|
91 | }
|
---|
92 | if (!fAmClosing) {
|
---|
93 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
|
---|
94 | HideNote();
|
---|
95 | }
|
---|
96 | }
|
---|
97 | break;
|
---|
98 |
|
---|
99 | case UM_FOCUSME:
|
---|
100 | CreateDataBar(HWND_DESKTOP, (ULONG) mp1);
|
---|
101 | return 0;
|
---|
102 |
|
---|
103 | case WM_BUTTON1UP:
|
---|
104 | case WM_BUTTON2UP:
|
---|
105 | case WM_BUTTON3UP:
|
---|
106 | case WM_MOUSEMOVE:
|
---|
107 | case WM_CHORD:
|
---|
108 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
|
---|
109 | break;
|
---|
110 |
|
---|
111 | case WM_CHAR:
|
---|
112 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
113 | break;
|
---|
114 |
|
---|
115 | case WM_CONTROL:
|
---|
116 | return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1,
|
---|
117 | mp2);
|
---|
118 |
|
---|
119 | case WM_COMMAND:
|
---|
120 | return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
|
---|
121 |
|
---|
122 | case WM_CALCFRAMERECT:
|
---|
123 | {
|
---|
124 | MRESULT mr;
|
---|
125 | PRECTL prectl;
|
---|
126 | LONG sheight = 20, bheight = 20;
|
---|
127 |
|
---|
128 | mr = (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
|
---|
129 | PFNWPFrame(hwnd, msg, mp1, mp2);
|
---|
130 |
|
---|
131 | /*
|
---|
132 | * Calculate the position of the client rectangle.
|
---|
133 | * Otherwise, we'll see a lot of redraw when we move the
|
---|
134 | * client during WM_FORMATFRAME.
|
---|
135 | */
|
---|
136 |
|
---|
137 | if (mr && mp2) {
|
---|
138 | prectl = (PRECTL) mp1;
|
---|
139 | if (prectl->yBottom != prectl->yTop) {
|
---|
140 | {
|
---|
141 | HPS hps;
|
---|
142 | POINTL aptl[TXTBOX_COUNT];
|
---|
143 |
|
---|
144 | hps = WinGetPS(hwndStatus);
|
---|
145 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
|
---|
146 | WinReleasePS(hps);
|
---|
147 | sheight = aptl[TXTBOX_TOPLEFT].y + 6;
|
---|
148 | hps = WinGetPS(hwndName);
|
---|
149 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
|
---|
150 | WinReleasePS(hps);
|
---|
151 | bheight = aptl[TXTBOX_TOPLEFT].y + 6;
|
---|
152 | }
|
---|
153 | prectl->yBottom += (sheight + 4);
|
---|
154 | prectl->yTop -= (sheight + 4);
|
---|
155 | prectl->yBottom += (bheight + 4);
|
---|
156 | prectl->yTop -= (bheight + 4);
|
---|
157 | if (fToolbar) {
|
---|
158 | if (!fTextTools)
|
---|
159 | prectl->yTop -= ((fToolTitles) ? 50 : 40);
|
---|
160 | else
|
---|
161 | prectl->yTop -= 32;
|
---|
162 | }
|
---|
163 | ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
|
---|
164 | ((prectl->xRight -
|
---|
165 | (WinQuerySysValue(HWND_DESKTOP,
|
---|
166 | SV_CYSIZEBORDER) * 2)) - 4));
|
---|
167 | prectl->yTop -= (16 * (DriveLines * 18));
|
---|
168 | prectl->yTop -= 2;
|
---|
169 | if (fAutoView) {
|
---|
170 | AutoviewHeight = min(AutoviewHeight,
|
---|
171 | (prectl->yTop - prectl->yBottom) - 116);
|
---|
172 | AutoviewHeight = max(AutoviewHeight, 36);
|
---|
173 | prectl->yBottom += (AutoviewHeight + 6);
|
---|
174 | }
|
---|
175 | }
|
---|
176 | }
|
---|
177 | return mr;
|
---|
178 | }
|
---|
179 |
|
---|
180 | case WM_FORMATFRAME:
|
---|
181 | {
|
---|
182 | SHORT sCount, soldCount;
|
---|
183 | PSWP pswp, pswpClient, pswpNew;
|
---|
184 | SWP swpClient;
|
---|
185 | ULONG theight = 48L, dheight = 20, bheight = 20, sheight = 20;
|
---|
186 | LONG width, lastx;
|
---|
187 |
|
---|
188 | sCount = (SHORT) ((oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
|
---|
189 | PFNWPFrame(hwnd, msg, mp1, mp2));
|
---|
190 | soldCount = sCount;
|
---|
191 | /*
|
---|
192 | * Reformat the frame to "squeeze" the client
|
---|
193 | * and make room for status window sibling beneath
|
---|
194 | * and toolbar above (if toolbar's on) and userlists
|
---|
195 | * (if userlists are on).
|
---|
196 | */
|
---|
197 |
|
---|
198 | pswp = (PSWP) mp1;
|
---|
199 | {
|
---|
200 | SHORT x;
|
---|
201 |
|
---|
202 | for (x = 0; x < sCount; x++) {
|
---|
203 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
|
---|
204 | pswpClient = pswp;
|
---|
205 | break;
|
---|
206 | }
|
---|
207 | pswp++;
|
---|
208 | }
|
---|
209 | }
|
---|
210 |
|
---|
211 | {
|
---|
212 | HPS hps;
|
---|
213 | POINTL aptl[TXTBOX_COUNT];
|
---|
214 |
|
---|
215 | hps = WinGetPS(hwndStatus);
|
---|
216 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
|
---|
217 | WinReleasePS(hps);
|
---|
218 | bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
|
---|
219 | hps = WinGetPS(hwndName);
|
---|
220 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
|
---|
221 | WinReleasePS(hps);
|
---|
222 | bheight = aptl[TXTBOX_TOPLEFT].y + 6;
|
---|
223 | }
|
---|
224 |
|
---|
225 | pswpNew = (PSWP) mp1 + soldCount;
|
---|
226 | *pswpNew = *pswpClient;
|
---|
227 | swpClient = *pswpClient;
|
---|
228 | pswpNew->hwnd = hwndStatus;
|
---|
229 | pswpNew->x = swpClient.x + 3;
|
---|
230 | pswpNew->y = swpClient.y + 2;
|
---|
231 | width = (swpClient.cx / 2) - 6;
|
---|
232 | width = max(width, 10);
|
---|
233 | pswpNew->cx = width - 6;
|
---|
234 | pswpNew->cy = sheight;
|
---|
235 | pswpClient->y = pswpNew->y + pswpNew->cy + 3;
|
---|
236 | pswpClient->cy = (swpClient.cy - pswpNew->cy) - 3;
|
---|
237 | sCount++;
|
---|
238 |
|
---|
239 | pswpNew = (PSWP) mp1 + (soldCount + 1);
|
---|
240 | *pswpNew = *pswpClient;
|
---|
241 | pswpNew->hwnd = hwndStatus2;
|
---|
242 | pswpNew->x = width + 8;
|
---|
243 | pswpNew->y = swpClient.y + 2;
|
---|
244 | pswpNew->cx = width - 6;
|
---|
245 | pswpNew->cy = sheight;
|
---|
246 | sCount++;
|
---|
247 |
|
---|
248 | if (fToolbar) {
|
---|
249 | if (fTextTools)
|
---|
250 | theight = 32L;
|
---|
251 | else if (!fToolTitles)
|
---|
252 | theight = 40L;
|
---|
253 | pswpNew = (PSWP) mp1 + (soldCount + 2);
|
---|
254 | *pswpNew = *pswpClient;
|
---|
255 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
|
---|
256 | pswpNew->x = swpClient.x + 2;
|
---|
257 | pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
|
---|
258 | pswpNew->cx = swpClient.cx - 4;
|
---|
259 | pswpNew->cy = theight - 4;
|
---|
260 | pswpClient->cy -= theight;
|
---|
261 | sCount++;
|
---|
262 | }
|
---|
263 | else
|
---|
264 | WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
|
---|
265 |
|
---|
266 | ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
|
---|
267 | pswpNew = (PSWP) mp1 + (soldCount + 2 + (fToolbar != FALSE));
|
---|
268 | *pswpNew = *pswpClient;
|
---|
269 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
|
---|
270 | pswpNew->x = swpClient.x + 2;
|
---|
271 | dheight += ((dheight - 2) * DriveLines);
|
---|
272 | pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
|
---|
273 | if (fToolbar)
|
---|
274 | pswpNew->y -= theight;
|
---|
275 | pswpNew->cx = swpClient.cx - 4;
|
---|
276 | pswpNew->cy = dheight - 4;
|
---|
277 | pswpClient->cy -= dheight;
|
---|
278 | pswpClient->cy -= 2;
|
---|
279 | sCount++;
|
---|
280 |
|
---|
281 | if (fAutoView) {
|
---|
282 | pswpNew = (PSWP) mp1 + (soldCount + 3 + (fToolbar != FALSE));
|
---|
283 | *pswpNew = *pswpClient;
|
---|
284 | pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
|
---|
285 | pswpNew->x = pswpClient->x + 3;
|
---|
286 | pswpNew->y = pswpClient->y + 3;
|
---|
287 | if (fMoreButtons)
|
---|
288 | pswpNew->y += (bheight + 4);
|
---|
289 | pswpNew->cx = pswpClient->cx - 6;
|
---|
290 | AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
|
---|
291 | AutoviewHeight = max(AutoviewHeight, 36);
|
---|
292 | pswpNew->cy = AutoviewHeight;
|
---|
293 | pswpClient->y += (AutoviewHeight + 6);
|
---|
294 | pswpClient->cy -= (AutoviewHeight + 6);
|
---|
295 | sCount++;
|
---|
296 | WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
|
---|
297 | }
|
---|
298 | else {
|
---|
299 | WinShowWindow(hwndAutoview, FALSE);
|
---|
300 | WinShowWindow(hwndAutoMLE, FALSE);
|
---|
301 | }
|
---|
302 |
|
---|
303 | pswpNew = (PSWP) mp1 + (soldCount + 3 + (fToolbar != FALSE) +
|
---|
304 | (fAutoView != FALSE));
|
---|
305 | *pswpNew = *pswpClient;
|
---|
306 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED);
|
---|
307 | pswpNew->x = (swpClient.x + swpClient.cx) - 12;
|
---|
308 | pswpNew->y = swpClient.y;
|
---|
309 | pswpNew->cx = 12;
|
---|
310 | pswpNew->cy = 12;
|
---|
311 | sCount++;
|
---|
312 |
|
---|
313 | pswpNew = (PSWP) mp1 + (soldCount + 4 + (fToolbar != FALSE) +
|
---|
314 | (fAutoView != FALSE));
|
---|
315 | *pswpNew = *pswpClient;
|
---|
316 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
|
---|
317 | pswpNew->x = (swpClient.x + swpClient.cx) - 12;
|
---|
318 | pswpNew->y = swpClient.y + 12;
|
---|
319 | pswpNew->cx = 12;
|
---|
320 | pswpNew->cy = sheight - 8;
|
---|
321 | sCount++;
|
---|
322 |
|
---|
323 | pswpNew = (PSWP) mp1 + (soldCount + 5 + (fToolbar != FALSE) +
|
---|
324 | (fAutoView != FALSE));
|
---|
325 | *pswpNew = *pswpClient;
|
---|
326 | pswpNew->hwnd = hwndName;
|
---|
327 | pswpNew->x = swpClient.x + 3;
|
---|
328 | pswpNew->y = swpClient.y + (sheight + 6);
|
---|
329 | pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
|
---|
330 | lastx = pswpNew->x + pswpNew->cx;
|
---|
331 | pswpNew->cy = bheight;
|
---|
332 | pswpClient->y += (bheight + 4);
|
---|
333 | pswpClient->cy -= (bheight + 4);
|
---|
334 | sCount++;
|
---|
335 |
|
---|
336 | pswpNew = (PSWP) mp1 + (soldCount + 6 + (fToolbar != FALSE) +
|
---|
337 | (fAutoView != FALSE));
|
---|
338 | *pswpNew = *pswpClient;
|
---|
339 | pswpNew->hwnd = hwndDate;
|
---|
340 | pswpNew->x = lastx + 3;
|
---|
341 | pswpNew->y = swpClient.y + (sheight + 6);
|
---|
342 | pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
|
---|
343 | lastx = pswpNew->x + pswpNew->cx;
|
---|
344 | pswpNew->cy = bheight;
|
---|
345 | sCount++;
|
---|
346 |
|
---|
347 | pswpNew = (PSWP) mp1 + (soldCount + 7 + (fToolbar != FALSE) +
|
---|
348 | (fAutoView != FALSE));
|
---|
349 | *pswpNew = *pswpClient;
|
---|
350 | pswpNew->hwnd = hwndAttr;
|
---|
351 | pswpNew->x = lastx + 3;
|
---|
352 | pswpNew->y = swpClient.y + (sheight + 6);
|
---|
353 | pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
|
---|
354 | pswpNew->cy = bheight;
|
---|
355 | sCount++;
|
---|
356 |
|
---|
357 | return MRFROMSHORT(sCount);
|
---|
358 | }
|
---|
359 |
|
---|
360 | case WM_QUERYFRAMECTLCOUNT:
|
---|
361 | {
|
---|
362 | SHORT sCount;
|
---|
363 |
|
---|
364 | sCount = (SHORT) ((oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
|
---|
365 | PFNWPFrame(hwnd, msg, mp1, mp2));
|
---|
366 | sCount += 8;
|
---|
367 | if (fToolbar)
|
---|
368 | sCount++;
|
---|
369 | if (fAutoView)
|
---|
370 | sCount++;
|
---|
371 | return MRFROMSHORT(sCount);
|
---|
372 | }
|
---|
373 |
|
---|
374 | case WM_CLOSE:
|
---|
375 | WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
|
---|
376 | return 0;
|
---|
377 | }
|
---|
378 | return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
|
---|
379 | PFNWPFrame(hwnd, msg, mp1, mp2);
|
---|
380 | }
|
---|
381 |
|
---|
382 | static MRESULT EXPENTRY MainWMCommand2(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
383 | MPARAM mp2)
|
---|
384 | {
|
---|
385 | PERSON1DATA *pd;
|
---|
386 |
|
---|
387 | SetShiftState();
|
---|
388 | switch (SHORT1FROMMP(mp1)) {
|
---|
389 | case IDM_TOAUTOMLE:
|
---|
390 | case IDM_CLI:
|
---|
391 | case IDM_CREATETOOL:
|
---|
392 | case IDM_ABOUT:
|
---|
393 | case IDM_WINFULLSCREEN:
|
---|
394 | case IDM_DOSCOMMANDLINE:
|
---|
395 | case IDM_INIVIEWER:
|
---|
396 | case IDM_EDITASSOC:
|
---|
397 | case IDM_COMMANDLINE:
|
---|
398 | case IDM_KILLPROC:
|
---|
399 | case IDM_TOOLBAR:
|
---|
400 | case IDM_TEXTTOOLS:
|
---|
401 | case IDM_TOOLTITLES:
|
---|
402 | case IDM_TOOLLEFT:
|
---|
403 | case IDM_TOOLRIGHT:
|
---|
404 | case IDM_AUTOVIEWCOMMENTS:
|
---|
405 | case IDM_AUTOVIEWFILE:
|
---|
406 | case IDM_AUTOVIEW:
|
---|
407 | // case IDM_SYSINFO:
|
---|
408 | case IDM_HIDENOTEWND:
|
---|
409 | case IDM_SHOWNOTEWND:
|
---|
410 | case IDM_INSTANT:
|
---|
411 | case IDM_HELPCONTEXT:
|
---|
412 | case IDM_HELPHINTS:
|
---|
413 | case IDM_HELPPIX:
|
---|
414 | case IDM_KILLME:
|
---|
415 | case IDM_EXIT:
|
---|
416 | case IDM_HELPTUTOR:
|
---|
417 | case IDM_HELPCONTENTS:
|
---|
418 | case IDM_HELPGENERAL:
|
---|
419 | case IDM_HELPKEYS:
|
---|
420 | case IDM_HELPMOUSE:
|
---|
421 | case IDM_HELP:
|
---|
422 | return MainWMCommand(hwnd, msg, mp1, mp2);
|
---|
423 |
|
---|
424 | case IDM_REMAP:
|
---|
425 | WinDlgBox(HWND_DESKTOP,
|
---|
426 | hwnd, RemapDlgProc, FM3ModHandle, MAP_FRAME, NULL);
|
---|
427 | break;
|
---|
428 |
|
---|
429 | case IDM_TWODIRS: // Menu action
|
---|
430 | case IDM_WINDOWDLG: // Toolbar action
|
---|
431 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
432 | if (pd) {
|
---|
433 |
|
---|
434 | WALK2 wa;
|
---|
435 |
|
---|
436 | memset(&wa, 0, sizeof(wa));
|
---|
437 | wa.size = sizeof(wa);
|
---|
438 | *wa.szCurrentPath1 = 0;
|
---|
439 | WinSendMsg(pd->hwndDir1,
|
---|
440 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
|
---|
441 | MakeValidDir(wa.szCurrentPath1);
|
---|
442 | *wa.szCurrentPath2 = 0;
|
---|
443 | WinSendMsg(pd->hwndDir2,
|
---|
444 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
|
---|
445 | MakeValidDir(wa.szCurrentPath2);
|
---|
446 | if (WinDlgBox(HWND_DESKTOP,
|
---|
447 | hwnd,
|
---|
448 | WalkTwoSetDlgProc,
|
---|
449 | FM3ModHandle,
|
---|
450 | WALK2_FRAME,
|
---|
451 | MPFROMP(&wa)) &&
|
---|
452 | (IsRoot(wa.szCurrentPath1) ||
|
---|
453 | !IsFile(wa.szCurrentPath1)) &&
|
---|
454 | (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) {
|
---|
455 | WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir1,
|
---|
456 | FID_CLIENT), DIR_CNR),
|
---|
457 | UM_SETDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
|
---|
458 | WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir2,
|
---|
459 | FID_CLIENT), DIR_CNR),
|
---|
460 | UM_SETDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
|
---|
461 | }
|
---|
462 | }
|
---|
463 | break;
|
---|
464 |
|
---|
465 | case IDM_COMPARE:
|
---|
466 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
467 | if (pd) {
|
---|
468 |
|
---|
469 | WALK2 wa;
|
---|
470 |
|
---|
471 | memset(&wa, 0, sizeof(wa));
|
---|
472 | wa.size = sizeof(wa);
|
---|
473 | *wa.szCurrentPath1 = 0;
|
---|
474 | WinSendMsg(pd->hwndDir1,
|
---|
475 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
|
---|
476 | MakeValidDir(wa.szCurrentPath1);
|
---|
477 | *wa.szCurrentPath2 = 0;
|
---|
478 | WinSendMsg(pd->hwndDir2,
|
---|
479 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
|
---|
480 | MakeValidDir(wa.szCurrentPath2);
|
---|
481 | if (WinDlgBox(HWND_DESKTOP,
|
---|
482 | hwnd,
|
---|
483 | WalkTwoCmpDlgProc,
|
---|
484 | FM3ModHandle,
|
---|
485 | WALK2_FRAME,
|
---|
486 | MPFROMP(&wa)) &&
|
---|
487 | (IsRoot(wa.szCurrentPath1) ||
|
---|
488 | !IsFile(wa.szCurrentPath1)) &&
|
---|
489 | (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) {
|
---|
490 | if (!*dircompare) {
|
---|
491 |
|
---|
492 | COMPARE *cmp;
|
---|
493 |
|
---|
494 | cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
|
---|
495 | if (cmp) {
|
---|
496 | cmp->size = sizeof(COMPARE);
|
---|
497 | strcpy(cmp->leftdir, wa.szCurrentPath1);
|
---|
498 | strcpy(cmp->rightdir, wa.szCurrentPath2);
|
---|
499 | cmp->hwndParent = hwnd;
|
---|
500 | cmp->dcd.hwndParent = hwnd;
|
---|
501 | WinDlgBox(HWND_DESKTOP,
|
---|
502 | HWND_DESKTOP,
|
---|
503 | CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
|
---|
504 | }
|
---|
505 | }
|
---|
506 | else {
|
---|
507 | CHAR szPath1[CCHMAXPATH];
|
---|
508 | CHAR szPath2[CCHMAXPATH];
|
---|
509 | runemf2(SEPARATE,
|
---|
510 | HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
511 | NULL, NULL,
|
---|
512 | "%s %s %s",
|
---|
513 | dircompare,
|
---|
514 | BldQuotedFileName(szPath1, wa.szCurrentPath1),
|
---|
515 | BldQuotedFileName(szPath2, wa.szCurrentPath2));
|
---|
516 | }
|
---|
517 | }
|
---|
518 | }
|
---|
519 | break;
|
---|
520 |
|
---|
521 | case IDM_VTREE:
|
---|
522 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
|
---|
523 | if (hwndTree) {
|
---|
524 | WinShowWindow(hwndTree, FALSE);
|
---|
525 | PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
|
---|
526 | hwndTree = (HWND) 0;
|
---|
527 | }
|
---|
528 | else {
|
---|
529 |
|
---|
530 | ULONG size = sizeof(ULONG);
|
---|
531 |
|
---|
532 | hwndTree = StartTreeCnr(hwnd, 3);
|
---|
533 | PrfQueryProfileData(fmprof,
|
---|
534 | realappname,
|
---|
535 | "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
|
---|
536 | TreeWidth = max(TreeWidth, 80);
|
---|
537 | }
|
---|
538 | {
|
---|
539 | BOOL dummy = (hwndTree != (HWND) 0);
|
---|
540 |
|
---|
541 | PrfWriteProfileData(fmprof,
|
---|
542 | realappname,
|
---|
543 | "FM/4 TreeUp", (PVOID) & dummy, sizeof(dummy));
|
---|
544 | }
|
---|
545 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
546 | break;
|
---|
547 |
|
---|
548 | case IDM_TILEBACKWARDS:
|
---|
549 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
|
---|
550 | fTileBackwards = (fTileBackwards) ? FALSE : TRUE;
|
---|
551 | PrfWriteProfileData(fmprof,
|
---|
552 | FM3Str,
|
---|
553 | "TileBackwards",
|
---|
554 | (PVOID) & fTileBackwards, sizeof(BOOL));
|
---|
555 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
556 | break;
|
---|
557 |
|
---|
558 | case IDM_NEXTWINDOW:
|
---|
559 | case IDM_PREVWINDOW:
|
---|
560 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
561 | if (pd) {
|
---|
562 |
|
---|
563 | HWND hwndFocus;
|
---|
564 |
|
---|
565 | if (hwndTree) {
|
---|
566 | if (pd->hwndMax) {
|
---|
567 | if (hwndTree == pd->hwndCurr)
|
---|
568 | hwndFocus = pd->hwndMax;
|
---|
569 | else
|
---|
570 | hwndFocus = hwndTree;
|
---|
571 | }
|
---|
572 | else {
|
---|
573 | if (hwndTree == pd->hwndCurr)
|
---|
574 | hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
|
---|
575 | pd->hwndDir1 : pd->hwndDir2;
|
---|
576 | else if (pd->hwndDir1 == pd->hwndCurr)
|
---|
577 | hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
|
---|
578 | pd->hwndDir2 : hwndTree;
|
---|
579 | else
|
---|
580 | hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
|
---|
581 | hwndTree : pd->hwndDir1;
|
---|
582 | }
|
---|
583 | }
|
---|
584 | else {
|
---|
585 | if (pd->hwndMax)
|
---|
586 | hwndFocus = pd->hwndMax;
|
---|
587 | else
|
---|
588 | hwndFocus = pd->hwndCurr == pd->hwndDir1 ?
|
---|
589 | pd->hwndDir2 : pd->hwndDir1;
|
---|
590 | }
|
---|
591 | WinSetFocus(HWND_DESKTOP, hwndFocus);
|
---|
592 | }
|
---|
593 | break;
|
---|
594 |
|
---|
595 | case IDM_NOTEBOOK:
|
---|
596 | case IDM_DIRCNRSETTINGS:
|
---|
597 | case IDM_DIRVIEWSETTINGS:
|
---|
598 | case IDM_DIRSORTSETTINGS:
|
---|
599 | case IDM_COLLECTORVIEWSETTINGS:
|
---|
600 | case IDM_COLLECTORSORTSETTINGS:
|
---|
601 | case IDM_ARCHIVERSETTINGS:
|
---|
602 | case IDM_TREECNRVIEWSETTINGS:
|
---|
603 | case IDM_TREECNRSORTSETTINGS:
|
---|
604 | case IDM_VIEWERSETTINGS:
|
---|
605 | case IDM_VIEWERSETTINGS2:
|
---|
606 | case IDM_COMPARESETTINGS:
|
---|
607 | case IDM_MONOLITHICSETTINGS:
|
---|
608 | case IDM_GENERALSETTINGS:
|
---|
609 | case IDM_SCANSETTINGS:
|
---|
610 | case IDM_BUBBLESSETTINGS:
|
---|
611 | WinDlgBox(HWND_DESKTOP,
|
---|
612 | hwnd,
|
---|
613 | CfgDlgProc,
|
---|
614 | FM3ModHandle,
|
---|
615 | CFG_FRAME,
|
---|
616 | MPFROMLONG(mp1)); // 15 Feb 08 SHL
|
---|
617 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
618 | break;
|
---|
619 |
|
---|
620 | case IDM_SEEALL:
|
---|
621 | case IDM_GREP:
|
---|
622 | case IDM_COLLECTOR:
|
---|
623 | {
|
---|
624 | HWND hwndC;
|
---|
625 |
|
---|
626 | hwndC = StartCollector(HWND_DESKTOP, 4);
|
---|
627 | if (hwndC) {
|
---|
628 | WinSetWindowPos(hwndC,
|
---|
629 | HWND_TOP,
|
---|
630 | 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE);
|
---|
631 | if (SHORT1FROMMP(mp1) == IDM_GREP)
|
---|
632 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
|
---|
633 | WM_COMMAND, MPFROM2SHORT(IDM_GREP, 0), MPVOID);
|
---|
634 | if (SHORT1FROMMP(mp1) == IDM_SEEALL)
|
---|
635 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
|
---|
636 | WM_COMMAND, MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
|
---|
637 | }
|
---|
638 | }
|
---|
639 | break;
|
---|
640 |
|
---|
641 | case IDM_EDITCOMMANDS:
|
---|
642 | EditCommands(hwnd);
|
---|
643 | break;
|
---|
644 |
|
---|
645 | default:
|
---|
646 | if (SHORT1FROMMP(mp1) >= IDM_SWITCHSTART &&
|
---|
647 | SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499) {
|
---|
648 | if (SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches)
|
---|
649 | WinSwitchToProgram(switches[SHORT1FROMMP(mp1) - IDM_SWITCHSTART]);
|
---|
650 | break;
|
---|
651 | }
|
---|
652 | else if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
|
---|
653 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
|
---|
654 |
|
---|
655 | INT x;
|
---|
656 | HWND hwndCnr;
|
---|
657 |
|
---|
658 | if (!cmdloaded)
|
---|
659 | load_commands();
|
---|
660 | hwndCnr = TopWindow(hwnd, (HWND) 0);
|
---|
661 | hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
|
---|
662 | UM_CONTAINERHWND, MPVOID, MPVOID);
|
---|
663 | if (!hwndCnr) {
|
---|
664 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
|
---|
665 | break;
|
---|
666 | }
|
---|
667 | x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
|
---|
668 | if (x >= 0) {
|
---|
669 | x++;
|
---|
670 | RunCommand(hwndCnr, x);
|
---|
671 | if (fUnHilite) {
|
---|
672 |
|
---|
673 | PCNRITEM pci;
|
---|
674 | DIRCNRDATA *dcd = NULL;
|
---|
675 |
|
---|
676 | if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
|
---|
677 | dcd = INSTDATA(hwndCnr);
|
---|
678 | pci = (PCNRITEM) WinSendMsg(hwndCnr,
|
---|
679 | CM_QUERYRECORDEMPHASIS,
|
---|
680 | MPFROMLONG(CMA_FIRST),
|
---|
681 | MPFROMSHORT(CRA_CURSORED));
|
---|
682 | if (pci && (INT) pci != -1 && (pci->rc.flRecordAttr & CRA_SELECTED)) {
|
---|
683 | UnHilite(hwnd,
|
---|
684 | TRUE,
|
---|
685 | dcd ? &dcd->lastselection : NULL,
|
---|
686 | dcd ? dcd->ulItemsToUnHilite : 0);
|
---|
687 | }
|
---|
688 | }
|
---|
689 | }
|
---|
690 | }
|
---|
691 | else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
|
---|
692 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
|
---|
693 | if (!qtloaded)
|
---|
694 | load_quicktools();
|
---|
695 | if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
|
---|
696 | if (fToolsChanged)
|
---|
697 | save_tools(NULL);
|
---|
698 | if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
|
---|
699 | load_tools(NULL);
|
---|
700 | else {
|
---|
701 | strcpy(lasttoolbox,
|
---|
702 | quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
|
---|
703 | PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
|
---|
704 | }
|
---|
705 | BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
706 | MAIN_TOOLS), TRUE);
|
---|
707 | }
|
---|
708 | }
|
---|
709 | else {
|
---|
710 |
|
---|
711 | HWND hwndActive;
|
---|
712 |
|
---|
713 | hwndActive = TopWindow(hwnd, (HWND) 0);
|
---|
714 | if (hwndActive)
|
---|
715 | PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), msg, mp1, mp2);
|
---|
716 | }
|
---|
717 | break;
|
---|
718 | }
|
---|
719 | return 0;
|
---|
720 | }
|
---|
721 |
|
---|
722 | static MRESULT EXPENTRY MainWMOnce2(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
723 | MPARAM mp2)
|
---|
724 | {
|
---|
725 | PERSON1DATA *pd;
|
---|
726 |
|
---|
727 | switch (msg) {
|
---|
728 | case WM_CREATE:
|
---|
729 | {
|
---|
730 | TID tid;
|
---|
731 |
|
---|
732 | WinQueryWindowProcess(hwnd, &mypid, &tid);
|
---|
733 | }
|
---|
734 | hwndMain = hwnd;
|
---|
735 | WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
|
---|
736 | WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
|
---|
737 | WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
|
---|
738 | WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
|
---|
739 | if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
|
---|
740 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
741 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
742 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
743 | return 0;
|
---|
744 | }
|
---|
745 | else
|
---|
746 | DosSleep(32);//05 Aug 07 GKY 64
|
---|
747 |
|
---|
748 | pd = xmallocz(sizeof(PERSON1DATA), pszSrcFile, __LINE__);
|
---|
749 | if (!pd)
|
---|
750 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
|
---|
751 | else {
|
---|
752 | pd->size = sizeof(PERSON1DATA);
|
---|
753 | WinSetWindowPtr(hwnd, QWL_USER + 4, (PVOID) pd);
|
---|
754 | }
|
---|
755 | {
|
---|
756 | SWP swp;
|
---|
757 | PFNWP oldproc;
|
---|
758 |
|
---|
759 | /*
|
---|
760 | * create frame children (not client children, frame children)
|
---|
761 | */
|
---|
762 | DosSleep(1);
|
---|
763 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
|
---|
764 | oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
765 | (PFNWP) MainFrameWndProc2);
|
---|
766 | if (oldproc)
|
---|
767 | WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER, (PVOID) oldproc);
|
---|
768 | CommonCreateMainChildren(hwnd, &swp);
|
---|
769 |
|
---|
770 | {
|
---|
771 | HWND hwndMenu;
|
---|
772 |
|
---|
773 | hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_MENU);
|
---|
774 | WinSetWindowULong(hwnd, QWL_USER, hwndMenu);
|
---|
775 | CfgMenuInit(hwndMenu, FALSE); // 14 Feb 08 SHL
|
---|
776 | SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE);
|
---|
777 | SetConditionalCascade(hwndMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
|
---|
778 | SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
|
---|
779 | }
|
---|
780 | }
|
---|
781 | WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
782 | FID_TITLEBAR), "FM/2 Lite");
|
---|
783 | FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), NULL);
|
---|
784 | SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_SYSMENU));
|
---|
785 | break;
|
---|
786 |
|
---|
787 | case UM_SETUP:
|
---|
788 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
789 | if (pd) {
|
---|
790 |
|
---|
791 | CHAR s[CCHMAXPATH];
|
---|
792 | ULONG size;
|
---|
793 | DIRCNRDATA *dcd;
|
---|
794 | HWND hwndC;
|
---|
795 | BOOL dummy = TRUE;
|
---|
796 |
|
---|
797 | size = sizeof(BOOL);
|
---|
798 | PrfQueryProfileData(fmprof,
|
---|
799 | realappname, "FM/4 TreeUp", (PVOID) & dummy, &size);
|
---|
800 | if (dummy) {
|
---|
801 | size = sizeof(ULONG);
|
---|
802 | hwndTree = StartTreeCnr(hwnd, 3);
|
---|
803 | PrfQueryProfileData(fmprof,
|
---|
804 | realappname,
|
---|
805 | "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
|
---|
806 | TreeWidth = max(TreeWidth, 80);
|
---|
807 | }
|
---|
808 | size = sizeof(BOOL);
|
---|
809 | if (PrfQueryProfileData(fmprof,
|
---|
810 | FM3Str,
|
---|
811 | "Toolbar", &dummy, &size) && size && !dummy)
|
---|
812 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
|
---|
813 |
|
---|
814 | size = sizeof(s);
|
---|
815 | *s = 0;
|
---|
816 | if (PrfQueryProfileData(fmprof,
|
---|
817 | realappname, "FM/4 Dir1", s, &size) && *s)
|
---|
818 | MakeValidDir(s);
|
---|
819 | else
|
---|
820 | save_dir(s);
|
---|
821 | pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 =
|
---|
822 | StartDirCnr(hwnd, s, (HWND) 0, 3);
|
---|
823 | size = sizeof(s);
|
---|
824 | *s = 0;
|
---|
825 | if (PrfQueryProfileData(fmprof,
|
---|
826 | realappname, "FM/4 Dir2", s, &size) && *s)
|
---|
827 | MakeValidDir(s);
|
---|
828 | else
|
---|
829 | save_dir(s);
|
---|
830 | pd->hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3);
|
---|
831 | WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
|
---|
832 |
|
---|
833 | hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
|
---|
834 | if (hwndC) {
|
---|
835 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
836 | if (dcd) {
|
---|
837 | size = sizeof(INT);
|
---|
838 | if (PrfQueryProfileData(fmprof,
|
---|
839 | realappname,
|
---|
840 | "FM/4 Dir1.Sort",
|
---|
841 | (PVOID) & dcd->sortFlags,
|
---|
842 | &size) && size == sizeof(INT)) {
|
---|
843 | if (!dcd->sortFlags)
|
---|
844 | dcd->sortFlags = SORT_PATHNAME;
|
---|
845 | }
|
---|
846 | size = sizeof(MASK);
|
---|
847 | if (PrfQueryProfileData(fmprof,
|
---|
848 | realappname,
|
---|
849 | "FM/4 Dir1.Filter",
|
---|
850 | (PVOID) & dcd->mask, &size) && size) {
|
---|
851 | if (*dcd->mask.szMask)
|
---|
852 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
853 | UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
|
---|
854 | }
|
---|
855 | *(dcd->mask.prompt) = 0;
|
---|
856 | size = sizeof(ULONG);
|
---|
857 | if (PrfQueryProfileData(fmprof,
|
---|
858 | realappname,
|
---|
859 | "FM/4 Dir1.View",
|
---|
860 | (PVOID) & dcd->flWindowAttr,
|
---|
861 | &size) && size == sizeof(ULONG)) {
|
---|
862 |
|
---|
863 | CNRINFO cnri;
|
---|
864 |
|
---|
865 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
866 | cnri.cb = sizeof(CNRINFO);
|
---|
867 | if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
868 | CM_QUERYCNRINFO,
|
---|
869 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
|
---|
870 | cnri.flWindowAttr = dcd->flWindowAttr;
|
---|
871 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
872 | CM_SETCNRINFO,
|
---|
873 | MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
|
---|
874 | }
|
---|
875 | }
|
---|
876 | }
|
---|
877 | }
|
---|
878 |
|
---|
879 | hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
|
---|
880 | if (hwndC) {
|
---|
881 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
882 | if (dcd) {
|
---|
883 | size = sizeof(INT);
|
---|
884 | if (PrfQueryProfileData(fmprof,
|
---|
885 | realappname,
|
---|
886 | "FM/4 Dir2.Sort",
|
---|
887 | (PVOID) & dcd->sortFlags,
|
---|
888 | &size) && size == sizeof(INT)) {
|
---|
889 | if (!dcd->sortFlags)
|
---|
890 | dcd->sortFlags = SORT_PATHNAME;
|
---|
891 | }
|
---|
892 | size = sizeof(MASK);
|
---|
893 | if (PrfQueryProfileData(fmprof,
|
---|
894 | realappname,
|
---|
895 | "FM/4 Dir2.Filter",
|
---|
896 | (PVOID) & dcd->mask, &size) && size) {
|
---|
897 | if (*dcd->mask.szMask)
|
---|
898 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
899 | UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
|
---|
900 | }
|
---|
901 | *(dcd->mask.prompt) = 0;
|
---|
902 | size = sizeof(ULONG);
|
---|
903 | if (PrfQueryProfileData(fmprof,
|
---|
904 | realappname,
|
---|
905 | "FM/4 Dir2.View",
|
---|
906 | (PVOID) & dcd->flWindowAttr,
|
---|
907 | &size) && size == sizeof(ULONG)) {
|
---|
908 |
|
---|
909 | CNRINFO cnri;
|
---|
910 |
|
---|
911 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
912 | cnri.cb = sizeof(CNRINFO);
|
---|
913 | if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
914 | CM_QUERYCNRINFO,
|
---|
915 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
|
---|
916 | cnri.flWindowAttr = dcd->flWindowAttr;
|
---|
917 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
918 | CM_SETCNRINFO,
|
---|
919 | MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
|
---|
920 | }
|
---|
921 | }
|
---|
922 | }
|
---|
923 | }
|
---|
924 | }
|
---|
925 | {
|
---|
926 | ULONG which = 0, size = sizeof(ULONG);
|
---|
927 |
|
---|
928 | if (PrfQueryProfileData(fmprof,
|
---|
929 | realappname,
|
---|
930 | "FM/4 Max",
|
---|
931 | (PVOID) & which,
|
---|
932 | &size) && size == sizeof(ULONG) && which) {
|
---|
933 | PostMsg(hwnd,
|
---|
934 | UM_MAXIMIZE,
|
---|
935 | MPFROMLONG(((which == 1) ?
|
---|
936 | pd->hwndDir1 : pd->hwndDir2)), MPVOID);
|
---|
937 | }
|
---|
938 | }
|
---|
939 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
940 | if (!hwndTree)
|
---|
941 | PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
|
---|
942 | load_tools(NULL);
|
---|
943 | BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
944 | MAIN_TOOLS), TRUE);
|
---|
945 | fRunning = TRUE;
|
---|
946 | return 0;
|
---|
947 |
|
---|
948 | case WM_SAVEAPPLICATION:
|
---|
949 | WinStoreWindowPos(FM2Str,
|
---|
950 | "MainWindowPos2", WinQueryWindow(hwnd, QW_PARENT));
|
---|
951 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
952 | if (pd) {
|
---|
953 |
|
---|
954 | CHAR s[CCHMAXPATH];
|
---|
955 | HWND hwndC;
|
---|
956 | DIRCNRDATA *dcd;
|
---|
957 | ULONG flWindowAttr;
|
---|
958 |
|
---|
959 | *s = 0;
|
---|
960 | WinSendMsg(pd->hwndDir1, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
|
---|
961 | if (*s) {
|
---|
962 | MakeValidDir(s);
|
---|
963 | PrfWriteProfileString(fmprof, realappname, "FM/4 Dir1", s);
|
---|
964 | }
|
---|
965 | *s = 0;
|
---|
966 | WinSendMsg(pd->hwndDir2, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
|
---|
967 | if (*s) {
|
---|
968 | MakeValidDir(s);
|
---|
969 | PrfWriteProfileString(fmprof, realappname, "FM/4 Dir2", s);
|
---|
970 | }
|
---|
971 | flWindowAttr = (pd->hwndMax == pd->hwndDir1) ?
|
---|
972 | 1 : (pd->hwndMax == pd->hwndDir2) ? 2 : 0;
|
---|
973 | PrfWriteProfileData(fmprof,
|
---|
974 | realappname,
|
---|
975 | "FM/4 Max", &flWindowAttr, sizeof(flWindowAttr));
|
---|
976 | hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
|
---|
977 | if (hwndC) {
|
---|
978 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
979 | if (dcd) {
|
---|
980 | flWindowAttr = dcd->flWindowAttr;
|
---|
981 | if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
|
---|
982 | flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
|
---|
983 | if (dcd->lastattr) {
|
---|
984 | if (dcd->lastattr & CV_TEXT)
|
---|
985 | flWindowAttr |= CV_TEXT;
|
---|
986 | else if (dcd->lastattr & CV_DETAIL)
|
---|
987 | flWindowAttr |= CV_DETAIL;
|
---|
988 | else if (dcd->lastattr & CV_ICON)
|
---|
989 | flWindowAttr |= CV_ICON;
|
---|
990 | else
|
---|
991 | flWindowAttr |= CV_NAME;
|
---|
992 | }
|
---|
993 | else
|
---|
994 | flWindowAttr |= CV_NAME;
|
---|
995 | }
|
---|
996 | PrfWriteProfileData(fmprof,
|
---|
997 | realappname,
|
---|
998 | "FM/4 Dir1.Sort",
|
---|
999 | (PVOID) & dcd->sortFlags, sizeof(INT));
|
---|
1000 | PrfWriteProfileData(fmprof,
|
---|
1001 | realappname,
|
---|
1002 | "FM/4 Dir1.Filter",
|
---|
1003 | (PVOID) & dcd->mask, sizeof(MASK));
|
---|
1004 | PrfWriteProfileData(fmprof,
|
---|
1005 | realappname,
|
---|
1006 | "FM/4 Dir1.View",
|
---|
1007 | (PVOID) & flWindowAttr, sizeof(ULONG));
|
---|
1008 | }
|
---|
1009 | }
|
---|
1010 |
|
---|
1011 | hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
|
---|
1012 | if (hwndC) {
|
---|
1013 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
1014 | if (dcd) {
|
---|
1015 | flWindowAttr = dcd->flWindowAttr;
|
---|
1016 | if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
|
---|
1017 | flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
|
---|
1018 | if (dcd->lastattr) {
|
---|
1019 | if (dcd->lastattr & CV_TEXT)
|
---|
1020 | flWindowAttr |= CV_TEXT;
|
---|
1021 | else if (dcd->lastattr & CV_DETAIL)
|
---|
1022 | flWindowAttr |= CV_DETAIL;
|
---|
1023 | else if (dcd->lastattr & CV_ICON)
|
---|
1024 | flWindowAttr |= CV_ICON;
|
---|
1025 | else
|
---|
1026 | flWindowAttr |= CV_NAME;
|
---|
1027 | }
|
---|
1028 | else
|
---|
1029 | flWindowAttr |= CV_NAME;
|
---|
1030 | }
|
---|
1031 | PrfWriteProfileData(fmprof,
|
---|
1032 | realappname,
|
---|
1033 | "FM/4 Dir2.Sort",
|
---|
1034 | (PVOID) & dcd->sortFlags, sizeof(INT));
|
---|
1035 | PrfWriteProfileData(fmprof,
|
---|
1036 | realappname,
|
---|
1037 | "FM/4 Dir2.Filter",
|
---|
1038 | (PVOID) & dcd->mask, sizeof(MASK));
|
---|
1039 | PrfWriteProfileData(fmprof,
|
---|
1040 | realappname,
|
---|
1041 | "FM/4 Dir2.View",
|
---|
1042 | (PVOID) & flWindowAttr, sizeof(ULONG));
|
---|
1043 | }
|
---|
1044 | }
|
---|
1045 | }
|
---|
1046 | break;
|
---|
1047 | }
|
---|
1048 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | MRESULT EXPENTRY MainWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1052 | {
|
---|
1053 | PERSON1DATA *pd;
|
---|
1054 |
|
---|
1055 | switch (msg) {
|
---|
1056 | case WM_SAVEAPPLICATION:
|
---|
1057 | case UM_SETUP:
|
---|
1058 | case WM_CREATE:
|
---|
1059 | return MainWMOnce2(hwnd, msg, mp1, mp2);
|
---|
1060 |
|
---|
1061 | case UM_THREADUSE:
|
---|
1062 | case UM_LOADFILE:
|
---|
1063 | case UM_BUILDDRIVEBAR:
|
---|
1064 | return CommonMainWndProc(hwnd, msg, mp1, mp2);
|
---|
1065 |
|
---|
1066 | case UM_SETUP2:
|
---|
1067 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1068 | if (pd) {
|
---|
1069 | if (mp1) {
|
---|
1070 | if (pd->hwndDir1 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir1))
|
---|
1071 | BoxWindow(pd->hwndDir1, (HPS) 0, CLR_PALEGRAY);
|
---|
1072 | if (pd->hwndDir2 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir2))
|
---|
1073 | BoxWindow(pd->hwndDir2, (HPS) 0, CLR_PALEGRAY);
|
---|
1074 | if (hwndTree)
|
---|
1075 | BoxWindow(hwndTree, (HPS) 0, CLR_PALEGRAY);
|
---|
1076 | }
|
---|
1077 | else {
|
---|
1078 | if (hwndTree)
|
---|
1079 | BoxWindow(hwndTree,
|
---|
1080 | (HPS) 0,
|
---|
1081 | (pd->hwndCurr == hwndTree) ? CLR_RED : CLR_WHITE);
|
---|
1082 | if (!pd->hwndMax || pd->hwndMax == pd->hwndDir1)
|
---|
1083 | BoxWindow(pd->hwndDir1,
|
---|
1084 | (HPS) 0,
|
---|
1085 | (pd->hwndDir1 == pd->hwndCurr) ?
|
---|
1086 | CLR_RED :
|
---|
1087 | (pd->hwndDir1 == pd->hwndLastDir) ?
|
---|
1088 | CLR_DARKRED : CLR_PALEGRAY);
|
---|
1089 | if (!pd->hwndMax || pd->hwndMax == pd->hwndDir2)
|
---|
1090 | BoxWindow(pd->hwndDir2,
|
---|
1091 | (HPS) 0,
|
---|
1092 | (pd->hwndDir2 == pd->hwndCurr) ?
|
---|
1093 | CLR_RED :
|
---|
1094 | (pd->hwndDir2 == pd->hwndLastDir) ?
|
---|
1095 | CLR_DARKRED : CLR_PALEGRAY);
|
---|
1096 | }
|
---|
1097 | }
|
---|
1098 | return 0;
|
---|
1099 |
|
---|
1100 | case WM_BUTTON1DOWN:
|
---|
1101 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
|
---|
1102 | if (hwndTree) {
|
---|
1103 |
|
---|
1104 | SWP swp;
|
---|
1105 |
|
---|
1106 | WinQueryWindowPos(hwndTree, &swp);
|
---|
1107 | if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
|
---|
1108 | SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) {
|
---|
1109 |
|
---|
1110 | SWP swpC;
|
---|
1111 | TRACKINFO track;
|
---|
1112 |
|
---|
1113 | WinQueryWindowPos(hwnd, &swpC);
|
---|
1114 | track.cxBorder = 4;
|
---|
1115 | track.cyBorder = 4;
|
---|
1116 | track.cxGrid = 1;
|
---|
1117 | track.cyGrid = 1;
|
---|
1118 | track.cxKeyboard = 8;
|
---|
1119 | track.cyKeyboard = 8;
|
---|
1120 | track.rclTrack.yBottom = 2;
|
---|
1121 | track.rclTrack.yTop = swpC.cy - 4;
|
---|
1122 | track.rclTrack.xLeft = 2;
|
---|
1123 | track.rclTrack.xRight = swp.x + swp.cx + 2;
|
---|
1124 | track.rclBoundary = track.rclTrack;
|
---|
1125 | track.rclBoundary.xRight = swpC.cx - 80;
|
---|
1126 | track.ptlMinTrackSize.x = 80;
|
---|
1127 | track.ptlMinTrackSize.y = swpC.cy - 4;
|
---|
1128 | track.ptlMaxTrackSize.x = swpC.cx - 80;
|
---|
1129 | track.ptlMaxTrackSize.y = swpC.cy - 4;
|
---|
1130 | track.fs = TF_RIGHT;
|
---|
1131 | if (WinTrackRect(hwnd, (HPS) 0, &track)) {
|
---|
1132 | TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft;
|
---|
1133 | PrfWriteProfileData(fmprof,
|
---|
1134 | realappname,
|
---|
1135 | "FM/4 TreeWidth", &TreeWidth, sizeof(ULONG));
|
---|
1136 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
|
---|
1137 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
1138 | }
|
---|
1139 | return (MRESULT) TRUE;
|
---|
1140 | }
|
---|
1141 | }
|
---|
1142 | break;
|
---|
1143 |
|
---|
1144 | case WM_MOUSEMOVE:
|
---|
1145 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
|
---|
1146 | if (hwndTree) {
|
---|
1147 |
|
---|
1148 | SWP swp;
|
---|
1149 |
|
---|
1150 | if (WinQueryWindowPos(hwndTree, &swp)) {
|
---|
1151 | if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
|
---|
1152 | SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
|
---|
1153 | WinSetPointer(HWND_DESKTOP, hptrEW);
|
---|
1154 | else
|
---|
1155 | WinSetPointer(HWND_DESKTOP, hptrArrow);
|
---|
1156 | }
|
---|
1157 | else
|
---|
1158 | WinSetPointer(HWND_DESKTOP, hptrArrow);
|
---|
1159 | }
|
---|
1160 | return (MRESULT) TRUE;
|
---|
1161 |
|
---|
1162 | case WM_BUTTON1UP:
|
---|
1163 | case WM_BUTTON2UP:
|
---|
1164 | case WM_BUTTON3UP:
|
---|
1165 | case WM_CHAR:
|
---|
1166 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
1167 | break;
|
---|
1168 |
|
---|
1169 | case UM_ADVISEFOCUS:
|
---|
1170 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1171 | if (mp1 && pd && (HWND) mp1 != pd->hwndCurr) {
|
---|
1172 | if ((HWND) mp1 != hwndTree)
|
---|
1173 | pd->hwndLastDir = (HWND) mp1;
|
---|
1174 | pd->hwndCurr = (HWND) mp1;
|
---|
1175 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
1176 | }
|
---|
1177 | return 0;
|
---|
1178 |
|
---|
1179 | case UM_MAXIMIZE:
|
---|
1180 | if (mp1) {
|
---|
1181 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1182 | if (pd) {
|
---|
1183 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
|
---|
1184 | if (pd->hwndMax != (HWND) mp1) {
|
---|
1185 | pd->hwndMax = (HWND) mp1;
|
---|
1186 | WinSetFocus(HWND_DESKTOP, pd->hwndMax);
|
---|
1187 | }
|
---|
1188 | else
|
---|
1189 | pd->hwndMax = (HWND) 0;
|
---|
1190 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
1191 | }
|
---|
1192 | }
|
---|
1193 | return 0;
|
---|
1194 |
|
---|
1195 | case WM_INITMENU:
|
---|
1196 | switch (SHORT1FROMMP(mp1)) {
|
---|
1197 | case IDM_FILESMENU:
|
---|
1198 | case IDM_VIEWSMENU:
|
---|
1199 | case IDM_DETAILSSETUP:
|
---|
1200 | case IDM_COMMANDSMENU:
|
---|
1201 | case IDM_SORTSUBMENU:
|
---|
1202 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1203 | if (pd)
|
---|
1204 | WinSendMsg(pd->hwndCurr, UM_INITMENU, mp1, mp2);
|
---|
1205 | break;
|
---|
1206 | case IDM_CONFIGMENU:
|
---|
1207 | WinCheckMenuItem((HWND) mp2, IDM_TOOLSUBMENU, fToolbar);
|
---|
1208 | WinCheckMenuItem((HWND) mp2, IDM_AUTOVIEW, fAutoView);
|
---|
1209 | break;
|
---|
1210 | case IDM_TOOLSUBMENU:
|
---|
1211 | WinCheckMenuItem((HWND) mp2, IDM_TOOLBAR, fToolbar);
|
---|
1212 | WinCheckMenuItem((HWND) mp2, IDM_TEXTTOOLS, fTextTools);
|
---|
1213 | WinCheckMenuItem((HWND) mp2, IDM_TOOLTITLES, fToolTitles);
|
---|
1214 | break;
|
---|
1215 | case IDM_WINDOWSMENU:
|
---|
1216 | WinCheckMenuItem((HWND) mp2, IDM_VTREE, (hwndTree != (HWND) 0));
|
---|
1217 | WinCheckMenuItem((HWND) mp2, IDM_TILEBACKWARDS, fTileBackwards);
|
---|
1218 | SetupWinList((HWND) mp2, hwnd, WinQueryWindow(hwnd, QW_PARENT));
|
---|
1219 | break;
|
---|
1220 | }
|
---|
1221 | break;
|
---|
1222 |
|
---|
1223 | case WM_SETFOCUS:
|
---|
1224 | if (mp2)
|
---|
1225 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
---|
1226 | break;
|
---|
1227 |
|
---|
1228 | case UM_FOCUSME:
|
---|
1229 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1230 | if (pd)
|
---|
1231 | WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
|
---|
1232 | return 0;
|
---|
1233 |
|
---|
1234 | case UM_RESCAN:
|
---|
1235 | return 0;
|
---|
1236 |
|
---|
1237 | case UM_SIZE:
|
---|
1238 | {
|
---|
1239 | SWP swp;
|
---|
1240 |
|
---|
1241 | if (WinQueryWindowPos(hwnd, &swp)) {
|
---|
1242 | mp1 = MPFROM2SHORT(swp.cx, swp.cy);
|
---|
1243 | mp2 = MPFROM2SHORT(swp.cx, swp.cy);
|
---|
1244 | }
|
---|
1245 | else
|
---|
1246 | return 0;
|
---|
1247 | }
|
---|
1248 | /* intentional fallthru */
|
---|
1249 | case WM_SIZE:
|
---|
1250 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1251 | if (mp1 && mp2 && pd && pd->hwndDir1 && pd->hwndDir2) {
|
---|
1252 | if (hwndTree)
|
---|
1253 | WinSetWindowPos(hwndTree,
|
---|
1254 | HWND_TOP,
|
---|
1255 | 2,
|
---|
1256 | 2,
|
---|
1257 | TreeWidth - 4,
|
---|
1258 | SHORT2FROMMP(mp2) - 4,
|
---|
1259 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1260 | else
|
---|
1261 | TreeWidth = 0;
|
---|
1262 | if (!pd->hwndMax) {
|
---|
1263 | if (fTileBackwards) {
|
---|
1264 | WinSetWindowPos(pd->hwndDir1, HWND_TOP,
|
---|
1265 | (((SHORT1FROMMP(mp2) - TreeWidth) / 2) +
|
---|
1266 | TreeWidth) + 2,
|
---|
1267 | 2,
|
---|
1268 | ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
|
---|
1269 | SHORT2FROMMP(mp2) - 4,
|
---|
1270 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1271 | WinSetWindowPos(pd->hwndDir2, HWND_TOP,
|
---|
1272 | TreeWidth + 2,
|
---|
1273 | 2,
|
---|
1274 | ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
|
---|
1275 | SHORT2FROMMP(mp2) - 4,
|
---|
1276 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1277 | }
|
---|
1278 | else {
|
---|
1279 | WinSetWindowPos(pd->hwndDir1, HWND_TOP,
|
---|
1280 | TreeWidth + 2,
|
---|
1281 | 2,
|
---|
1282 | (SHORT1FROMMP(mp2) - TreeWidth) - 4,
|
---|
1283 | (SHORT2FROMMP(mp2) / 2) - 4,
|
---|
1284 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1285 | WinSetWindowPos(pd->hwndDir2, HWND_TOP,
|
---|
1286 | TreeWidth + 2,
|
---|
1287 | (SHORT2FROMMP(mp2) / 2) + 2,
|
---|
1288 | (SHORT1FROMMP(mp2) - TreeWidth) - 4,
|
---|
1289 | (SHORT2FROMMP(mp2) / 2) - 4,
|
---|
1290 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1291 | }
|
---|
1292 | }
|
---|
1293 | else {
|
---|
1294 |
|
---|
1295 | HWND hwndOther;
|
---|
1296 |
|
---|
1297 | WinSetWindowPos(pd->hwndMax, HWND_TOP,
|
---|
1298 | TreeWidth + 2,
|
---|
1299 | 2,
|
---|
1300 | (SHORT1FROMMP(mp2) - TreeWidth) - 4,
|
---|
1301 | SHORT2FROMMP(mp2) - 4,
|
---|
1302 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1303 | hwndOther = (pd->hwndMax == pd->hwndDir1) ?
|
---|
1304 | pd->hwndDir2 : pd->hwndDir1;
|
---|
1305 | WinSetWindowPos(hwndOther, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE);
|
---|
1306 | }
|
---|
1307 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
1308 | }
|
---|
1309 | if (msg == UM_SIZE)
|
---|
1310 | return 0;
|
---|
1311 | break;
|
---|
1312 |
|
---|
1313 | case WM_ERASEBACKGROUND:
|
---|
1314 | WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
|
---|
1315 | return 0;
|
---|
1316 |
|
---|
1317 | case WM_PAINT:
|
---|
1318 | {
|
---|
1319 | HPS hps;
|
---|
1320 | RECTL rcl;
|
---|
1321 |
|
---|
1322 | hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
|
---|
1323 | if (hps) {
|
---|
1324 | WinQueryWindowRect(hwnd, &rcl);
|
---|
1325 | WinFillRect(hps, (PRECTL) & rcl, CLR_PALEGRAY);
|
---|
1326 | WinEndPaint(hps);
|
---|
1327 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
1328 | }
|
---|
1329 | }
|
---|
1330 | break;
|
---|
1331 |
|
---|
1332 | case UM_COMMAND:
|
---|
1333 | case WM_COMMAND:
|
---|
1334 | return MainWMCommand2(hwnd, msg, mp1, mp2);
|
---|
1335 |
|
---|
1336 | case WM_CLOSE:
|
---|
1337 | fAmClosing = TRUE;
|
---|
1338 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
|
---|
1339 | CloseChildren(hwnd);
|
---|
1340 | PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
|
---|
1341 | DosSleep(1);
|
---|
1342 | return 0;
|
---|
1343 |
|
---|
1344 | case UM_CLOSE:
|
---|
1345 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
|
---|
1346 | return 0;
|
---|
1347 |
|
---|
1348 | case WM_DESTROY:
|
---|
1349 | hwndMain = (HWND) 0;
|
---|
1350 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1351 | xfree(pd, pszSrcFile, __LINE__);
|
---|
1352 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
1353 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
1354 | break;
|
---|
1355 | }
|
---|
1356 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
1357 | }
|
---|
1358 |
|
---|
1359 | HWND StartFM32(HAB hab, INT argc, CHAR ** argv)
|
---|
1360 | {
|
---|
1361 | HWND hwndFrame, hwndClient;
|
---|
1362 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
|
---|
1363 | FCF_SIZEBORDER | FCF_MINMAX |
|
---|
1364 | FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
|
---|
1365 |
|
---|
1366 | {
|
---|
1367 | INT x;
|
---|
1368 |
|
---|
1369 | for (x = 1; x < argc; x++) {
|
---|
1370 | if (*argv[x] == '+' && !argv[x][1])
|
---|
1371 | fLogFile = TRUE;
|
---|
1372 | if (*argv[x] == '-') {
|
---|
1373 | if (argv[x][1])
|
---|
1374 | strcpy(profile, &argv[x][1]);
|
---|
1375 | }
|
---|
1376 | }
|
---|
1377 | }
|
---|
1378 | {
|
---|
1379 | CHAR inipath[CCHMAXPATH], fullpath[CCHMAXPATH];
|
---|
1380 | FILESTATUS3 fsa;
|
---|
1381 |
|
---|
1382 | if (PrfQueryProfileString(HINI_USERPROFILE,
|
---|
1383 | FM2Str,
|
---|
1384 | "Home", NULL, inipath, sizeof(inipath))) {
|
---|
1385 | if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, sizeof(fsa))) {
|
---|
1386 | if (fsa.attrFile & FILE_DIRECTORY) {
|
---|
1387 | if (DosQueryPathInfo(inipath,
|
---|
1388 | FIL_QUERYFULLNAME, fullpath, sizeof(fullpath)))
|
---|
1389 | strcpy(fullpath, inipath);
|
---|
1390 | switch_to(fullpath);
|
---|
1391 | }
|
---|
1392 | }
|
---|
1393 | }
|
---|
1394 | }
|
---|
1395 |
|
---|
1396 | hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
|
---|
1397 | WS_VISIBLE,
|
---|
1398 | &FrameFlags,
|
---|
1399 | WC_MAINWND2,
|
---|
1400 | NULL,
|
---|
1401 | WS_VISIBLE | WS_ANIMATE,
|
---|
1402 | FM3ModHandle, MAIN2_FRAME, &hwndClient);
|
---|
1403 | if (hwndFrame) {
|
---|
1404 | hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
|
---|
1405 | if (!WinRestoreWindowPos(FM2Str, "MainWindowPos2", hwndFrame)) {
|
---|
1406 |
|
---|
1407 | ULONG fl = SWP_MOVE | SWP_SIZE;
|
---|
1408 | RECTL rcl;
|
---|
1409 | ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
|
---|
1410 | ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
|
---|
1411 |
|
---|
1412 | WinQueryWindowRect(HWND_DESKTOP, &rcl);
|
---|
1413 | rcl.yBottom += icz;
|
---|
1414 | rcl.yTop -= bsz;
|
---|
1415 | rcl.xLeft += bsz;
|
---|
1416 | rcl.xRight -= bsz;
|
---|
1417 | WinSetWindowPos(hwndFrame,
|
---|
1418 | HWND_TOP,
|
---|
1419 | rcl.xLeft,
|
---|
1420 | rcl.yBottom,
|
---|
1421 | rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
|
---|
1422 | }
|
---|
1423 | if (fLogFile)
|
---|
1424 | LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
|
---|
1425 | if (hwndHelp)
|
---|
1426 | WinAssociateHelpInstance(hwndHelp, hwndFrame);
|
---|
1427 | PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
|
---|
1428 | }
|
---|
1429 | return hwndFrame;
|
---|
1430 | }
|
---|
1431 |
|
---|
1432 | #pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2)
|
---|
1433 | #pragma alloc_text(PERSON12,StartFM32,MainWMOnce2)
|
---|
1434 | #pragma alloc_text(PERSON13,MainWMCommand2)
|
---|