source: trunk/dll/mainwnd2.c@ 771

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

Increase subject to 1024 reduce DosSleep times

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