source: trunk/dll/mainwnd2.c@ 775

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

Minor clean up add comments re recent changes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.4 KB
Line 
1
2/***********************************************************************
3
4 $Id: mainwnd2.c 775 2007-08-11 21:07:07Z gyoung $
5
6 fm/4 main window
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2005, 2007 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
22***********************************************************************/
23
24#define INCL_DOS
25#define INCL_WIN
26#define INCL_GPI
27#include <os2.h>
28
29#include <stdlib.h>
30#include <stdio.h>
31#include <string.h>
32#include <ctype.h>
33#include <share.h>
34#include <process.h> // _beginthread
35
36#include "fm3dll.h"
37#include "fm3dlg.h"
38#include "fm3str.h"
39#include "tools.h"
40#include "datamin.h"
41
42typedef struct
43{
44 USHORT size;
45 USHORT dummy;
46 HWND hwndDir1;
47 HWND hwndDir2;
48 HWND hwndCurr;
49 HWND hwndLastDir;
50 HWND hwndMax;
51}
52PERSON1DATA;
53
54static PSZ pszSrcFile = __FILE__;
55
56#pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2)
57#pragma alloc_text(PERSON12,StartFM32,MainWMOnce2)
58#pragma alloc_text(PERSON13,MainWMCommand2)
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, NULL, NULL,
506 "%s %s %s",
507 dircompare,
508 BldQuotedFileName(szPath1, wa.szCurrentPath1),
509 BldQuotedFileName(szPath2, wa.szCurrentPath2));
510 // CHAR *d1 = "\"", *d2 = "\"";
511 // if (!needs_quoting(wa.szCurrentPath1))
512 // *d1 = 0;
513 // if (!needs_quoting(wa.szCurrentPath2))
514 // *d2 = 0;
515 // runemf2(SEPARATE,
516 // HWND_DESKTOP,
517 // NULL,
518 // NULL,
519 // "%s %s%s%s %s%s%s",
520 // dircompare,
521 // d1, wa.szCurrentPath1, d1, d2, wa.szCurrentPath2, d2);
522 }
523 }
524 }
525 break;
526
527 case IDM_VTREE:
528 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
529 if (hwndTree) {
530 WinShowWindow(hwndTree, FALSE);
531 PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
532 hwndTree = (HWND) 0;
533 }
534 else {
535
536 ULONG size = sizeof(ULONG);
537
538 hwndTree = StartTreeCnr(hwnd, 3);
539 PrfQueryProfileData(fmprof,
540 realappname,
541 "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
542 TreeWidth = max(TreeWidth, 80);
543 }
544 {
545 BOOL dummy = (hwndTree != (HWND) 0);
546
547 PrfWriteProfileData(fmprof,
548 realappname,
549 "FM/4 TreeUp", (PVOID) & dummy, sizeof(dummy));
550 }
551 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
552 break;
553
554 case IDM_TILEBACKWARDS:
555 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
556 fTileBackwards = (fTileBackwards) ? FALSE : TRUE;
557 PrfWriteProfileData(fmprof,
558 FM3Str,
559 "TileBackwards",
560 (PVOID) & fTileBackwards, sizeof(BOOL));
561 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
562 break;
563
564 case IDM_NEXTWINDOW:
565 case IDM_PREVWINDOW:
566 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
567 if (pd) {
568
569 HWND hwndFocus;
570
571 if (hwndTree) {
572 if (pd->hwndMax) {
573 if (hwndTree == pd->hwndCurr)
574 hwndFocus = pd->hwndMax;
575 else
576 hwndFocus = hwndTree;
577 }
578 else {
579 if (hwndTree == pd->hwndCurr)
580 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
581 pd->hwndDir1 : pd->hwndDir2;
582 else if (pd->hwndDir1 == pd->hwndCurr)
583 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
584 pd->hwndDir2 : hwndTree;
585 else
586 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
587 hwndTree : pd->hwndDir1;
588 }
589 }
590 else {
591 if (pd->hwndMax)
592 hwndFocus = pd->hwndMax;
593 else
594 hwndFocus = (pd->hwndCurr == pd->hwndDir1) ?
595 pd->hwndDir2 : pd->hwndDir1;
596 }
597 WinSetFocus(HWND_DESKTOP, hwndFocus);
598 }
599 break;
600
601 case IDM_NOTEBOOK:
602 WinDlgBox(HWND_DESKTOP,
603 hwnd,
604 CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMP(realappname));
605 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
606 break;
607
608 case IDM_SEEALL:
609 case IDM_GREP:
610 case IDM_COLLECTOR:
611 {
612 HWND hwndC;
613
614 hwndC = StartCollector(HWND_DESKTOP, 4);
615 if (hwndC) {
616 WinSetWindowPos(hwndC,
617 HWND_TOP,
618 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE);
619 if (SHORT1FROMMP(mp1) == IDM_GREP)
620 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
621 WM_COMMAND, MPFROM2SHORT(IDM_GREP, 0), MPVOID);
622 if (SHORT1FROMMP(mp1) == IDM_SEEALL)
623 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
624 WM_COMMAND, MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
625 }
626 }
627 break;
628
629 case IDM_EDITCOMMANDS:
630 EditCommands(hwnd);
631 break;
632
633 default:
634 if (SHORT1FROMMP(mp1) >= IDM_SWITCHSTART &&
635 SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499) {
636 if (SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches)
637 WinSwitchToProgram(switches[SHORT1FROMMP(mp1) - IDM_SWITCHSTART]);
638 break;
639 }
640 else if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
641 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
642
643 INT x;
644 HWND hwndCnr;
645
646 if (!cmdloaded)
647 load_commands();
648 hwndCnr = TopWindow(hwnd, (HWND) 0);
649 hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
650 UM_CONTAINERHWND, MPVOID, MPVOID);
651 if (!hwndCnr) {
652 Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
653 break;
654 }
655 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
656 if (x >= 0) {
657 x++;
658 RunCommand(hwndCnr, x);
659 if (fUnHilite) {
660
661 PCNRITEM pci;
662 DIRCNRDATA *dcd = NULL;
663
664 if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
665 dcd = INSTDATA(hwndCnr);
666 pci = (PCNRITEM) WinSendMsg(hwndCnr,
667 CM_QUERYRECORDEMPHASIS,
668 MPFROMLONG(CMA_FIRST),
669 MPFROMSHORT(CRA_CURSORED));
670 if (pci && (INT) pci != -1 && (pci->rc.flRecordAttr & CRA_SELECTED)) {
671 UnHilite(hwnd,
672 TRUE,
673 dcd ? &dcd->lastselection : NULL,
674 dcd ? dcd->ulItemsToUnHilite : 0);
675 }
676 }
677 }
678 }
679 else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
680 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
681 if (!qtloaded)
682 load_quicktools();
683 if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
684 if (fToolsChanged)
685 save_tools(NULL);
686 if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
687 load_tools(NULL);
688 else {
689 strcpy(lasttoolbox,
690 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
691 PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
692 }
693 BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
694 MAIN_TOOLS), TRUE);
695 }
696 }
697 else {
698
699 HWND hwndActive;
700
701 hwndActive = TopWindow(hwnd, (HWND) 0);
702 if (hwndActive)
703 PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), msg, mp1, mp2);
704 }
705 break;
706 }
707 return 0;
708}
709
710static MRESULT EXPENTRY MainWMOnce2(HWND hwnd, ULONG msg, MPARAM mp1,
711 MPARAM mp2)
712{
713 PERSON1DATA *pd;
714
715 switch (msg) {
716 case WM_CREATE:
717 {
718 TID tid;
719
720 WinQueryWindowProcess(hwnd, &mypid, &tid);
721 }
722 hwndMain = hwnd;
723 WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
724 WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
725 WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
726 WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
727 if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
728 Runtime_Error(pszSrcFile, __LINE__,
729 GetPString(IDS_COULDNTSTARTTHREADTEXT));
730 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
731 return 0;
732 }
733 else
734 DosSleep(32);//05 Aug 07 GKY 64
735
736 pd = xmallocz(sizeof(PERSON1DATA), pszSrcFile, __LINE__);
737 if (!pd)
738 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
739 else {
740 pd->size = sizeof(PERSON1DATA);
741 WinSetWindowPtr(hwnd, QWL_USER + 4, (PVOID) pd);
742 }
743 {
744 SWP swp;
745 PFNWP oldproc;
746
747 /*
748 * create frame children (not client children, frame children)
749 */
750 DosSleep(1);
751 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
752 oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT),
753 (PFNWP) MainFrameWndProc2);
754 if (oldproc)
755 WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER, (PVOID) oldproc);
756 CommonCreateMainChildren(hwnd, &swp);
757
758 {
759 HWND hwndMenu;
760
761 hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_MENU);
762 WinSetWindowULong(hwnd, 0, hwndMenu);
763 SetConditionalCascade(hwndMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
764 SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
765 }
766 }
767 WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
768 FID_TITLEBAR), "FM/2 Lite");
769 FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), NULL);
770 SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_SYSMENU));
771 break;
772
773 case UM_SETUP:
774 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
775 if (pd) {
776
777 CHAR s[CCHMAXPATH];
778 ULONG size;
779 DIRCNRDATA *dcd;
780 HWND hwndC;
781 BOOL dummy = TRUE;
782
783 size = sizeof(BOOL);
784 PrfQueryProfileData(fmprof,
785 realappname, "FM/4 TreeUp", (PVOID) & dummy, &size);
786 if (dummy) {
787 size = sizeof(ULONG);
788 hwndTree = StartTreeCnr(hwnd, 3);
789 PrfQueryProfileData(fmprof,
790 realappname,
791 "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
792 TreeWidth = max(TreeWidth, 80);
793 }
794 size = sizeof(BOOL);
795 if (PrfQueryProfileData(fmprof,
796 FM3Str,
797 "Toolbar", &dummy, &size) && size && !dummy)
798 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
799
800 size = sizeof(s);
801 *s = 0;
802 if (PrfQueryProfileData(fmprof,
803 realappname, "FM/4 Dir1", s, &size) && *s)
804 MakeValidDir(s);
805 else
806 save_dir(s);
807 pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 =
808 StartDirCnr(hwnd, s, (HWND) 0, 3);
809 size = sizeof(s);
810 *s = 0;
811 if (PrfQueryProfileData(fmprof,
812 realappname, "FM/4 Dir2", s, &size) && *s)
813 MakeValidDir(s);
814 else
815 save_dir(s);
816 pd->hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3);
817 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
818
819 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
820 if (hwndC) {
821 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
822 if (dcd) {
823 size = sizeof(INT);
824 if (PrfQueryProfileData(fmprof,
825 realappname,
826 "FM/4 Dir1.Sort",
827 (PVOID) & dcd->sortFlags,
828 &size) && size == sizeof(INT)) {
829 if (!dcd->sortFlags)
830 dcd->sortFlags = SORT_PATHNAME;
831 }
832 size = sizeof(MASK);
833 if (PrfQueryProfileData(fmprof,
834 realappname,
835 "FM/4 Dir1.Filter",
836 (PVOID) & dcd->mask, &size) && size) {
837 if (*dcd->mask.szMask)
838 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
839 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
840 }
841 *(dcd->mask.prompt) = 0;
842 size = sizeof(ULONG);
843 if (PrfQueryProfileData(fmprof,
844 realappname,
845 "FM/4 Dir1.View",
846 (PVOID) & dcd->flWindowAttr,
847 &size) && size == sizeof(ULONG)) {
848
849 CNRINFO cnri;
850
851 memset(&cnri, 0, sizeof(CNRINFO));
852 cnri.cb = sizeof(CNRINFO);
853 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
854 CM_QUERYCNRINFO,
855 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
856 cnri.flWindowAttr = dcd->flWindowAttr;
857 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
858 CM_SETCNRINFO,
859 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
860 }
861 }
862 }
863 }
864
865 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
866 if (hwndC) {
867 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
868 if (dcd) {
869 size = sizeof(INT);
870 if (PrfQueryProfileData(fmprof,
871 realappname,
872 "FM/4 Dir2.Sort",
873 (PVOID) & dcd->sortFlags,
874 &size) && size == sizeof(INT)) {
875 if (!dcd->sortFlags)
876 dcd->sortFlags = SORT_PATHNAME;
877 }
878 size = sizeof(MASK);
879 if (PrfQueryProfileData(fmprof,
880 realappname,
881 "FM/4 Dir2.Filter",
882 (PVOID) & dcd->mask, &size) && size) {
883 if (*dcd->mask.szMask)
884 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
885 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
886 }
887 *(dcd->mask.prompt) = 0;
888 size = sizeof(ULONG);
889 if (PrfQueryProfileData(fmprof,
890 realappname,
891 "FM/4 Dir2.View",
892 (PVOID) & dcd->flWindowAttr,
893 &size) && size == sizeof(ULONG)) {
894
895 CNRINFO cnri;
896
897 memset(&cnri, 0, sizeof(CNRINFO));
898 cnri.cb = sizeof(CNRINFO);
899 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
900 CM_QUERYCNRINFO,
901 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
902 cnri.flWindowAttr = dcd->flWindowAttr;
903 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
904 CM_SETCNRINFO,
905 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
906 }
907 }
908 }
909 }
910 }
911 {
912 ULONG which = 0, size = sizeof(ULONG);
913
914 if (PrfQueryProfileData(fmprof,
915 realappname,
916 "FM/4 Max",
917 (PVOID) & which,
918 &size) && size == sizeof(ULONG) && which) {
919 PostMsg(hwnd,
920 UM_MAXIMIZE,
921 MPFROMLONG(((which == 1) ?
922 pd->hwndDir1 : pd->hwndDir2)), MPVOID);
923 }
924 }
925 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
926 if (!hwndTree)
927 PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
928 load_tools(NULL);
929 BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
930 MAIN_TOOLS), TRUE);
931 fRunning = TRUE;
932 return 0;
933
934 case WM_SAVEAPPLICATION:
935 WinStoreWindowPos(FM2Str,
936 "MainWindowPos2", WinQueryWindow(hwnd, QW_PARENT));
937 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
938 if (pd) {
939
940 CHAR s[CCHMAXPATH];
941 HWND hwndC;
942 DIRCNRDATA *dcd;
943 ULONG flWindowAttr;
944
945 *s = 0;
946 WinSendMsg(pd->hwndDir1, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
947 if (*s) {
948 MakeValidDir(s);
949 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir1", s);
950 }
951 *s = 0;
952 WinSendMsg(pd->hwndDir2, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
953 if (*s) {
954 MakeValidDir(s);
955 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir2", s);
956 }
957 flWindowAttr = (pd->hwndMax == pd->hwndDir1) ?
958 1 : (pd->hwndMax == pd->hwndDir2) ? 2 : 0;
959 PrfWriteProfileData(fmprof,
960 realappname,
961 "FM/4 Max", &flWindowAttr, sizeof(flWindowAttr));
962 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
963 if (hwndC) {
964 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
965 if (dcd) {
966 flWindowAttr = dcd->flWindowAttr;
967 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
968 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
969 if (dcd->lastattr) {
970 if (dcd->lastattr & CV_TEXT)
971 flWindowAttr |= CV_TEXT;
972 else if (dcd->lastattr & CV_DETAIL)
973 flWindowAttr |= CV_DETAIL;
974 else if (dcd->lastattr & CV_ICON)
975 flWindowAttr |= CV_ICON;
976 else
977 flWindowAttr |= CV_NAME;
978 }
979 else
980 flWindowAttr |= CV_NAME;
981 }
982 PrfWriteProfileData(fmprof,
983 realappname,
984 "FM/4 Dir1.Sort",
985 (PVOID) & dcd->sortFlags, sizeof(INT));
986 PrfWriteProfileData(fmprof,
987 realappname,
988 "FM/4 Dir1.Filter",
989 (PVOID) & dcd->mask, sizeof(MASK));
990 PrfWriteProfileData(fmprof,
991 realappname,
992 "FM/4 Dir1.View",
993 (PVOID) & flWindowAttr, sizeof(ULONG));
994 }
995 }
996
997 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
998 if (hwndC) {
999 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
1000 if (dcd) {
1001 flWindowAttr = dcd->flWindowAttr;
1002 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
1003 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1004 if (dcd->lastattr) {
1005 if (dcd->lastattr & CV_TEXT)
1006 flWindowAttr |= CV_TEXT;
1007 else if (dcd->lastattr & CV_DETAIL)
1008 flWindowAttr |= CV_DETAIL;
1009 else if (dcd->lastattr & CV_ICON)
1010 flWindowAttr |= CV_ICON;
1011 else
1012 flWindowAttr |= CV_NAME;
1013 }
1014 else
1015 flWindowAttr |= CV_NAME;
1016 }
1017 PrfWriteProfileData(fmprof,
1018 realappname,
1019 "FM/4 Dir2.Sort",
1020 (PVOID) & dcd->sortFlags, sizeof(INT));
1021 PrfWriteProfileData(fmprof,
1022 realappname,
1023 "FM/4 Dir2.Filter",
1024 (PVOID) & dcd->mask, sizeof(MASK));
1025 PrfWriteProfileData(fmprof,
1026 realappname,
1027 "FM/4 Dir2.View",
1028 (PVOID) & flWindowAttr, sizeof(ULONG));
1029 }
1030 }
1031 }
1032 break;
1033 }
1034 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1035}
1036
1037MRESULT EXPENTRY MainWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1038{
1039 PERSON1DATA *pd;
1040
1041 switch (msg) {
1042 case WM_SAVEAPPLICATION:
1043 case UM_SETUP:
1044 case WM_CREATE:
1045 return MainWMOnce2(hwnd, msg, mp1, mp2);
1046
1047 case UM_THREADUSE:
1048 case UM_LOADFILE:
1049 case UM_BUILDDRIVEBAR:
1050 return CommonMainWndProc(hwnd, msg, mp1, mp2);
1051
1052 case UM_SETUP2:
1053 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1054 if (pd) {
1055 if (mp1) {
1056 if (pd->hwndDir1 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir1))
1057 BoxWindow(pd->hwndDir1, (HPS) 0, CLR_PALEGRAY);
1058 if (pd->hwndDir2 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir2))
1059 BoxWindow(pd->hwndDir2, (HPS) 0, CLR_PALEGRAY);
1060 if (hwndTree)
1061 BoxWindow(hwndTree, (HPS) 0, CLR_PALEGRAY);
1062 }
1063 else {
1064 if (hwndTree)
1065 BoxWindow(hwndTree,
1066 (HPS) 0,
1067 (pd->hwndCurr == hwndTree) ? CLR_RED : CLR_WHITE);
1068 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir1)
1069 BoxWindow(pd->hwndDir1,
1070 (HPS) 0,
1071 (pd->hwndDir1 == pd->hwndCurr) ?
1072 CLR_RED :
1073 (pd->hwndDir1 == pd->hwndLastDir) ?
1074 CLR_DARKRED : CLR_PALEGRAY);
1075 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir2)
1076 BoxWindow(pd->hwndDir2,
1077 (HPS) 0,
1078 (pd->hwndDir2 == pd->hwndCurr) ?
1079 CLR_RED :
1080 (pd->hwndDir2 == pd->hwndLastDir) ?
1081 CLR_DARKRED : CLR_PALEGRAY);
1082 }
1083 }
1084 return 0;
1085
1086 case WM_BUTTON1DOWN:
1087 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1088 if (hwndTree) {
1089
1090 SWP swp;
1091
1092 WinQueryWindowPos(hwndTree, &swp);
1093 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
1094 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) {
1095
1096 SWP swpC;
1097 TRACKINFO track;
1098
1099 WinQueryWindowPos(hwnd, &swpC);
1100 track.cxBorder = 4;
1101 track.cyBorder = 4;
1102 track.cxGrid = 1;
1103 track.cyGrid = 1;
1104 track.cxKeyboard = 8;
1105 track.cyKeyboard = 8;
1106 track.rclTrack.yBottom = 2;
1107 track.rclTrack.yTop = swpC.cy - 4;
1108 track.rclTrack.xLeft = 2;
1109 track.rclTrack.xRight = swp.x + swp.cx + 2;
1110 track.rclBoundary = track.rclTrack;
1111 track.rclBoundary.xRight = swpC.cx - 80;
1112 track.ptlMinTrackSize.x = 80;
1113 track.ptlMinTrackSize.y = swpC.cy - 4;
1114 track.ptlMaxTrackSize.x = swpC.cx - 80;
1115 track.ptlMaxTrackSize.y = swpC.cy - 4;
1116 track.fs = TF_RIGHT;
1117 if (WinTrackRect(hwnd, (HPS) 0, &track)) {
1118 TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft;
1119 PrfWriteProfileData(fmprof,
1120 realappname,
1121 "FM/4 TreeWidth", &TreeWidth, sizeof(ULONG));
1122 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1123 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
1124 }
1125 return (MRESULT) TRUE;
1126 }
1127 }
1128 break;
1129
1130 case WM_MOUSEMOVE:
1131 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1132 if (hwndTree) {
1133
1134 SWP swp;
1135
1136 if (WinQueryWindowPos(hwndTree, &swp)) {
1137 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
1138 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
1139 WinSetPointer(HWND_DESKTOP, hptrEW);
1140 else
1141 WinSetPointer(HWND_DESKTOP, hptrArrow);
1142 }
1143 else
1144 WinSetPointer(HWND_DESKTOP, hptrArrow);
1145 }
1146 return (MRESULT) TRUE;
1147
1148 case WM_BUTTON1UP:
1149 case WM_BUTTON2UP:
1150 case WM_BUTTON3UP:
1151 case WM_CHAR:
1152 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1153 break;
1154
1155 case UM_ADVISEFOCUS:
1156 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1157 if (mp1 && pd && (HWND) mp1 != pd->hwndCurr) {
1158 if ((HWND) mp1 != hwndTree)
1159 pd->hwndLastDir = (HWND) mp1;
1160 pd->hwndCurr = (HWND) mp1;
1161 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1162 }
1163 return 0;
1164
1165 case UM_MAXIMIZE:
1166 if (mp1) {
1167 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1168 if (pd) {
1169 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1170 if (pd->hwndMax != (HWND) mp1) {
1171 pd->hwndMax = (HWND) mp1;
1172 WinSetFocus(HWND_DESKTOP, pd->hwndMax);
1173 }
1174 else
1175 pd->hwndMax = (HWND) 0;
1176 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
1177 }
1178 }
1179 return 0;
1180
1181 case WM_INITMENU:
1182 switch (SHORT1FROMMP(mp1)) {
1183 case IDM_FILESMENU:
1184 case IDM_VIEWSMENU:
1185 case IDM_DETAILSSETUP:
1186 case IDM_COMMANDSMENU:
1187 case IDM_SORTSUBMENU:
1188 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1189 if (pd)
1190 WinSendMsg(pd->hwndCurr, UM_INITMENU, mp1, mp2);
1191 break;
1192 case IDM_CONFIGMENU:
1193 WinCheckMenuItem((HWND) mp2, IDM_TOOLSUBMENU, fToolbar);
1194 WinCheckMenuItem((HWND) mp2, IDM_AUTOVIEW, fAutoView);
1195 break;
1196 case IDM_TOOLSUBMENU:
1197 WinCheckMenuItem((HWND) mp2, IDM_TOOLBAR, fToolbar);
1198 WinCheckMenuItem((HWND) mp2, IDM_TEXTTOOLS, fTextTools);
1199 WinCheckMenuItem((HWND) mp2, IDM_TOOLTITLES, fToolTitles);
1200 break;
1201 case IDM_WINDOWSMENU:
1202 WinCheckMenuItem((HWND) mp2, IDM_VTREE, (hwndTree != (HWND) 0));
1203 WinCheckMenuItem((HWND) mp2, IDM_TILEBACKWARDS, fTileBackwards);
1204 SetupWinList((HWND) mp2, hwnd, WinQueryWindow(hwnd, QW_PARENT));
1205 break;
1206 }
1207 break;
1208
1209 case WM_SETFOCUS:
1210 if (mp2)
1211 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
1212 break;
1213
1214 case UM_FOCUSME:
1215 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1216 if (pd)
1217 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
1218 return 0;
1219
1220 case UM_RESCAN:
1221 return 0;
1222
1223 case UM_SIZE:
1224 {
1225 SWP swp;
1226
1227 if (WinQueryWindowPos(hwnd, &swp)) {
1228 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
1229 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
1230 }
1231 else
1232 return 0;
1233 }
1234 /* intentional fallthru */
1235 case WM_SIZE:
1236 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1237 if (mp1 && mp2 && pd && pd->hwndDir1 && pd->hwndDir2) {
1238 if (hwndTree)
1239 WinSetWindowPos(hwndTree,
1240 HWND_TOP,
1241 2,
1242 2,
1243 TreeWidth - 4,
1244 SHORT2FROMMP(mp2) - 4,
1245 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1246 else
1247 TreeWidth = 0;
1248 if (!pd->hwndMax) {
1249 if (fTileBackwards) {
1250 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
1251 (((SHORT1FROMMP(mp2) - TreeWidth) / 2) +
1252 TreeWidth) + 2,
1253 2,
1254 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1255 SHORT2FROMMP(mp2) - 4,
1256 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1257 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
1258 TreeWidth + 2,
1259 2,
1260 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1261 SHORT2FROMMP(mp2) - 4,
1262 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1263 }
1264 else {
1265 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
1266 TreeWidth + 2,
1267 2,
1268 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1269 (SHORT2FROMMP(mp2) / 2) - 4,
1270 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1271 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
1272 TreeWidth + 2,
1273 (SHORT2FROMMP(mp2) / 2) + 2,
1274 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1275 (SHORT2FROMMP(mp2) / 2) - 4,
1276 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1277 }
1278 }
1279 else {
1280
1281 HWND hwndOther;
1282
1283 WinSetWindowPos(pd->hwndMax, HWND_TOP,
1284 TreeWidth + 2,
1285 2,
1286 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1287 SHORT2FROMMP(mp2) - 4,
1288 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1289 hwndOther = (pd->hwndMax == pd->hwndDir1) ?
1290 pd->hwndDir2 : pd->hwndDir1;
1291 WinSetWindowPos(hwndOther, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE);
1292 }
1293 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1294 }
1295 if (msg == UM_SIZE)
1296 return 0;
1297 break;
1298
1299 case WM_ERASEBACKGROUND:
1300 WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
1301 return 0;
1302
1303 case WM_PAINT:
1304 {
1305 HPS hps;
1306 RECTL rcl;
1307
1308 hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
1309 if (hps) {
1310 WinQueryWindowRect(hwnd, &rcl);
1311 WinFillRect(hps, (PRECTL) & rcl, CLR_PALEGRAY);
1312 WinEndPaint(hps);
1313 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1314 }
1315 }
1316 break;
1317
1318 case UM_COMMAND:
1319 case WM_COMMAND:
1320 return MainWMCommand2(hwnd, msg, mp1, mp2);
1321
1322 case WM_CLOSE:
1323 fAmClosing = TRUE;
1324 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
1325 CloseChildren(hwnd);
1326 PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
1327 DosSleep(1);
1328 return 0;
1329
1330 case UM_CLOSE:
1331 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
1332 return 0;
1333
1334 case WM_DESTROY:
1335 hwndMain = (HWND) 0;
1336 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1337 if (pd)
1338 free(pd);
1339 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1340 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1341 break;
1342 }
1343 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1344}
1345
1346HWND StartFM32(HAB hab, INT argc, CHAR ** argv)
1347{
1348 HWND hwndFrame, hwndClient;
1349 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1350 FCF_SIZEBORDER | FCF_MINMAX |
1351 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1352
1353 {
1354 INT x;
1355
1356 for (x = 1; x < argc; x++) {
1357 if (*argv[x] == '+' && !argv[x][1])
1358 fLogFile = TRUE;
1359 if (*argv[x] == '-') {
1360 if (argv[x][1])
1361 strcpy(profile, &argv[x][1]);
1362 }
1363 }
1364 }
1365 {
1366 CHAR inipath[CCHMAXPATH], fullpath[CCHMAXPATH];
1367 FILESTATUS3 fsa;
1368
1369 if (PrfQueryProfileString(HINI_USERPROFILE,
1370 FM2Str,
1371 "Home", NULL, inipath, sizeof(inipath))) {
1372 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) {
1373 if (fsa.attrFile & FILE_DIRECTORY) {
1374 if (DosQueryPathInfo(inipath,
1375 FIL_QUERYFULLNAME, fullpath, sizeof(fullpath)))
1376 strcpy(fullpath, inipath);
1377 switch_to(fullpath);
1378 }
1379 }
1380 }
1381 }
1382
1383 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1384 WS_VISIBLE,
1385 &FrameFlags,
1386 WC_MAINWND2,
1387 NULL,
1388 WS_VISIBLE | WS_ANIMATE,
1389 FM3ModHandle, MAIN2_FRAME, &hwndClient);
1390 if (hwndFrame) {
1391 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos2", hwndFrame)) {
1392
1393 ULONG fl = SWP_MOVE | SWP_SIZE;
1394 RECTL rcl;
1395 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1396 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1397
1398 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1399 rcl.yBottom += icz;
1400 rcl.yTop -= bsz;
1401 rcl.xLeft += bsz;
1402 rcl.xRight -= bsz;
1403 WinSetWindowPos(hwndFrame,
1404 HWND_TOP,
1405 rcl.xLeft,
1406 rcl.yBottom,
1407 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1408 }
1409 if (fLogFile)
1410 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1411 if (hwndHelp)
1412 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1413 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1414 }
1415 return hwndFrame;
1416}
Note: See TracBrowser for help on using the repository browser.