source: trunk/dll/mainwnd2.c@ 917

Last change on this file since 917 was 917, checked in by Steven Levine, 18 years ago

Correct/enhance settings notebook navigation, ticket #188 (Steven)
Reopen settings notebook to last selected page unless overridden, ticket #188 (Steven)
More Compare Directory overflow tweaks (Steven)

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