source: trunk/dll/mainwnd2.c@ 827

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

Move #pragma alloc_text to end for OpenWatcom compat

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