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