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