1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: mainwnd2.c 1778 2014-06-26 22:30:54Z 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 | BOOL yes;
|
---|
439 |
|
---|
440 | SetShiftState();
|
---|
441 | switch (SHORT1FROMMP(mp1)) {
|
---|
442 | case IDM_TOAUTOMLE:
|
---|
443 | case IDM_CLI:
|
---|
444 | case IDM_CREATETOOL:
|
---|
445 | case IDM_ABOUT:
|
---|
446 | case IDM_WINFULLSCREEN:
|
---|
447 | case IDM_DOSCOMMANDLINE:
|
---|
448 | case IDM_INIVIEWER:
|
---|
449 | case IDM_INIVIEWERFM2:
|
---|
450 | case IDM_INIVIEWERSYS:
|
---|
451 | case IDM_EDITASSOC:
|
---|
452 | case IDM_COMMANDLINE:
|
---|
453 | case IDM_KILLPROC:
|
---|
454 | case IDM_TOOLBAR:
|
---|
455 | case IDM_TEXTTOOLS:
|
---|
456 | case IDM_TOOLTITLES:
|
---|
457 | case IDM_TOOLLEFT:
|
---|
458 | case IDM_TOOLRIGHT:
|
---|
459 | case IDM_AUTOVIEWCOMMENTS:
|
---|
460 | case IDM_AUTOVIEWFILE:
|
---|
461 | case IDM_AUTOVIEW:
|
---|
462 | case IDM_CONFIRMDELETE: // 2014-05-17 SHL
|
---|
463 | case IDM_TOGGLEDRAGDIALOG: // 2014-05-15 SHL
|
---|
464 | // case IDM_SYSINFO:
|
---|
465 | case IDM_HIDENOTEWND:
|
---|
466 | case IDM_SHOWNOTEWND:
|
---|
467 | case IDM_INSTANT:
|
---|
468 | case IDM_HELPCONTEXT:
|
---|
469 | case IDM_HELPHINTS:
|
---|
470 | case IDM_HELPPIX:
|
---|
471 | case IDM_KILLME:
|
---|
472 | case IDM_EXIT:
|
---|
473 | case IDM_HELPTUTOR:
|
---|
474 | case IDM_HELPCONTENTS:
|
---|
475 | case IDM_HELPGENERAL:
|
---|
476 | case IDM_HELPKEYS:
|
---|
477 | case IDM_HELPMOUSE:
|
---|
478 | case IDM_HELP:
|
---|
479 | case IDM_FONTPALETTE:
|
---|
480 | case IDM_HICOLORPALETTE:
|
---|
481 | case IDM_COLORPALETTE:
|
---|
482 | case IDM_SYSTEMCLOCK:
|
---|
483 | return MainWMCommand(hwnd, msg, mp1, mp2);
|
---|
484 |
|
---|
485 | case IDM_REMAP:
|
---|
486 | WinDlgBox(HWND_DESKTOP,
|
---|
487 | hwnd, RemapDlgProc, FM3ModHandle, MAP_FRAME, NULL);
|
---|
488 | break;
|
---|
489 |
|
---|
490 | case IDM_TWODIRS: // Menu action
|
---|
491 | case IDM_WINDOWDLG: // Toolbar action
|
---|
492 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
493 | if (pd) {
|
---|
494 |
|
---|
495 | WALK2 wa;
|
---|
496 |
|
---|
497 | memset(&wa, 0, sizeof(wa));
|
---|
498 | wa.size = sizeof(wa);
|
---|
499 | *wa.szCurrentPath1 = 0;
|
---|
500 | WinSendMsg(pd->hwndDir1,
|
---|
501 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
|
---|
502 | MakeValidDir(wa.szCurrentPath1);
|
---|
503 | *wa.szCurrentPath2 = 0;
|
---|
504 | WinSendMsg(pd->hwndDir2,
|
---|
505 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
|
---|
506 | MakeValidDir(wa.szCurrentPath2);
|
---|
507 | if (WinDlgBox(HWND_DESKTOP,
|
---|
508 | hwnd,
|
---|
509 | WalkTwoSetDlgProc,
|
---|
510 | FM3ModHandle,
|
---|
511 | WALK2_FRAME,
|
---|
512 | MPFROMP(&wa)) &&
|
---|
513 | (IsRoot(wa.szCurrentPath1) ||
|
---|
514 | !IsFile(wa.szCurrentPath1)) &&
|
---|
515 | (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) {
|
---|
516 | WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir1,
|
---|
517 | FID_CLIENT), DIR_CNR),
|
---|
518 | UM_SETDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
|
---|
519 | WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir2,
|
---|
520 | FID_CLIENT), DIR_CNR),
|
---|
521 | UM_SETDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
|
---|
522 | }
|
---|
523 | }
|
---|
524 | break;
|
---|
525 |
|
---|
526 | case IDM_COMPARE:
|
---|
527 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
528 | if (pd) {
|
---|
529 |
|
---|
530 | WALK2 wa;
|
---|
531 |
|
---|
532 | memset(&wa, 0, sizeof(wa));
|
---|
533 | wa.size = sizeof(wa);
|
---|
534 | *wa.szCurrentPath1 = 0;
|
---|
535 | WinSendMsg(pd->hwndDir1,
|
---|
536 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
|
---|
537 | MakeValidDir(wa.szCurrentPath1);
|
---|
538 | *wa.szCurrentPath2 = 0;
|
---|
539 | WinSendMsg(pd->hwndDir2,
|
---|
540 | UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
|
---|
541 | MakeValidDir(wa.szCurrentPath2);
|
---|
542 | if (WinDlgBox(HWND_DESKTOP,
|
---|
543 | hwnd,
|
---|
544 | WalkTwoCmpDlgProc,
|
---|
545 | FM3ModHandle,
|
---|
546 | WALK2_FRAME,
|
---|
547 | MPFROMP(&wa)) &&
|
---|
548 | (IsRoot(wa.szCurrentPath1) ||
|
---|
549 | !IsFile(wa.szCurrentPath1)) &&
|
---|
550 | (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) {
|
---|
551 | if (!*dircompare) {
|
---|
552 |
|
---|
553 | COMPARE *cmp;
|
---|
554 |
|
---|
555 | cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
|
---|
556 | if (cmp) {
|
---|
557 | cmp->size = sizeof(COMPARE);
|
---|
558 | strcpy(cmp->leftdir, wa.szCurrentPath1);
|
---|
559 | strcpy(cmp->rightdir, wa.szCurrentPath2);
|
---|
560 | cmp->listfile = wa.listfile;
|
---|
561 | cmp->includesubdirs = wa.includesubdirs;
|
---|
562 | cmp->hwndParent = hwnd;
|
---|
563 | cmp->dcd.hwndParent = hwnd;
|
---|
564 | WinDlgBox(HWND_DESKTOP,
|
---|
565 | HWND_DESKTOP,
|
---|
566 | CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
|
---|
567 | }
|
---|
568 | }
|
---|
569 | else {
|
---|
570 | CHAR szPath1[CCHMAXPATH];
|
---|
571 | CHAR szPath2[CCHMAXPATH];
|
---|
572 | runemf2(SEPARATE,
|
---|
573 | HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
574 | NULL, NULL,
|
---|
575 | "%s %s %s",
|
---|
576 | dircompare,
|
---|
577 | BldQuotedFileName(szPath1, wa.szCurrentPath1),
|
---|
578 | BldQuotedFileName(szPath2, wa.szCurrentPath2));
|
---|
579 | }
|
---|
580 | }
|
---|
581 | }
|
---|
582 | break;
|
---|
583 |
|
---|
584 | case IDM_VTREE:
|
---|
585 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
|
---|
586 | if (hwndTree) {
|
---|
587 | // Hide
|
---|
588 | WinShowWindow(hwndTree, FALSE);
|
---|
589 | PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
|
---|
590 | hwndTree = NULLHANDLE;
|
---|
591 | }
|
---|
592 | else {
|
---|
593 | // Create tree window if needed and make visible
|
---|
594 | ULONG size = sizeof(ULONG);
|
---|
595 | hwndTree = StartTreeCnr(hwnd, 3);
|
---|
596 | PrfQueryProfileData(fmprof, realappname,
|
---|
597 | "FM/4 TreeWidth", (PVOID)&TreeWidth, &size);
|
---|
598 | TreeWidth = max(TreeWidth, 80);
|
---|
599 | }
|
---|
600 | yes = hwndTree != NULLHANDLE;
|
---|
601 | PrfWriteProfileData(fmprof, realappname,
|
---|
602 | "FM/4 TreeUp", (PVOID)&yes, sizeof(yes));
|
---|
603 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
604 | break;
|
---|
605 |
|
---|
606 | case IDM_TILEBACKWARDS:
|
---|
607 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
|
---|
608 | fTileBackwards = (fTileBackwards) ? FALSE : TRUE;
|
---|
609 | PrfWriteProfileData(fmprof,
|
---|
610 | FM3Str,
|
---|
611 | "TileBackwards",
|
---|
612 | (PVOID) & fTileBackwards, sizeof(BOOL));
|
---|
613 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
614 | break;
|
---|
615 |
|
---|
616 | case IDM_NEXTWINDOW:
|
---|
617 | case IDM_PREVWINDOW:
|
---|
618 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
619 | if (pd) {
|
---|
620 |
|
---|
621 | HWND hwndFocus;
|
---|
622 |
|
---|
623 | if (hwndTree) {
|
---|
624 | if (pd->hwndMax) {
|
---|
625 | if (hwndTree == pd->hwndCurr)
|
---|
626 | hwndFocus = pd->hwndMax;
|
---|
627 | else
|
---|
628 | hwndFocus = hwndTree;
|
---|
629 | }
|
---|
630 | else {
|
---|
631 | if (hwndTree == pd->hwndCurr)
|
---|
632 | hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
|
---|
633 | pd->hwndDir1 : pd->hwndDir2;
|
---|
634 | else if (pd->hwndDir1 == pd->hwndCurr)
|
---|
635 | hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
|
---|
636 | pd->hwndDir2 : hwndTree;
|
---|
637 | else
|
---|
638 | hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
|
---|
639 | hwndTree : pd->hwndDir1;
|
---|
640 | }
|
---|
641 | }
|
---|
642 | else {
|
---|
643 | if (pd->hwndMax)
|
---|
644 | hwndFocus = pd->hwndMax;
|
---|
645 | else
|
---|
646 | hwndFocus = pd->hwndCurr == pd->hwndDir1 ?
|
---|
647 | pd->hwndDir2 : pd->hwndDir1;
|
---|
648 | }
|
---|
649 | WinSetFocus(HWND_DESKTOP, hwndFocus);
|
---|
650 | }
|
---|
651 | break;
|
---|
652 |
|
---|
653 | case IDM_NOTEBOOK:
|
---|
654 | case IDM_DIRCNRSETTINGS:
|
---|
655 | case IDM_DIRVIEWSETTINGS:
|
---|
656 | case IDM_DIRSORTSETTINGS:
|
---|
657 | case IDM_COLLECTORVIEWSETTINGS:
|
---|
658 | case IDM_COLLECTORSORTSETTINGS:
|
---|
659 | case IDM_ARCHIVERSETTINGS:
|
---|
660 | case IDM_TREECNRVIEWSETTINGS:
|
---|
661 | case IDM_TREECNRSORTSETTINGS:
|
---|
662 | case IDM_VIEWERSETTINGS:
|
---|
663 | case IDM_VIEWERSETTINGS2:
|
---|
664 | case IDM_COMPARESETTINGS:
|
---|
665 | case IDM_MONOLITHICSETTINGS:
|
---|
666 | case IDM_GENERALSETTINGS:
|
---|
667 | case IDM_SCANSETTINGS:
|
---|
668 | case IDM_BUBBLESSETTINGS:
|
---|
669 | WinDlgBox(HWND_DESKTOP,
|
---|
670 | hwnd,
|
---|
671 | CfgDlgProc,
|
---|
672 | FM3ModHandle,
|
---|
673 | CFG_FRAME,
|
---|
674 | MPFROMLONG(mp1)); // 15 Feb 08 SHL
|
---|
675 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
676 | break;
|
---|
677 |
|
---|
678 | case IDM_SEEALL:
|
---|
679 | case IDM_GREP:
|
---|
680 | case IDM_COLLECTOR:
|
---|
681 | {
|
---|
682 | HWND hwndC;
|
---|
683 |
|
---|
684 | hwndC = StartCollector(HWND_DESKTOP, 4);
|
---|
685 | if (hwndC) {
|
---|
686 | WinSetWindowPos(hwndC,
|
---|
687 | HWND_TOP,
|
---|
688 | 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE);
|
---|
689 | if (SHORT1FROMMP(mp1) == IDM_GREP)
|
---|
690 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
|
---|
691 | WM_COMMAND, MPFROM2SHORT(IDM_GREP, 0), MPVOID);
|
---|
692 | if (SHORT1FROMMP(mp1) == IDM_SEEALL)
|
---|
693 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
|
---|
694 | WM_COMMAND, MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
|
---|
695 | }
|
---|
696 | }
|
---|
697 | break;
|
---|
698 |
|
---|
699 | case IDM_EDITCOMMANDS:
|
---|
700 | EditCommands(hwnd);
|
---|
701 | break;
|
---|
702 |
|
---|
703 | default:
|
---|
704 | if (SHORT1FROMMP(mp1) >= IDM_SWITCHSTART &&
|
---|
705 | SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499) {
|
---|
706 | if (SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches)
|
---|
707 | WinSwitchToProgram(switches[SHORT1FROMMP(mp1) - IDM_SWITCHSTART]);
|
---|
708 | break;
|
---|
709 | }
|
---|
710 | else if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
|
---|
711 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
|
---|
712 |
|
---|
713 | INT x;
|
---|
714 | HWND hwndCnr;
|
---|
715 |
|
---|
716 | if (!cmdloaded)
|
---|
717 | load_commands();
|
---|
718 | hwndCnr = TopWindow(hwnd, (HWND) 0);
|
---|
719 | hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
|
---|
720 | UM_CONTAINERHWND, MPVOID, MPVOID);
|
---|
721 | if (!hwndCnr) {
|
---|
722 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
723 | break;
|
---|
724 | }
|
---|
725 | x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART;
|
---|
726 | if (x >= 0) {
|
---|
727 | //x++;
|
---|
728 | RunCommand(hwndCnr, x);
|
---|
729 | if (fUnHilite) {
|
---|
730 |
|
---|
731 | PCNRITEM pci;
|
---|
732 | DIRCNRDATA *dcd = NULL;
|
---|
733 |
|
---|
734 | if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
|
---|
735 | dcd = INSTDATA(hwndCnr);
|
---|
736 | pci = (PCNRITEM) WinSendMsg(hwndCnr,
|
---|
737 | CM_QUERYRECORDEMPHASIS,
|
---|
738 | MPFROMLONG(CMA_FIRST),
|
---|
739 | MPFROMSHORT(CRA_CURSORED));
|
---|
740 | if (pci && (INT) pci != -1 && (pci->rc.flRecordAttr & CRA_SELECTED)) {
|
---|
741 | UnHilite(hwnd,
|
---|
742 | TRUE,
|
---|
743 | dcd ? &dcd->lastselection : NULL,
|
---|
744 | dcd ? dcd->ulItemsToUnHilite : 0);
|
---|
745 | }
|
---|
746 | }
|
---|
747 | }
|
---|
748 | }
|
---|
749 | else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
|
---|
750 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) {
|
---|
751 | if (!qtloaded)
|
---|
752 | load_quicktools();
|
---|
753 | if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) {
|
---|
754 | if (fToolsChanged)
|
---|
755 | save_tools(NULL);
|
---|
756 | if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]))
|
---|
757 | load_tools(NULL);
|
---|
758 | else {
|
---|
759 | strcpy(lasttoolbar,
|
---|
760 | quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]);
|
---|
761 | PrfWriteProfileString(fmprof, appname, "LastToolbar", lasttoolbar);
|
---|
762 | }
|
---|
763 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
|
---|
764 | }
|
---|
765 | }
|
---|
766 | else {
|
---|
767 |
|
---|
768 | HWND hwndActive;
|
---|
769 |
|
---|
770 | hwndActive = TopWindow(hwnd, (HWND) 0);
|
---|
771 | if (hwndActive)
|
---|
772 | PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), msg, mp1, mp2);
|
---|
773 | }
|
---|
774 | break;
|
---|
775 | }
|
---|
776 | return 0;
|
---|
777 | }
|
---|
778 |
|
---|
779 | static MRESULT EXPENTRY MainWMOnce2(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
780 | MPARAM mp2)
|
---|
781 | {
|
---|
782 | PERSON1DATA *pd;
|
---|
783 | TID tid;
|
---|
784 | SWP swp;
|
---|
785 | PFNWP oldproc;
|
---|
786 | HWND hwndMenu;
|
---|
787 | DIRCNRDATA *dcd;
|
---|
788 | HWND hwndC;
|
---|
789 | ULONG which;
|
---|
790 | ULONG size;
|
---|
791 | BOOL yes;
|
---|
792 |
|
---|
793 | switch (msg) {
|
---|
794 | case WM_CREATE:
|
---|
795 | WinQueryWindowProcess(hwnd, &mypid, &tid);
|
---|
796 | hwndMain = hwnd;
|
---|
797 |
|
---|
798 | WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
|
---|
799 | WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
|
---|
800 | WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
|
---|
801 | WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
|
---|
802 | if (xbeginthread(MakeMainObjWin,
|
---|
803 | 245760,
|
---|
804 | MPVOID,
|
---|
805 | pszSrcFile,
|
---|
806 | __LINE__) == -1)
|
---|
807 | {
|
---|
808 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
809 | return 0;
|
---|
810 | }
|
---|
811 | else
|
---|
812 | DosSleep(32);//05 Aug 07 GKY 64
|
---|
813 |
|
---|
814 | pd = xmallocz(sizeof(PERSON1DATA), pszSrcFile, __LINE__);
|
---|
815 | if (!pd)
|
---|
816 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
|
---|
817 | else {
|
---|
818 | pd->size = sizeof(PERSON1DATA);
|
---|
819 | WinSetWindowPtr(hwnd, QWL_USER + 4, (PVOID) pd);
|
---|
820 | }
|
---|
821 |
|
---|
822 | // create frame children (not client children, frame children)
|
---|
823 | DosSleep(1);
|
---|
824 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
|
---|
825 | oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
826 | (PFNWP) MainFrameWndProc2);
|
---|
827 | if (oldproc)
|
---|
828 | WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER, (PVOID) oldproc);
|
---|
829 |
|
---|
830 | CommonCreateMainChildren(hwnd, &swp);
|
---|
831 |
|
---|
832 | hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_MENU);
|
---|
833 | WinSetWindowULong(hwnd, QWL_USER, hwndMenu);
|
---|
834 |
|
---|
835 | // 2014-05-15 SHL FIXME to be sure needed
|
---|
836 | // WinCheckMenuItem(hwndMenu, IDM_TOGGLEDRAGDIALOG, fDragndropDlg); // 2014-05-15 SHL
|
---|
837 |
|
---|
838 | CfgMenuInit(hwndMenu, FALSE); // 14 Feb 08 SHL
|
---|
839 | SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE);
|
---|
840 |
|
---|
841 | if (fProtectOnly) {
|
---|
842 | WinEnableMenuItem(hwndMenu, IDM_DOSCOMMANDLINE, FALSE);
|
---|
843 | WinEnableMenuItem(hwndMenu, IDM_WINFULLSCREEN, FALSE);
|
---|
844 | }
|
---|
845 |
|
---|
846 | SetConditionalCascade(hwndMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
|
---|
847 | SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
|
---|
848 |
|
---|
849 | WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
850 | FID_TITLEBAR), "FM/2 Lite");
|
---|
851 |
|
---|
852 | FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), NULL);
|
---|
853 | SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_SYSMENU));
|
---|
854 | break;
|
---|
855 |
|
---|
856 | case UM_SETUP:
|
---|
857 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
858 | if (pd) {
|
---|
859 | CHAR s[CCHMAXPATH];
|
---|
860 | yes = TRUE;
|
---|
861 | size = sizeof(BOOL);
|
---|
862 | PrfQueryProfileData(fmprof, realappname,
|
---|
863 | "FM/4 TreeUp", (PVOID)&yes, &size);
|
---|
864 | if (yes) {
|
---|
865 | hwndTree = StartTreeCnr(hwnd, 3);
|
---|
866 | size = sizeof(TreeWidth);
|
---|
867 | PrfQueryProfileData(fmprof, realappname, "FM/4 TreeWidth",
|
---|
868 | (PVOID)&TreeWidth, &size);
|
---|
869 | TreeWidth = max(TreeWidth, 80);
|
---|
870 | }
|
---|
871 | size = sizeof(BOOL);
|
---|
872 | if (PrfQueryProfileData(fmprof, appname, "Toolbar", &yes, &size) &&
|
---|
873 | size &&
|
---|
874 | !yes)
|
---|
875 | {
|
---|
876 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
|
---|
877 | }
|
---|
878 |
|
---|
879 | size = sizeof(s);
|
---|
880 | *s = 0;
|
---|
881 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1", s, &size) && *s)
|
---|
882 | MakeValidDir(s);
|
---|
883 | else
|
---|
884 | save_dir(s);
|
---|
885 | pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 =
|
---|
886 | StartDirCnr(hwnd, s, (HWND) 0, 3);
|
---|
887 | size = sizeof(s);
|
---|
888 | *s = 0;
|
---|
889 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2", s, &size) && *s)
|
---|
890 | MakeValidDir(s);
|
---|
891 | else
|
---|
892 | save_dir(s);
|
---|
893 | pd->hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3);
|
---|
894 | WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
|
---|
895 |
|
---|
896 | hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
|
---|
897 | if (hwndC) {
|
---|
898 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
899 | if (dcd) {
|
---|
900 | size = sizeof(INT);
|
---|
901 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.Sort",
|
---|
902 | (PVOID) & dcd->sortFlags,
|
---|
903 | &size) && size == sizeof(INT)) {
|
---|
904 | if (!dcd->sortFlags)
|
---|
905 | dcd->sortFlags = SORT_PATHNAME;
|
---|
906 | }
|
---|
907 | size = sizeof(MASK);
|
---|
908 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.Filter",
|
---|
909 | (PVOID) & dcd->mask, &size) && size) {
|
---|
910 | if (*dcd->mask.szMask)
|
---|
911 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
912 | UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
|
---|
913 | }
|
---|
914 | *(dcd->mask.prompt) = 0;
|
---|
915 | size = sizeof(ULONG);
|
---|
916 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.View",
|
---|
917 | (PVOID) & dcd->flWindowAttr,
|
---|
918 | &size) && size == sizeof(ULONG)) {
|
---|
919 |
|
---|
920 | CNRINFO cnri;
|
---|
921 |
|
---|
922 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
923 | cnri.cb = sizeof(CNRINFO);
|
---|
924 | if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
925 | CM_QUERYCNRINFO,
|
---|
926 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
|
---|
927 | cnri.flWindowAttr = dcd->flWindowAttr;
|
---|
928 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
929 | CM_SETCNRINFO,
|
---|
930 | MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
|
---|
931 | }
|
---|
932 | }
|
---|
933 | }
|
---|
934 | }
|
---|
935 |
|
---|
936 | hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
|
---|
937 | if (hwndC) {
|
---|
938 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
939 | if (dcd) {
|
---|
940 | size = sizeof(INT);
|
---|
941 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.Sort",
|
---|
942 | (PVOID) & dcd->sortFlags,
|
---|
943 | &size) && size == sizeof(INT)) {
|
---|
944 | if (!dcd->sortFlags)
|
---|
945 | dcd->sortFlags = SORT_PATHNAME;
|
---|
946 | }
|
---|
947 | size = sizeof(MASK);
|
---|
948 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.Filter",
|
---|
949 | (PVOID) & dcd->mask, &size) && size) {
|
---|
950 | if (*dcd->mask.szMask)
|
---|
951 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
952 | UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
|
---|
953 | }
|
---|
954 | *(dcd->mask.prompt) = 0;
|
---|
955 | size = sizeof(ULONG);
|
---|
956 | if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.View",
|
---|
957 | (PVOID) & dcd->flWindowAttr,
|
---|
958 | &size) && size == sizeof(ULONG)) {
|
---|
959 |
|
---|
960 | CNRINFO cnri;
|
---|
961 |
|
---|
962 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
963 | cnri.cb = sizeof(CNRINFO);
|
---|
964 | if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
965 | CM_QUERYCNRINFO,
|
---|
966 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
|
---|
967 | cnri.flWindowAttr = dcd->flWindowAttr;
|
---|
968 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
|
---|
969 | CM_SETCNRINFO,
|
---|
970 | MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
|
---|
971 | }
|
---|
972 | }
|
---|
973 | }
|
---|
974 | }
|
---|
975 | }
|
---|
976 | // 2014-06-11 SHL Initialize view, sort and filter button text
|
---|
977 | if (pd->hwndDir1) {
|
---|
978 | hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
|
---|
979 | if (hwndC) {
|
---|
980 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
981 | if (dcd && dcd->hwndCnr)
|
---|
982 | PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
|
---|
983 | }
|
---|
984 | }
|
---|
985 | if (pd->hwndDir2) {
|
---|
986 | hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
|
---|
987 | if (hwndC) {
|
---|
988 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
989 | if (dcd && dcd->hwndCnr)
|
---|
990 | PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
|
---|
991 | }
|
---|
992 | }
|
---|
993 |
|
---|
994 | which = 0;
|
---|
995 | size = sizeof(ULONG);
|
---|
996 | if (PrfQueryProfileData(fmprof,
|
---|
997 | realappname,
|
---|
998 | "FM/4 Max",
|
---|
999 | (PVOID)&which,
|
---|
1000 | &size) &&
|
---|
1001 | size == sizeof(ULONG) &&
|
---|
1002 | which)
|
---|
1003 | {
|
---|
1004 | PostMsg(hwnd,
|
---|
1005 | UM_MAXIMIZE,
|
---|
1006 | MPFROMLONG(((which == 1) ?
|
---|
1007 | pd->hwndDir1 : pd->hwndDir2)), MPVOID);
|
---|
1008 | }
|
---|
1009 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
1010 | if (!hwndTree)
|
---|
1011 | PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
|
---|
1012 | load_tools(NULL);
|
---|
1013 | PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
|
---|
1014 | fRunning = TRUE;
|
---|
1015 | return 0;
|
---|
1016 |
|
---|
1017 | case WM_SAVEAPPLICATION:
|
---|
1018 | WinStoreWindowPos((CHAR *) FM2Str,
|
---|
1019 | "MainWindowPos2", WinQueryWindow(hwnd, QW_PARENT));
|
---|
1020 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1021 | if (pd) {
|
---|
1022 |
|
---|
1023 | CHAR s[CCHMAXPATH];
|
---|
1024 | HWND hwndC;
|
---|
1025 | DIRCNRDATA *dcd;
|
---|
1026 | ULONG flWindowAttr;
|
---|
1027 |
|
---|
1028 | *s = 0;
|
---|
1029 | WinSendMsg(pd->hwndDir1, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
|
---|
1030 | if (*s) {
|
---|
1031 | MakeValidDir(s);
|
---|
1032 | PrfWriteProfileString(fmprof, realappname, "FM/4 Dir1", s);
|
---|
1033 | }
|
---|
1034 | *s = 0;
|
---|
1035 | WinSendMsg(pd->hwndDir2, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
|
---|
1036 | if (*s) {
|
---|
1037 | MakeValidDir(s);
|
---|
1038 | PrfWriteProfileString(fmprof, realappname, "FM/4 Dir2", s);
|
---|
1039 | }
|
---|
1040 | flWindowAttr = (pd->hwndMax == pd->hwndDir1) ?
|
---|
1041 | 1 : (pd->hwndMax == pd->hwndDir2) ? 2 : 0;
|
---|
1042 | PrfWriteProfileData(fmprof,
|
---|
1043 | realappname,
|
---|
1044 | "FM/4 Max", &flWindowAttr, sizeof(flWindowAttr));
|
---|
1045 | hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
|
---|
1046 | if (hwndC) {
|
---|
1047 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
1048 | if (dcd) {
|
---|
1049 | flWindowAttr = dcd->flWindowAttr;
|
---|
1050 | if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
|
---|
1051 | flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
|
---|
1052 | if (dcd->lastattr) {
|
---|
1053 | if (dcd->lastattr & CV_TEXT)
|
---|
1054 | flWindowAttr |= CV_TEXT;
|
---|
1055 | else if (dcd->lastattr & CV_DETAIL)
|
---|
1056 | flWindowAttr |= CV_DETAIL;
|
---|
1057 | else if (dcd->lastattr & CV_ICON)
|
---|
1058 | flWindowAttr |= CV_ICON;
|
---|
1059 | else
|
---|
1060 | flWindowAttr |= CV_NAME;
|
---|
1061 | }
|
---|
1062 | else
|
---|
1063 | flWindowAttr |= CV_NAME;
|
---|
1064 | }
|
---|
1065 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.Sort",
|
---|
1066 | (PVOID) & dcd->sortFlags, sizeof(INT));
|
---|
1067 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.Filter",
|
---|
1068 | (PVOID) & dcd->mask, sizeof(MASK));
|
---|
1069 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.View",
|
---|
1070 | (PVOID) & flWindowAttr, sizeof(ULONG));
|
---|
1071 | }
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
|
---|
1075 | if (hwndC) {
|
---|
1076 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
|
---|
1077 | if (dcd) {
|
---|
1078 | flWindowAttr = dcd->flWindowAttr;
|
---|
1079 | if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
|
---|
1080 | flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
|
---|
1081 | if (dcd->lastattr) {
|
---|
1082 | if (dcd->lastattr & CV_TEXT)
|
---|
1083 | flWindowAttr |= CV_TEXT;
|
---|
1084 | else if (dcd->lastattr & CV_DETAIL)
|
---|
1085 | flWindowAttr |= CV_DETAIL;
|
---|
1086 | else if (dcd->lastattr & CV_ICON)
|
---|
1087 | flWindowAttr |= CV_ICON;
|
---|
1088 | else
|
---|
1089 | flWindowAttr |= CV_NAME;
|
---|
1090 | }
|
---|
1091 | else
|
---|
1092 | flWindowAttr |= CV_NAME;
|
---|
1093 | }
|
---|
1094 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.Sort",
|
---|
1095 | (PVOID) & dcd->sortFlags, sizeof(INT));
|
---|
1096 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.Filter",
|
---|
1097 | (PVOID) & dcd->mask, sizeof(MASK));
|
---|
1098 | PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.View",
|
---|
1099 | (PVOID) & flWindowAttr, sizeof(ULONG));
|
---|
1100 | }
|
---|
1101 | }
|
---|
1102 | }
|
---|
1103 | break;
|
---|
1104 | }
|
---|
1105 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
1106 | }
|
---|
1107 |
|
---|
1108 | MRESULT EXPENTRY MainWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1109 | {
|
---|
1110 | PERSON1DATA *pd;
|
---|
1111 |
|
---|
1112 | switch (msg) {
|
---|
1113 | case WM_SAVEAPPLICATION:
|
---|
1114 | case UM_SETUP:
|
---|
1115 | case WM_CREATE:
|
---|
1116 | return MainWMOnce2(hwnd, msg, mp1, mp2);
|
---|
1117 |
|
---|
1118 | case UM_THREADUSE:
|
---|
1119 | case UM_LOADFILE:
|
---|
1120 | case UM_BUILDDRIVEBAR:
|
---|
1121 | case WM_TIMER:
|
---|
1122 | return CommonMainWndProc(hwnd, msg, mp1, mp2);
|
---|
1123 |
|
---|
1124 | case UM_SETUP2:
|
---|
1125 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1126 | if (pd) {
|
---|
1127 | if (mp1) {
|
---|
1128 | if (pd->hwndDir1 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir1))
|
---|
1129 | BoxWindow(pd->hwndDir1, (HPS) 0, CLR_PALEGRAY);
|
---|
1130 | if (pd->hwndDir2 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir2))
|
---|
1131 | BoxWindow(pd->hwndDir2, (HPS) 0, CLR_PALEGRAY);
|
---|
1132 | if (hwndTree)
|
---|
1133 | BoxWindow(hwndTree, (HPS) 0, CLR_PALEGRAY);
|
---|
1134 | }
|
---|
1135 | else {
|
---|
1136 | if (hwndTree)
|
---|
1137 | BoxWindow(hwndTree,
|
---|
1138 | (HPS) 0,
|
---|
1139 | (pd->hwndCurr == hwndTree) ? CLR_RED : CLR_WHITE);
|
---|
1140 | if (!pd->hwndMax || pd->hwndMax == pd->hwndDir1)
|
---|
1141 | BoxWindow(pd->hwndDir1,
|
---|
1142 | (HPS) 0,
|
---|
1143 | (pd->hwndDir1 == pd->hwndCurr) ?
|
---|
1144 | CLR_RED :
|
---|
1145 | (pd->hwndDir1 == pd->hwndLastDir) ?
|
---|
1146 | CLR_DARKRED : CLR_PALEGRAY);
|
---|
1147 | if (!pd->hwndMax || pd->hwndMax == pd->hwndDir2)
|
---|
1148 | BoxWindow(pd->hwndDir2,
|
---|
1149 | (HPS) 0,
|
---|
1150 | (pd->hwndDir2 == pd->hwndCurr) ?
|
---|
1151 | CLR_RED :
|
---|
1152 | (pd->hwndDir2 == pd->hwndLastDir) ?
|
---|
1153 | CLR_DARKRED : CLR_PALEGRAY);
|
---|
1154 | }
|
---|
1155 | }
|
---|
1156 | return 0;
|
---|
1157 |
|
---|
1158 | case WM_BUTTON1DOWN:
|
---|
1159 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
|
---|
1160 | if (hwndTree) {
|
---|
1161 |
|
---|
1162 | SWP swp;
|
---|
1163 |
|
---|
1164 | WinQueryWindowPos(hwndTree, &swp);
|
---|
1165 | if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
|
---|
1166 | SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) {
|
---|
1167 |
|
---|
1168 | SWP swpC;
|
---|
1169 | TRACKINFO track;
|
---|
1170 |
|
---|
1171 | WinQueryWindowPos(hwnd, &swpC);
|
---|
1172 | track.cxBorder = 4;
|
---|
1173 | track.cyBorder = 4;
|
---|
1174 | track.cxGrid = 1;
|
---|
1175 | track.cyGrid = 1;
|
---|
1176 | track.cxKeyboard = 8;
|
---|
1177 | track.cyKeyboard = 8;
|
---|
1178 | track.rclTrack.yBottom = 2;
|
---|
1179 | track.rclTrack.yTop = swpC.cy - 4;
|
---|
1180 | track.rclTrack.xLeft = 2;
|
---|
1181 | track.rclTrack.xRight = swp.x + swp.cx + 2;
|
---|
1182 | track.rclBoundary = track.rclTrack;
|
---|
1183 | track.rclBoundary.xRight = swpC.cx - 80;
|
---|
1184 | track.ptlMinTrackSize.x = 80;
|
---|
1185 | track.ptlMinTrackSize.y = swpC.cy - 4;
|
---|
1186 | track.ptlMaxTrackSize.x = swpC.cx - 80;
|
---|
1187 | track.ptlMaxTrackSize.y = swpC.cy - 4;
|
---|
1188 | track.fs = TF_RIGHT;
|
---|
1189 | if (WinTrackRect(hwnd, (HPS) 0, &track)) {
|
---|
1190 | TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft;
|
---|
1191 | PrfWriteProfileData(fmprof,
|
---|
1192 | realappname,
|
---|
1193 | "FM/4 TreeWidth", &TreeWidth, sizeof(ULONG));
|
---|
1194 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
|
---|
1195 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
1196 | }
|
---|
1197 | return (MRESULT) TRUE;
|
---|
1198 | }
|
---|
1199 | }
|
---|
1200 | break;
|
---|
1201 |
|
---|
1202 | case WM_MOUSEMOVE:
|
---|
1203 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
|
---|
1204 | if (hwndTree) {
|
---|
1205 |
|
---|
1206 | SWP swp;
|
---|
1207 |
|
---|
1208 | if (WinQueryWindowPos(hwndTree, &swp)) {
|
---|
1209 | if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
|
---|
1210 | SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
|
---|
1211 | WinSetPointer(HWND_DESKTOP, hptrEW);
|
---|
1212 | else
|
---|
1213 | WinSetPointer(HWND_DESKTOP, hptrArrow);
|
---|
1214 | }
|
---|
1215 | else
|
---|
1216 | WinSetPointer(HWND_DESKTOP, hptrArrow);
|
---|
1217 | }
|
---|
1218 | return (MRESULT) TRUE;
|
---|
1219 |
|
---|
1220 | case WM_BUTTON1UP:
|
---|
1221 | case WM_BUTTON2UP:
|
---|
1222 | case WM_BUTTON3UP:
|
---|
1223 | case WM_CHAR:
|
---|
1224 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
1225 | break;
|
---|
1226 |
|
---|
1227 | case UM_ADVISEFOCUS:
|
---|
1228 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1229 | if (mp1 && pd && (HWND) mp1 != pd->hwndCurr) {
|
---|
1230 | if ((HWND) mp1 != hwndTree)
|
---|
1231 | pd->hwndLastDir = (HWND) mp1;
|
---|
1232 | pd->hwndCurr = (HWND) mp1;
|
---|
1233 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
1234 | }
|
---|
1235 | return 0;
|
---|
1236 |
|
---|
1237 | case UM_MAXIMIZE:
|
---|
1238 | if (mp1) {
|
---|
1239 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1240 | if (pd) {
|
---|
1241 | WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
|
---|
1242 | if (pd->hwndMax != (HWND) mp1) {
|
---|
1243 | pd->hwndMax = (HWND) mp1;
|
---|
1244 | WinSetFocus(HWND_DESKTOP, pd->hwndMax);
|
---|
1245 | }
|
---|
1246 | else
|
---|
1247 | pd->hwndMax = (HWND) 0;
|
---|
1248 | PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
|
---|
1249 | }
|
---|
1250 | }
|
---|
1251 | return 0;
|
---|
1252 |
|
---|
1253 | case WM_INITMENU:
|
---|
1254 | switch (SHORT1FROMMP(mp1)) {
|
---|
1255 | case IDM_FILESMENU:
|
---|
1256 | case IDM_VIEWSMENU:
|
---|
1257 | case IDM_DETAILSSETUP:
|
---|
1258 | case IDM_COMMANDSMENU:
|
---|
1259 | case IDM_SORTSUBMENU:
|
---|
1260 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1261 | if (pd)
|
---|
1262 | WinSendMsg(pd->hwndCurr, UM_INITMENU, mp1, mp2);
|
---|
1263 | break;
|
---|
1264 | case IDM_CONFIGMENU:
|
---|
1265 | // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
|
---|
1266 | WinCheckMenuItem((HWND) mp2, IDM_TOOLSUBMENU, fToolbar);
|
---|
1267 | WinCheckMenuItem((HWND) mp2, IDM_AUTOVIEW, fAutoView);
|
---|
1268 | WinCheckMenuItem((HWND) mp2, IDM_CONFIRMDELETE, fConfirmDelete); // 2014-05-17 SHL
|
---|
1269 | WinCheckMenuItem((HWND) mp2, IDM_TOGGLEDRAGDIALOG, fDragndropDlg); // 2014-05-15 SHL
|
---|
1270 | break;
|
---|
1271 | case IDM_TOOLSUBMENU:
|
---|
1272 | // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
|
---|
1273 | WinCheckMenuItem((HWND) mp2, IDM_TOOLBAR, fToolbar);
|
---|
1274 | WinCheckMenuItem((HWND) mp2, IDM_TEXTTOOLS, fTextTools);
|
---|
1275 | WinCheckMenuItem((HWND) mp2, IDM_TOOLTITLES, fToolTitles);
|
---|
1276 | break;
|
---|
1277 | case IDM_WINDOWSMENU:
|
---|
1278 | // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
|
---|
1279 | WinCheckMenuItem((HWND) mp2, IDM_VTREE, (hwndTree != (HWND) 0));
|
---|
1280 | WinCheckMenuItem((HWND) mp2, IDM_TILEBACKWARDS, fTileBackwards);
|
---|
1281 | SetupWinList((HWND) mp2, hwnd, WinQueryWindow(hwnd, QW_PARENT));
|
---|
1282 | break;
|
---|
1283 | }
|
---|
1284 | break;
|
---|
1285 |
|
---|
1286 | case WM_SETFOCUS:
|
---|
1287 | if (mp2)
|
---|
1288 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
---|
1289 | break;
|
---|
1290 |
|
---|
1291 | case UM_FOCUSME:
|
---|
1292 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1293 | if (pd)
|
---|
1294 | WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
|
---|
1295 | return 0;
|
---|
1296 |
|
---|
1297 | case UM_RESCAN:
|
---|
1298 | return 0;
|
---|
1299 |
|
---|
1300 | case UM_SIZE:
|
---|
1301 | {
|
---|
1302 | SWP swp;
|
---|
1303 |
|
---|
1304 | if (WinQueryWindowPos(hwnd, &swp)) {
|
---|
1305 | mp1 = MPFROM2SHORT(swp.cx, swp.cy);
|
---|
1306 | mp2 = MPFROM2SHORT(swp.cx, swp.cy);
|
---|
1307 | }
|
---|
1308 | else
|
---|
1309 | return 0;
|
---|
1310 | }
|
---|
1311 | // intentional fallthru
|
---|
1312 | case WM_SIZE:
|
---|
1313 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1314 | if (mp1 && mp2 && pd && pd->hwndDir1 && pd->hwndDir2) {
|
---|
1315 | if (hwndTree)
|
---|
1316 | WinSetWindowPos(hwndTree,
|
---|
1317 | HWND_TOP,
|
---|
1318 | 2,
|
---|
1319 | 2,
|
---|
1320 | TreeWidth - 4,
|
---|
1321 | SHORT2FROMMP(mp2) - 4,
|
---|
1322 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1323 | else
|
---|
1324 | TreeWidth = 0;
|
---|
1325 | if (!pd->hwndMax) {
|
---|
1326 | if (fTileBackwards) {
|
---|
1327 | WinSetWindowPos(pd->hwndDir1, HWND_TOP,
|
---|
1328 | (((SHORT1FROMMP(mp2) - TreeWidth) / 2) +
|
---|
1329 | TreeWidth) + 2,
|
---|
1330 | 2,
|
---|
1331 | ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
|
---|
1332 | SHORT2FROMMP(mp2) - 4,
|
---|
1333 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1334 | WinSetWindowPos(pd->hwndDir2, HWND_TOP,
|
---|
1335 | TreeWidth + 2,
|
---|
1336 | 2,
|
---|
1337 | ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
|
---|
1338 | SHORT2FROMMP(mp2) - 4,
|
---|
1339 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1340 | }
|
---|
1341 | else {
|
---|
1342 | WinSetWindowPos(pd->hwndDir1, HWND_TOP,
|
---|
1343 | TreeWidth + 2,
|
---|
1344 | 2,
|
---|
1345 | (SHORT1FROMMP(mp2) - TreeWidth) - 4,
|
---|
1346 | (SHORT2FROMMP(mp2) / 2) - 4,
|
---|
1347 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1348 | WinSetWindowPos(pd->hwndDir2, HWND_TOP,
|
---|
1349 | TreeWidth + 2,
|
---|
1350 | (SHORT2FROMMP(mp2) / 2) + 2,
|
---|
1351 | (SHORT1FROMMP(mp2) - TreeWidth) - 4,
|
---|
1352 | (SHORT2FROMMP(mp2) / 2) - 4,
|
---|
1353 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1354 | }
|
---|
1355 | }
|
---|
1356 | else {
|
---|
1357 |
|
---|
1358 | HWND hwndOther;
|
---|
1359 |
|
---|
1360 | WinSetWindowPos(pd->hwndMax, HWND_TOP,
|
---|
1361 | TreeWidth + 2,
|
---|
1362 | 2,
|
---|
1363 | (SHORT1FROMMP(mp2) - TreeWidth) - 4,
|
---|
1364 | SHORT2FROMMP(mp2) - 4,
|
---|
1365 | SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
1366 | hwndOther = (pd->hwndMax == pd->hwndDir1) ?
|
---|
1367 | pd->hwndDir2 : pd->hwndDir1;
|
---|
1368 | WinSetWindowPos(hwndOther, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE);
|
---|
1369 | }
|
---|
1370 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
1371 | }
|
---|
1372 | if (msg == UM_SIZE)
|
---|
1373 | return 0;
|
---|
1374 | break;
|
---|
1375 |
|
---|
1376 | case WM_ERASEBACKGROUND:
|
---|
1377 | WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
|
---|
1378 | return 0;
|
---|
1379 |
|
---|
1380 | case WM_PAINT:
|
---|
1381 | {
|
---|
1382 | HPS hps;
|
---|
1383 | RECTL rcl;
|
---|
1384 |
|
---|
1385 | hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
|
---|
1386 | if (hps) {
|
---|
1387 | WinQueryWindowRect(hwnd, &rcl);
|
---|
1388 | WinFillRect(hps, (PRECTL) & rcl, CLR_PALEGRAY);
|
---|
1389 | WinEndPaint(hps);
|
---|
1390 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
1391 | }
|
---|
1392 | }
|
---|
1393 | break;
|
---|
1394 |
|
---|
1395 | case UM_COMMAND:
|
---|
1396 | case WM_COMMAND:
|
---|
1397 | return MainWMCommand2(hwnd, msg, mp1, mp2);
|
---|
1398 |
|
---|
1399 | case WM_CLOSE:
|
---|
1400 | fAmClosing = TRUE;
|
---|
1401 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
|
---|
1402 | CloseChildren(hwnd);
|
---|
1403 | PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
|
---|
1404 | DosSleep(1);
|
---|
1405 | return 0; // Suppress WinDefWindowProc WM_QUIT message generation
|
---|
1406 |
|
---|
1407 | case UM_CLOSE:
|
---|
1408 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
|
---|
1409 | return 0;
|
---|
1410 |
|
---|
1411 | case WM_DESTROY:
|
---|
1412 | hwndMain = (HWND) 0;
|
---|
1413 | pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
|
---|
1414 | xfree(pd, pszSrcFile, __LINE__);
|
---|
1415 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
1416 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
1417 | break;
|
---|
1418 | }
|
---|
1419 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | HWND StartFM32(HAB hab, INT argc, CHAR ** argv)
|
---|
1423 | {
|
---|
1424 | HWND hwndFrame, hwndClient;
|
---|
1425 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
|
---|
1426 | FCF_SIZEBORDER | FCF_MINMAX |
|
---|
1427 | FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
|
---|
1428 |
|
---|
1429 | {
|
---|
1430 | INT x;
|
---|
1431 |
|
---|
1432 | for (x = 1; x < argc; x++) {
|
---|
1433 | if (*argv[x] == '+' && !argv[x][1])
|
---|
1434 | fLogFile = TRUE;
|
---|
1435 | if (*argv[x] == '-') {
|
---|
1436 | if (argv[x][1])
|
---|
1437 | strcpy(profile, &argv[x][1]);
|
---|
1438 | }
|
---|
1439 | }
|
---|
1440 | }
|
---|
1441 | {
|
---|
1442 | CHAR inipath[CCHMAXPATH], fullpath[CCHMAXPATH];
|
---|
1443 | FILESTATUS3 fsa;
|
---|
1444 |
|
---|
1445 | if (PrfQueryProfileString(HINI_USERPROFILE,
|
---|
1446 | (CHAR *) FM2Str,
|
---|
1447 | "Home", NULL, inipath, sizeof(inipath))) {
|
---|
1448 | if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, sizeof(fsa))) {
|
---|
1449 | if (fsa.attrFile & FILE_DIRECTORY) {
|
---|
1450 | if (DosQueryPathInfo(inipath,
|
---|
1451 | FIL_QUERYFULLNAME, fullpath, sizeof(fullpath)))
|
---|
1452 | strcpy(fullpath, inipath);
|
---|
1453 | switch_to(fullpath);
|
---|
1454 | }
|
---|
1455 | }
|
---|
1456 | }
|
---|
1457 | }
|
---|
1458 |
|
---|
1459 | hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
|
---|
1460 | WS_VISIBLE,
|
---|
1461 | &FrameFlags,
|
---|
1462 | (CHAR *) WC_MAINWND2,
|
---|
1463 | NULL,
|
---|
1464 | WS_VISIBLE | WS_ANIMATE,
|
---|
1465 | FM3ModHandle, MAIN2_FRAME, &hwndClient);
|
---|
1466 | if (hwndFrame) {
|
---|
1467 | hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
|
---|
1468 | if (!WinRestoreWindowPos((CHAR *) FM2Str, "MainWindowPos2", hwndFrame)) {
|
---|
1469 |
|
---|
1470 | ULONG fl = SWP_MOVE | SWP_SIZE;
|
---|
1471 | RECTL rcl;
|
---|
1472 | ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
|
---|
1473 | ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
|
---|
1474 |
|
---|
1475 | WinQueryWindowRect(HWND_DESKTOP, &rcl);
|
---|
1476 | rcl.yBottom += icz;
|
---|
1477 | rcl.yTop -= bsz;
|
---|
1478 | rcl.xLeft += bsz;
|
---|
1479 | rcl.xRight -= bsz;
|
---|
1480 | WinSetWindowPos(hwndFrame,
|
---|
1481 | HWND_TOP,
|
---|
1482 | rcl.xLeft,
|
---|
1483 | rcl.yBottom,
|
---|
1484 | rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
|
---|
1485 | }
|
---|
1486 | if (fLogFile) {
|
---|
1487 | CHAR *modea = "a+";
|
---|
1488 |
|
---|
1489 | LogFileHandle = xfsopen("FM2.LOG", modea, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
|
---|
1490 | }
|
---|
1491 | if (hwndHelp)
|
---|
1492 | WinAssociateHelpInstance(hwndHelp, hwndFrame);
|
---|
1493 | PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
|
---|
1494 | }
|
---|
1495 | return hwndFrame;
|
---|
1496 | }
|
---|
1497 |
|
---|
1498 | #pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2)
|
---|
1499 | #pragma alloc_text(PERSON12,StartFM32,MainWMOnce2)
|
---|
1500 | #pragma alloc_text(PERSON13,MainWMCommand2)
|
---|