source: trunk/dll/mainwnd2.c@ 938

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

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

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