source: trunk/dll/mainwnd2.c@ 888

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

runemf2 now quotes executable strings if needed (Ticket 180); it also reports where it was called from on errors

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.3 KB
RevLine 
[133]1
2/***********************************************************************
3
4 $Id: mainwnd2.c 888 2007-12-22 22:02:11Z 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
[775]19 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
[773]20 07 Aug 07 SHL Use BldQuotedFileName
[793]21 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[672]22
[133]23***********************************************************************/
24
[2]25#define INCL_DOS
26#define INCL_WIN
27#define INCL_GPI
[841]28#define INCL_LONGLONG
[352]29#include <os2.h>
[2]30
31#include <stdlib.h>
32#include <stdio.h>
33#include <string.h>
34#include <ctype.h>
35#include <share.h>
[689]36#include <process.h> // _beginthread
[133]37
[2]38#include "fm3dll.h"
39#include "fm3dlg.h"
40#include "fm3str.h"
41#include "tools.h"
[133]42#include "datamin.h"
[2]43
[133]44typedef struct
45{
46 USHORT size;
47 USHORT dummy;
48 HWND hwndDir1;
49 HWND hwndDir2;
50 HWND hwndCurr;
51 HWND hwndLastDir;
52 HWND hwndMax;
[551]53}
54PERSON1DATA;
[2]55
[352]56static PSZ pszSrcFile = __FILE__;
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.
[773]126 * Otherwise, we'll see a lot of redraw when we move the
[133]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 {
[773]500 CHAR szPath1[CCHMAXPATH];
501 CHAR szPath2[CCHMAXPATH];
[133]502 runemf2(SEPARATE,
[888]503 HWND_DESKTOP, pszSrcFile, __LINE__,
504 NULL, NULL,
[773]505 "%s %s %s",
[133]506 dircompare,
[773]507 BldQuotedFileName(szPath1, wa.szCurrentPath1),
508 BldQuotedFileName(szPath2, wa.szCurrentPath2));
[133]509 }
[2]510 }
[133]511 }
512 break;
[2]513
[133]514 case IDM_VTREE:
[551]515 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
516 if (hwndTree) {
[133]517 WinShowWindow(hwndTree, FALSE);
[551]518 PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
519 hwndTree = (HWND) 0;
[133]520 }
[551]521 else {
[2]522
[133]523 ULONG size = sizeof(ULONG);
[2]524
[133]525 hwndTree = StartTreeCnr(hwnd, 3);
526 PrfQueryProfileData(fmprof,
527 realappname,
[551]528 "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
[133]529 TreeWidth = max(TreeWidth, 80);
530 }
531 {
[551]532 BOOL dummy = (hwndTree != (HWND) 0);
[2]533
534 PrfWriteProfileData(fmprof,
[133]535 realappname,
[551]536 "FM/4 TreeUp", (PVOID) & dummy, sizeof(dummy));
[133]537 }
[551]538 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]539 break;
[2]540
[133]541 case IDM_TILEBACKWARDS:
[551]542 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
[133]543 fTileBackwards = (fTileBackwards) ? FALSE : TRUE;
544 PrfWriteProfileData(fmprof,
545 FM3Str,
546 "TileBackwards",
[551]547 (PVOID) & fTileBackwards, sizeof(BOOL));
548 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]549 break;
[2]550
[133]551 case IDM_NEXTWINDOW:
552 case IDM_PREVWINDOW:
[299]553 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]554 if (pd) {
[2]555
[133]556 HWND hwndFocus;
557
[551]558 if (hwndTree) {
559 if (pd->hwndMax) {
560 if (hwndTree == pd->hwndCurr)
561 hwndFocus = pd->hwndMax;
[133]562 else
563 hwndFocus = hwndTree;
564 }
[551]565 else {
566 if (hwndTree == pd->hwndCurr)
[133]567 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
[551]568 pd->hwndDir1 : pd->hwndDir2;
569 else if (pd->hwndDir1 == pd->hwndCurr)
[133]570 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
[551]571 pd->hwndDir2 : hwndTree;
[133]572 else
573 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
[551]574 hwndTree : pd->hwndDir1;
[133]575 }
[2]576 }
[551]577 else {
578 if (pd->hwndMax)
579 hwndFocus = pd->hwndMax;
[133]580 else
[551]581 hwndFocus = (pd->hwndCurr == pd->hwndDir1) ?
582 pd->hwndDir2 : pd->hwndDir1;
[133]583 }
584 WinSetFocus(HWND_DESKTOP, hwndFocus);
585 }
586 break;
[2]587
[133]588 case IDM_NOTEBOOK:
589 WinDlgBox(HWND_DESKTOP,
590 hwnd,
[551]591 CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMP(realappname));
592 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]593 break;
[2]594
[133]595 case IDM_SEEALL:
596 case IDM_GREP:
597 case IDM_COLLECTOR:
598 {
599 HWND hwndC;
600
601 hwndC = StartCollector(HWND_DESKTOP, 4);
[551]602 if (hwndC) {
[133]603 WinSetWindowPos(hwndC,
604 HWND_TOP,
[551]605 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE);
[133]606 if (SHORT1FROMMP(mp1) == IDM_GREP)
607 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
[551]608 WM_COMMAND, MPFROM2SHORT(IDM_GREP, 0), MPVOID);
[133]609 if (SHORT1FROMMP(mp1) == IDM_SEEALL)
610 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
[551]611 WM_COMMAND, MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
[2]612 }
[133]613 }
614 break;
[2]615
[133]616 case IDM_EDITCOMMANDS:
617 EditCommands(hwnd);
618 break;
619
620 default:
621 if (SHORT1FROMMP(mp1) >= IDM_SWITCHSTART &&
[551]622 SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499) {
[133]623 if (SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches)
[551]624 WinSwitchToProgram(switches[SHORT1FROMMP(mp1) - IDM_SWITCHSTART]);
[2]625 break;
[133]626 }
627 else if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
[551]628 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
[2]629
[133]630 INT x;
631 HWND hwndCnr;
632
633 if (!cmdloaded)
634 load_commands();
[551]635 hwndCnr = TopWindow(hwnd, (HWND) 0);
636 hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
637 UM_CONTAINERHWND, MPVOID, MPVOID);
638 if (!hwndCnr) {
639 Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
[133]640 break;
[2]641 }
[133]642 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
[551]643 if (x >= 0) {
[133]644 x++;
645 RunCommand(hwndCnr, x);
[551]646 if (fUnHilite) {
[2]647
[133]648 PCNRITEM pci;
649 DIRCNRDATA *dcd = NULL;
[2]650
[133]651 if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
652 dcd = INSTDATA(hwndCnr);
653 pci = (PCNRITEM) WinSendMsg(hwndCnr,
654 CM_QUERYRECORDEMPHASIS,
655 MPFROMLONG(CMA_FIRST),
656 MPFROMSHORT(CRA_CURSORED));
[672]657 if (pci && (INT) pci != -1 && (pci->rc.flRecordAttr & CRA_SELECTED)) {
658 UnHilite(hwnd,
659 TRUE,
660 dcd ? &dcd->lastselection : NULL,
661 dcd ? dcd->ulItemsToUnHilite : 0);
662 }
[133]663 }
[2]664 }
[133]665 }
666 else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
[551]667 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
[133]668 if (!qtloaded)
669 load_quicktools();
[551]670 if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
[133]671 if (fToolsChanged)
672 save_tools(NULL);
673 if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
674 load_tools(NULL);
[551]675 else {
676 strcpy(lasttoolbox,
677 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
678 PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
[133]679 }
680 BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]681 MAIN_TOOLS), TRUE);
[2]682 }
[133]683 }
[551]684 else {
[2]685
[133]686 HWND hwndActive;
[2]687
[551]688 hwndActive = TopWindow(hwnd, (HWND) 0);
[133]689 if (hwndActive)
[551]690 PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), msg, mp1, mp2);
[133]691 }
692 break;
[2]693 }
694 return 0;
695}
696
[551]697static MRESULT EXPENTRY MainWMOnce2(HWND hwnd, ULONG msg, MPARAM mp1,
698 MPARAM mp2)
[133]699{
[2]700 PERSON1DATA *pd;
701
[551]702 switch (msg) {
[133]703 case WM_CREATE:
704 {
705 TID tid;
[2]706
[133]707 WinQueryWindowProcess(hwnd, &mypid, &tid);
708 }
709 hwndMain = hwnd;
710 WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
711 WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
712 WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
713 WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
[551]714 if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
715 Runtime_Error(pszSrcFile, __LINE__,
716 GetPString(IDS_COULDNTSTARTTHREADTEXT));
717 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
[133]718 return 0;
719 }
720 else
[771]721 DosSleep(32);//05 Aug 07 GKY 64
[2]722
[551]723 pd = xmallocz(sizeof(PERSON1DATA), pszSrcFile, __LINE__);
[133]724 if (!pd)
725 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
[352]726 else {
[551]727 pd->size = sizeof(PERSON1DATA);
728 WinSetWindowPtr(hwnd, QWL_USER + 4, (PVOID) pd);
[133]729 }
730 {
731 SWP swp;
732 PFNWP oldproc;
[2]733
[133]734 /*
735 * create frame children (not client children, frame children)
736 */
[771]737 DosSleep(1);
[133]738 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
739 oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT),
740 (PFNWP) MainFrameWndProc2);
741 if (oldproc)
[574]742 WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER, (PVOID) oldproc);
[133]743 CommonCreateMainChildren(hwnd, &swp);
[2]744
[133]745 {
746 HWND hwndMenu;
[2]747
[551]748 hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_MENU);
749 WinSetWindowULong(hwnd, 0, hwndMenu);
750 SetConditionalCascade(hwndMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
751 SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
[2]752 }
[133]753 }
754 WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]755 FID_TITLEBAR), "FM/2 Lite");
756 FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), NULL);
757 SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_SYSMENU));
[133]758 break;
[2]759
[133]760 case UM_SETUP:
[299]761 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]762 if (pd) {
[2]763
[133]764 CHAR s[CCHMAXPATH];
765 ULONG size;
766 DIRCNRDATA *dcd;
767 HWND hwndC;
768 BOOL dummy = TRUE;
[2]769
[133]770 size = sizeof(BOOL);
771 PrfQueryProfileData(fmprof,
[551]772 realappname, "FM/4 TreeUp", (PVOID) & dummy, &size);
773 if (dummy) {
[133]774 size = sizeof(ULONG);
775 hwndTree = StartTreeCnr(hwnd, 3);
776 PrfQueryProfileData(fmprof,
777 realappname,
[551]778 "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
[133]779 TreeWidth = max(TreeWidth, 80);
780 }
781 size = sizeof(BOOL);
782 if (PrfQueryProfileData(fmprof,
783 FM3Str,
[551]784 "Toolbar", &dummy, &size) && size && !dummy)
785 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
[2]786
[133]787 size = sizeof(s);
788 *s = 0;
789 if (PrfQueryProfileData(fmprof,
[551]790 realappname, "FM/4 Dir1", s, &size) && *s)
[133]791 MakeValidDir(s);
792 else
793 save_dir(s);
[551]794 pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 =
795 StartDirCnr(hwnd, s, (HWND) 0, 3);
[133]796 size = sizeof(s);
797 *s = 0;
798 if (PrfQueryProfileData(fmprof,
[551]799 realappname, "FM/4 Dir2", s, &size) && *s)
[133]800 MakeValidDir(s);
801 else
802 save_dir(s);
[551]803 pd->hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3);
804 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
[2]805
[551]806 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
807 if (hwndC) {
[299]808 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
[551]809 if (dcd) {
[133]810 size = sizeof(INT);
811 if (PrfQueryProfileData(fmprof,
812 realappname,
813 "FM/4 Dir1.Sort",
[551]814 (PVOID) & dcd->sortFlags,
815 &size) && size == sizeof(INT)) {
816 if (!dcd->sortFlags)
817 dcd->sortFlags = SORT_PATHNAME;
[133]818 }
819 size = sizeof(MASK);
820 if (PrfQueryProfileData(fmprof,
821 realappname,
822 "FM/4 Dir1.Filter",
[551]823 (PVOID) & dcd->mask, &size) && size) {
824 if (*dcd->mask.szMask)
[133]825 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
[551]826 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
[133]827 }
[551]828 *(dcd->mask.prompt) = 0;
[133]829 size = sizeof(ULONG);
830 if (PrfQueryProfileData(fmprof,
831 realappname,
832 "FM/4 Dir1.View",
[551]833 (PVOID) & dcd->flWindowAttr,
834 &size) && size == sizeof(ULONG)) {
[2]835
[133]836 CNRINFO cnri;
[2]837
[133]838 memset(&cnri, 0, sizeof(CNRINFO));
839 cnri.cb = sizeof(CNRINFO);
840 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
841 CM_QUERYCNRINFO,
[551]842 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
843 cnri.flWindowAttr = dcd->flWindowAttr;
[133]844 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
845 CM_SETCNRINFO,
[551]846 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
[133]847 }
848 }
849 }
850 }
[2]851
[551]852 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
853 if (hwndC) {
[299]854 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
[551]855 if (dcd) {
[133]856 size = sizeof(INT);
857 if (PrfQueryProfileData(fmprof,
858 realappname,
859 "FM/4 Dir2.Sort",
[551]860 (PVOID) & dcd->sortFlags,
861 &size) && size == sizeof(INT)) {
862 if (!dcd->sortFlags)
863 dcd->sortFlags = SORT_PATHNAME;
[133]864 }
865 size = sizeof(MASK);
866 if (PrfQueryProfileData(fmprof,
867 realappname,
868 "FM/4 Dir2.Filter",
[551]869 (PVOID) & dcd->mask, &size) && size) {
870 if (*dcd->mask.szMask)
[133]871 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
[551]872 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
[133]873 }
[551]874 *(dcd->mask.prompt) = 0;
[133]875 size = sizeof(ULONG);
876 if (PrfQueryProfileData(fmprof,
877 realappname,
878 "FM/4 Dir2.View",
[551]879 (PVOID) & dcd->flWindowAttr,
880 &size) && size == sizeof(ULONG)) {
[2]881
[133]882 CNRINFO cnri;
[2]883
[133]884 memset(&cnri, 0, sizeof(CNRINFO));
885 cnri.cb = sizeof(CNRINFO);
886 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
887 CM_QUERYCNRINFO,
[551]888 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
889 cnri.flWindowAttr = dcd->flWindowAttr;
[133]890 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
891 CM_SETCNRINFO,
[551]892 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
[133]893 }
894 }
895 }
[2]896 }
[133]897 }
898 {
899 ULONG which = 0, size = sizeof(ULONG);
900
901 if (PrfQueryProfileData(fmprof,
902 realappname,
903 "FM/4 Max",
904 (PVOID) & which,
[551]905 &size) && size == sizeof(ULONG) && which) {
[133]906 PostMsg(hwnd,
907 UM_MAXIMIZE,
908 MPFROMLONG(((which == 1) ?
[551]909 pd->hwndDir1 : pd->hwndDir2)), MPVOID);
[2]910 }
[133]911 }
[551]912 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]913 if (!hwndTree)
[551]914 PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
[133]915 load_tools(NULL);
916 BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]917 MAIN_TOOLS), TRUE);
[133]918 fRunning = TRUE;
919 return 0;
[2]920
[133]921 case WM_SAVEAPPLICATION:
922 WinStoreWindowPos(FM2Str,
[551]923 "MainWindowPos2", WinQueryWindow(hwnd, QW_PARENT));
[299]924 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]925 if (pd) {
[2]926
[133]927 CHAR s[CCHMAXPATH];
928 HWND hwndC;
929 DIRCNRDATA *dcd;
930 ULONG flWindowAttr;
[2]931
[133]932 *s = 0;
[551]933 WinSendMsg(pd->hwndDir1, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
934 if (*s) {
[133]935 MakeValidDir(s);
[551]936 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir1", s);
[133]937 }
938 *s = 0;
[551]939 WinSendMsg(pd->hwndDir2, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
940 if (*s) {
[133]941 MakeValidDir(s);
[551]942 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir2", s);
[133]943 }
[551]944 flWindowAttr = (pd->hwndMax == pd->hwndDir1) ?
945 1 : (pd->hwndMax == pd->hwndDir2) ? 2 : 0;
[133]946 PrfWriteProfileData(fmprof,
947 realappname,
[551]948 "FM/4 Max", &flWindowAttr, sizeof(flWindowAttr));
949 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
950 if (hwndC) {
[299]951 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
[551]952 if (dcd) {
953 flWindowAttr = dcd->flWindowAttr;
954 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
[133]955 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
[551]956 if (dcd->lastattr) {
957 if (dcd->lastattr & CV_TEXT)
[133]958 flWindowAttr |= CV_TEXT;
[551]959 else if (dcd->lastattr & CV_DETAIL)
[133]960 flWindowAttr |= CV_DETAIL;
[551]961 else if (dcd->lastattr & CV_ICON)
[133]962 flWindowAttr |= CV_ICON;
963 else
964 flWindowAttr |= CV_NAME;
965 }
966 else
967 flWindowAttr |= CV_NAME;
968 }
969 PrfWriteProfileData(fmprof,
970 realappname,
971 "FM/4 Dir1.Sort",
[551]972 (PVOID) & dcd->sortFlags, sizeof(INT));
[133]973 PrfWriteProfileData(fmprof,
974 realappname,
975 "FM/4 Dir1.Filter",
[551]976 (PVOID) & dcd->mask, sizeof(MASK));
[133]977 PrfWriteProfileData(fmprof,
978 realappname,
979 "FM/4 Dir1.View",
[551]980 (PVOID) & flWindowAttr, sizeof(ULONG));
[133]981 }
982 }
[2]983
[551]984 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
985 if (hwndC) {
[299]986 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
[551]987 if (dcd) {
988 flWindowAttr = dcd->flWindowAttr;
989 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
[133]990 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
[551]991 if (dcd->lastattr) {
992 if (dcd->lastattr & CV_TEXT)
[133]993 flWindowAttr |= CV_TEXT;
[551]994 else if (dcd->lastattr & CV_DETAIL)
[133]995 flWindowAttr |= CV_DETAIL;
[551]996 else if (dcd->lastattr & CV_ICON)
[133]997 flWindowAttr |= CV_ICON;
998 else
999 flWindowAttr |= CV_NAME;
1000 }
1001 else
1002 flWindowAttr |= CV_NAME;
1003 }
1004 PrfWriteProfileData(fmprof,
1005 realappname,
1006 "FM/4 Dir2.Sort",
[551]1007 (PVOID) & dcd->sortFlags, sizeof(INT));
[133]1008 PrfWriteProfileData(fmprof,
1009 realappname,
1010 "FM/4 Dir2.Filter",
[551]1011 (PVOID) & dcd->mask, sizeof(MASK));
[133]1012 PrfWriteProfileData(fmprof,
1013 realappname,
1014 "FM/4 Dir2.View",
[551]1015 (PVOID) & flWindowAttr, sizeof(ULONG));
[133]1016 }
[2]1017 }
[133]1018 }
1019 break;
[2]1020 }
[133]1021 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]1022}
1023
[133]1024MRESULT EXPENTRY MainWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1025{
[2]1026 PERSON1DATA *pd;
1027
[551]1028 switch (msg) {
[133]1029 case WM_SAVEAPPLICATION:
1030 case UM_SETUP:
1031 case WM_CREATE:
1032 return MainWMOnce2(hwnd, msg, mp1, mp2);
[2]1033
[133]1034 case UM_THREADUSE:
1035 case UM_LOADFILE:
[246]1036 case UM_BUILDDRIVEBAR:
[133]1037 return CommonMainWndProc(hwnd, msg, mp1, mp2);
[2]1038
[133]1039 case UM_SETUP2:
[299]1040 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]1041 if (pd) {
1042 if (mp1) {
1043 if (pd->hwndDir1 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir1))
1044 BoxWindow(pd->hwndDir1, (HPS) 0, CLR_PALEGRAY);
1045 if (pd->hwndDir2 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir2))
1046 BoxWindow(pd->hwndDir2, (HPS) 0, CLR_PALEGRAY);
[133]1047 if (hwndTree)
[551]1048 BoxWindow(hwndTree, (HPS) 0, CLR_PALEGRAY);
[2]1049 }
[551]1050 else {
[133]1051 if (hwndTree)
1052 BoxWindow(hwndTree,
1053 (HPS) 0,
[551]1054 (pd->hwndCurr == hwndTree) ? CLR_RED : CLR_WHITE);
1055 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir1)
1056 BoxWindow(pd->hwndDir1,
[133]1057 (HPS) 0,
[551]1058 (pd->hwndDir1 == pd->hwndCurr) ?
[133]1059 CLR_RED :
[551]1060 (pd->hwndDir1 == pd->hwndLastDir) ?
1061 CLR_DARKRED : CLR_PALEGRAY);
1062 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir2)
1063 BoxWindow(pd->hwndDir2,
[133]1064 (HPS) 0,
[551]1065 (pd->hwndDir2 == pd->hwndCurr) ?
[133]1066 CLR_RED :
[551]1067 (pd->hwndDir2 == pd->hwndLastDir) ?
1068 CLR_DARKRED : CLR_PALEGRAY);
[133]1069 }
1070 }
1071 return 0;
[2]1072
[133]1073 case WM_BUTTON1DOWN:
1074 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
[551]1075 if (hwndTree) {
[2]1076
[133]1077 SWP swp;
[2]1078
[133]1079 WinQueryWindowPos(hwndTree, &swp);
1080 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
[551]1081 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) {
[2]1082
[133]1083 SWP swpC;
1084 TRACKINFO track;
[2]1085
[133]1086 WinQueryWindowPos(hwnd, &swpC);
1087 track.cxBorder = 4;
1088 track.cyBorder = 4;
1089 track.cxGrid = 1;
1090 track.cyGrid = 1;
1091 track.cxKeyboard = 8;
1092 track.cyKeyboard = 8;
1093 track.rclTrack.yBottom = 2;
1094 track.rclTrack.yTop = swpC.cy - 4;
1095 track.rclTrack.xLeft = 2;
1096 track.rclTrack.xRight = swp.x + swp.cx + 2;
1097 track.rclBoundary = track.rclTrack;
1098 track.rclBoundary.xRight = swpC.cx - 80;
1099 track.ptlMinTrackSize.x = 80;
1100 track.ptlMinTrackSize.y = swpC.cy - 4;
1101 track.ptlMaxTrackSize.x = swpC.cx - 80;
1102 track.ptlMaxTrackSize.y = swpC.cy - 4;
1103 track.fs = TF_RIGHT;
[551]1104 if (WinTrackRect(hwnd, (HPS) 0, &track)) {
[133]1105 TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft;
1106 PrfWriteProfileData(fmprof,
1107 realappname,
[551]1108 "FM/4 TreeWidth", &TreeWidth, sizeof(ULONG));
1109 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1110 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]1111 }
1112 return (MRESULT) TRUE;
[2]1113 }
[133]1114 }
1115 break;
[2]1116
[133]1117 case WM_MOUSEMOVE:
1118 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
[551]1119 if (hwndTree) {
[2]1120
[133]1121 SWP swp;
[2]1122
[551]1123 if (WinQueryWindowPos(hwndTree, &swp)) {
[133]1124 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
1125 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
1126 WinSetPointer(HWND_DESKTOP, hptrEW);
1127 else
1128 WinSetPointer(HWND_DESKTOP, hptrArrow);
[2]1129 }
[133]1130 else
1131 WinSetPointer(HWND_DESKTOP, hptrArrow);
1132 }
1133 return (MRESULT) TRUE;
[2]1134
[133]1135 case WM_BUTTON1UP:
1136 case WM_BUTTON2UP:
1137 case WM_BUTTON3UP:
1138 case WM_CHAR:
1139 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1140 break;
[2]1141
[133]1142 case UM_ADVISEFOCUS:
[299]1143 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]1144 if (mp1 && pd && (HWND) mp1 != pd->hwndCurr) {
1145 if ((HWND) mp1 != hwndTree)
1146 pd->hwndLastDir = (HWND) mp1;
1147 pd->hwndCurr = (HWND) mp1;
1148 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
[133]1149 }
1150 return 0;
[2]1151
[133]1152 case UM_MAXIMIZE:
[551]1153 if (mp1) {
[299]1154 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]1155 if (pd) {
1156 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1157 if (pd->hwndMax != (HWND) mp1) {
1158 pd->hwndMax = (HWND) mp1;
1159 WinSetFocus(HWND_DESKTOP, pd->hwndMax);
[133]1160 }
1161 else
[551]1162 pd->hwndMax = (HWND) 0;
1163 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[2]1164 }
[133]1165 }
1166 return 0;
[2]1167
[133]1168 case WM_INITMENU:
[551]1169 switch (SHORT1FROMMP(mp1)) {
[133]1170 case IDM_FILESMENU:
1171 case IDM_VIEWSMENU:
1172 case IDM_DETAILSSETUP:
1173 case IDM_COMMANDSMENU:
1174 case IDM_SORTSUBMENU:
[299]1175 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[133]1176 if (pd)
[551]1177 WinSendMsg(pd->hwndCurr, UM_INITMENU, mp1, mp2);
[2]1178 break;
[133]1179 case IDM_CONFIGMENU:
[551]1180 WinCheckMenuItem((HWND) mp2, IDM_TOOLSUBMENU, fToolbar);
1181 WinCheckMenuItem((HWND) mp2, IDM_AUTOVIEW, fAutoView);
[2]1182 break;
[133]1183 case IDM_TOOLSUBMENU:
[551]1184 WinCheckMenuItem((HWND) mp2, IDM_TOOLBAR, fToolbar);
1185 WinCheckMenuItem((HWND) mp2, IDM_TEXTTOOLS, fTextTools);
1186 WinCheckMenuItem((HWND) mp2, IDM_TOOLTITLES, fToolTitles);
[133]1187 break;
1188 case IDM_WINDOWSMENU:
[551]1189 WinCheckMenuItem((HWND) mp2, IDM_VTREE, (hwndTree != (HWND) 0));
1190 WinCheckMenuItem((HWND) mp2, IDM_TILEBACKWARDS, fTileBackwards);
1191 SetupWinList((HWND) mp2, hwnd, WinQueryWindow(hwnd, QW_PARENT));
[133]1192 break;
1193 }
1194 break;
[2]1195
[133]1196 case WM_SETFOCUS:
1197 if (mp2)
[551]1198 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
[133]1199 break;
[2]1200
[133]1201 case UM_FOCUSME:
[299]1202 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[133]1203 if (pd)
[551]1204 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
[133]1205 return 0;
[2]1206
[133]1207 case UM_RESCAN:
1208 return 0;
1209
1210 case UM_SIZE:
1211 {
1212 SWP swp;
1213
[551]1214 if (WinQueryWindowPos(hwnd, &swp)) {
[133]1215 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
1216 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
[2]1217 }
[133]1218 else
1219 return 0;
1220 }
1221 /* intentional fallthru */
1222 case WM_SIZE:
[299]1223 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]1224 if (mp1 && mp2 && pd && pd->hwndDir1 && pd->hwndDir2) {
[133]1225 if (hwndTree)
1226 WinSetWindowPos(hwndTree,
1227 HWND_TOP,
1228 2,
1229 2,
1230 TreeWidth - 4,
1231 SHORT2FROMMP(mp2) - 4,
1232 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1233 else
1234 TreeWidth = 0;
[551]1235 if (!pd->hwndMax) {
1236 if (fTileBackwards) {
1237 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
[133]1238 (((SHORT1FROMMP(mp2) - TreeWidth) / 2) +
1239 TreeWidth) + 2,
1240 2,
1241 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1242 SHORT2FROMMP(mp2) - 4,
1243 SWP_SHOW | SWP_MOVE | SWP_SIZE);
[551]1244 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
[133]1245 TreeWidth + 2,
1246 2,
1247 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1248 SHORT2FROMMP(mp2) - 4,
1249 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1250 }
[551]1251 else {
1252 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
[133]1253 TreeWidth + 2,
1254 2,
1255 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1256 (SHORT2FROMMP(mp2) / 2) - 4,
1257 SWP_SHOW | SWP_MOVE | SWP_SIZE);
[551]1258 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
[133]1259 TreeWidth + 2,
1260 (SHORT2FROMMP(mp2) / 2) + 2,
1261 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1262 (SHORT2FROMMP(mp2) / 2) - 4,
1263 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1264 }
1265 }
[551]1266 else {
[2]1267
[133]1268 HWND hwndOther;
[2]1269
[551]1270 WinSetWindowPos(pd->hwndMax, HWND_TOP,
[133]1271 TreeWidth + 2,
1272 2,
1273 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1274 SHORT2FROMMP(mp2) - 4,
1275 SWP_SHOW | SWP_MOVE | SWP_SIZE);
[551]1276 hwndOther = (pd->hwndMax == pd->hwndDir1) ?
1277 pd->hwndDir2 : pd->hwndDir1;
[133]1278 WinSetWindowPos(hwndOther, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE);
[2]1279 }
[551]1280 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
[133]1281 }
1282 if (msg == UM_SIZE)
[2]1283 return 0;
[133]1284 break;
[2]1285
[133]1286 case WM_ERASEBACKGROUND:
[551]1287 WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
[133]1288 return 0;
1289
1290 case WM_PAINT:
1291 {
1292 HPS hps;
1293 RECTL rcl;
1294
[551]1295 hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
1296 if (hps) {
[133]1297 WinQueryWindowRect(hwnd, &rcl);
[551]1298 WinFillRect(hps, (PRECTL) & rcl, CLR_PALEGRAY);
[133]1299 WinEndPaint(hps);
[551]1300 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
[2]1301 }
[133]1302 }
1303 break;
[2]1304
[133]1305 case UM_COMMAND:
1306 case WM_COMMAND:
1307 return MainWMCommand2(hwnd, msg, mp1, mp2);
[2]1308
[133]1309 case WM_CLOSE:
1310 fAmClosing = TRUE;
[551]1311 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
[133]1312 CloseChildren(hwnd);
[551]1313 PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
[771]1314 DosSleep(1);
[133]1315 return 0;
[2]1316
[133]1317 case UM_CLOSE:
1318 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
1319 return 0;
[2]1320
[133]1321 case WM_DESTROY:
[551]1322 hwndMain = (HWND) 0;
[299]1323 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[133]1324 if (pd)
1325 free(pd);
[551]1326 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1327 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
[133]1328 break;
[2]1329 }
[133]1330 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]1331}
1332
[133]1333HWND StartFM32(HAB hab, INT argc, CHAR ** argv)
1334{
1335 HWND hwndFrame, hwndClient;
1336 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1337 FCF_SIZEBORDER | FCF_MINMAX |
1338 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1339
1340 {
1341 INT x;
1342
[551]1343 for (x = 1; x < argc; x++) {
[133]1344 if (*argv[x] == '+' && !argv[x][1])
1345 fLogFile = TRUE;
[551]1346 if (*argv[x] == '-') {
[133]1347 if (argv[x][1])
1348 strcpy(profile, &argv[x][1]);
[2]1349 }
1350 }
1351 }
1352 {
[133]1353 CHAR inipath[CCHMAXPATH], fullpath[CCHMAXPATH];
[843]1354 FILESTATUS3 fsa;
[2]1355
[133]1356 if (PrfQueryProfileString(HINI_USERPROFILE,
1357 FM2Str,
[551]1358 "Home", NULL, inipath, sizeof(inipath))) {
[843]1359 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, sizeof(fsa))) {
[551]1360 if (fsa.attrFile & FILE_DIRECTORY) {
[133]1361 if (DosQueryPathInfo(inipath,
[551]1362 FIL_QUERYFULLNAME, fullpath, sizeof(fullpath)))
[133]1363 strcpy(fullpath, inipath);
1364 switch_to(fullpath);
1365 }
[2]1366 }
1367 }
1368 }
1369
1370 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[133]1371 WS_VISIBLE,
1372 &FrameFlags,
[593]1373 WC_MAINWND2,
[133]1374 NULL,
1375 WS_VISIBLE | WS_ANIMATE,
[551]1376 FM3ModHandle, MAIN2_FRAME, &hwndClient);
1377 if (hwndFrame) {
[875]1378 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
[551]1379 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos2", hwndFrame)) {
[2]1380
[133]1381 ULONG fl = SWP_MOVE | SWP_SIZE;
[2]1382 RECTL rcl;
[133]1383 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1384 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1385
[133]1386 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1387 rcl.yBottom += icz;
1388 rcl.yTop -= bsz;
1389 rcl.xLeft += bsz;
1390 rcl.xRight -= bsz;
1391 WinSetWindowPos(hwndFrame,
[133]1392 HWND_TOP,
1393 rcl.xLeft,
1394 rcl.yBottom,
[551]1395 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1396 }
[133]1397 if (fLogFile)
1398 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1399 if (hwndHelp)
1400 WinAssociateHelpInstance(hwndHelp, hwndFrame);
[551]1401 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1402 }
1403 return hwndFrame;
1404}
[793]1405
1406#pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2)
1407#pragma alloc_text(PERSON12,StartFM32,MainWMOnce2)
1408#pragma alloc_text(PERSON13,MainWMCommand2)
Note: See TracBrowser for help on using the repository browser.