source: trunk/dll/mainwnd2.c@ 858

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

Revert to standard APIs where large file support not required by ticket #41

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