source: trunk/dll/mainwnd2.c@ 940

Last change on this file since 940 was 940, checked in by Gregg Young, 18 years ago

Minor cleanup, added comments and History for recent changes

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