source: trunk/dll/mainwnd2.c@ 672

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

Use dcd->ulItemsToUnHilite
Sync UnHilite calls with arg mods

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