source: trunk/dll/mainwnd2.c@ 773

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

Correct some compare directories collector nits
Use BldQuoted... functions
Move BldQuoted... functions near primary callers
Add RUNTYPE_MASK
Use Runtime_Error2 more

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