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