source: trunk/dll/mainwnd2.c@ 935

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

Added command line submenu on utilities menu in FM/2 Lite

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