Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

760 lines
17 KiB

  1. //
  2. // AGRP.CPP
  3. // Tool Attributes Display Group
  4. //
  5. // Copyright Microsoft 1998-
  6. //
  7. // PRECOMP
  8. #include "precomp.h"
  9. // Class name
  10. static const TCHAR szAGClassName[] = "T126WB_AGRP";
  11. //
  12. // Page Control child IDs
  13. // Index is PGC_ value
  14. //
  15. static UINT_PTR g_uPageIds[NUM_PAGE_CONTROLS] =
  16. {
  17. IDM_PAGE_FIRST,
  18. IDM_PAGE_PREV,
  19. IDM_PAGE_ANY,
  20. IDM_PAGE_NEXT,
  21. IDM_PAGE_LAST,
  22. IDM_PAGE_INSERT_AFTER
  23. };
  24. //
  25. // WbAttributesGroup()
  26. //
  27. WbAttributesGroup::WbAttributesGroup(void)
  28. {
  29. int i;
  30. m_hwnd = NULL;
  31. for (i = 0; i < NUM_PAGE_CONTROLS; i++)
  32. {
  33. m_uPageCtrls[i].hbmp = NULL;
  34. m_uPageCtrls[i].hwnd = NULL;
  35. }
  36. m_hPageCtrlFont = NULL;
  37. m_cxPageCtrls = DEFAULT_PGC_WIDTH;
  38. m_hwndFontButton = NULL;
  39. }
  40. //
  41. // ~WbAttibutesGroup()
  42. //
  43. WbAttributesGroup::~WbAttributesGroup(void)
  44. {
  45. int i;
  46. if (m_hwnd != NULL)
  47. {
  48. ::DestroyWindow(m_hwnd);
  49. ASSERT(m_hwnd == NULL);
  50. }
  51. ::UnregisterClass(szAGClassName, g_hInstance);
  52. //
  53. // Delete control bitmaps
  54. //
  55. for (i = 0; i < NUM_PAGE_CONTROLS; i++)
  56. {
  57. if (m_uPageCtrls[i].hbmp)
  58. {
  59. ::DeleteBitmap(m_uPageCtrls[i].hbmp);
  60. m_uPageCtrls[i].hbmp = NULL;
  61. }
  62. }
  63. if (m_hPageCtrlFont != NULL)
  64. {
  65. ::DeleteFont(m_hPageCtrlFont);
  66. m_hPageCtrlFont = NULL;
  67. }
  68. }
  69. //
  70. // Create()
  71. //
  72. BOOL WbAttributesGroup::Create
  73. (
  74. HWND hwndParent,
  75. LPCRECT lpRect
  76. )
  77. {
  78. SIZE size;
  79. RECT rectCG;
  80. RECT rectFSG;
  81. TCHAR szFOBStr[256];
  82. HFONT hOldFont;
  83. HDC hdc;
  84. int i;
  85. BITMAP bmpInfo;
  86. int x, cx;
  87. int yLogPix;
  88. WNDCLASSEX wc;
  89. ASSERT(m_hwnd == NULL);
  90. // Register our class
  91. ZeroMemory(&wc, sizeof(wc));
  92. wc.cbSize = sizeof(wc);
  93. wc.style = 0;
  94. wc.lpfnWndProc = AGWndProc;
  95. wc.hInstance = g_hInstance;
  96. wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
  97. wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
  98. wc.lpszClassName = szAGClassName;
  99. if (!::RegisterClassEx(&wc))
  100. {
  101. ERROR_OUT(("WbAttributesGroup::Create register class failed"));
  102. return(FALSE);
  103. }
  104. // Create the window
  105. if (!::CreateWindowEx(0, szAGClassName, NULL,
  106. WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
  107. lpRect->left, lpRect->top,
  108. lpRect->right - lpRect->left, lpRect->bottom - lpRect->top,
  109. hwndParent, NULL, g_hInstance, this))
  110. {
  111. ERROR_OUT(("Couldn't create WbAttributesGroup window"));
  112. return(FALSE);
  113. }
  114. ASSERT(m_hwnd != NULL);
  115. //
  116. // Create the page control button bitmaps
  117. //
  118. if (!RecolorButtonImages())
  119. {
  120. ERROR_OUT(("Error getting page button bitmaps"));
  121. return(FALSE);
  122. }
  123. hdc = ::CreateCompatibleDC(NULL);
  124. yLogPix = ::GetDeviceCaps(hdc, LOGPIXELSY);
  125. ::DeleteDC(hdc);
  126. //
  127. // Create the font for the edit field and buttons
  128. //
  129. ::GetObject(m_uPageCtrls[PGC_LAST].hbmp, sizeof(BITMAP), &bmpInfo);
  130. m_hPageCtrlFont = ::CreateFont(-bmpInfo.bmHeight,
  131. 0, 0, 0,
  132. FW_NORMAL, 0, 0, 0,
  133. DEFAULT_CHARSET,
  134. OUT_TT_PRECIS,
  135. CLIP_DFA_OVERRIDE,
  136. DEFAULT_QUALITY,
  137. VARIABLE_PITCH | FF_SWISS,
  138. "Arial" );
  139. if (!m_hPageCtrlFont)
  140. {
  141. ERROR_OUT(("WbPagesGroup::Create - couldn't create font"));
  142. return(FALSE);
  143. }
  144. //
  145. // Create the child controls in inverse order, right to left
  146. //
  147. x = lpRect->right;
  148. for (i = NUM_PAGE_CONTROLS - 1; i >= 0; i--)
  149. {
  150. x -= BORDER_SIZE_X;
  151. switch (i)
  152. {
  153. case PGC_ANY:
  154. cx = (3*PAGEBTN_WIDTH)/2;
  155. break;
  156. case PGC_FIRST:
  157. case PGC_LAST:
  158. // make button fit bitmap width + standard border
  159. ::GetObject(m_uPageCtrls[i].hbmp, sizeof(BITMAP), &bmpInfo);
  160. cx = bmpInfo.bmWidth + 2*::GetSystemMetrics(SM_CXFIXEDFRAME); // standard button border
  161. break;
  162. default:
  163. cx = PAGEBTN_WIDTH;
  164. break;
  165. }
  166. x -= cx;
  167. if (i == PGC_ANY)
  168. {
  169. m_uPageCtrls[i].hwnd = ::CreateWindowEx(WS_EX_CLIENTEDGE,
  170. _T("EDIT"), NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE |
  171. ES_NUMBER | ES_CENTER | ES_MULTILINE,
  172. x, 2*BORDER_SIZE_Y, cx, PAGEBTN_HEIGHT,
  173. m_hwnd, (HMENU)g_uPageIds[i], g_hInstance, NULL);
  174. if (!m_uPageCtrls[i].hwnd)
  175. {
  176. ERROR_OUT(("Couldn't create PGRP edit field"));
  177. return(FALSE);
  178. }
  179. ::SendMessage(m_uPageCtrls[i].hwnd, EM_LIMITTEXT, MAX_NUMCHARS, 0);
  180. ::SendMessage(m_uPageCtrls[i].hwnd, WM_SETFONT, (WPARAM)m_hPageCtrlFont, 0);
  181. }
  182. else
  183. {
  184. m_uPageCtrls[i].hwnd = ::CreateWindowEx(0, _T("BUTTON"),
  185. NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_BITMAP,
  186. x, 2*BORDER_SIZE_Y, cx, PAGEBTN_HEIGHT,
  187. m_hwnd, (HMENU)g_uPageIds[i], g_hInstance, NULL);
  188. if (!m_uPageCtrls[i].hwnd)
  189. {
  190. ERROR_OUT(("Couldn't create PGRP button ID %x", g_uPageIds[i]));
  191. return(FALSE);
  192. }
  193. ::SendMessage(m_uPageCtrls[i].hwnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)m_uPageCtrls[i].hbmp);
  194. }
  195. }
  196. m_cxPageCtrls = lpRect->right - x;
  197. SetPageButtonNo(PGC_FIRST, 1);
  198. SetPageButtonNo(PGC_LAST, 1);
  199. //
  200. // Create the color palette
  201. //
  202. m_colorsGroup.GetNaturalSize(&size);
  203. rectCG.left = BORDER_SIZE_X;
  204. rectCG.right = rectCG.left + size.cx;
  205. rectCG.top = BORDER_SIZE_Y;
  206. rectCG.bottom = rectCG.top + size.cy;
  207. if (!m_colorsGroup.Create(m_hwnd, &rectCG))
  208. {
  209. ERROR_OUT(("Couldn't create CGRP window"));
  210. return(FALSE);
  211. }
  212. //
  213. // Create the font button.
  214. // Now calculate the real size of the button
  215. //
  216. hdc = ::GetDC(m_hwnd);
  217. if (!hdc)
  218. return(FALSE);
  219. hOldFont = SelectFont(hdc, (HFONT)::GetStockObject(DEFAULT_GUI_FONT));
  220. ::LoadString(g_hInstance, IDS_FONTOPTIONS, szFOBStr, 256);
  221. ::GetTextExtentPoint(hdc, szFOBStr, lstrlen(szFOBStr), &size);
  222. SelectFont(hdc, hOldFont);
  223. ::ReleaseDC(m_hwnd, hdc);
  224. size.cx += 4 * BORDER_SIZE_X;
  225. size.cy += 4 * BORDER_SIZE_Y;
  226. m_hwndFontButton = ::CreateWindowEx(0, _T("BUTTON"), szFOBStr,
  227. WS_CHILD | WS_CLIPSIBLINGS | BS_PUSHBUTTON,
  228. rectCG.right + SEPARATOR_SIZE_X, 2*BORDER_SIZE_Y,
  229. max(size.cx, FONTBUTTONWIDTH), max(size.cy, FONTBUTTONHEIGHT),
  230. m_hwnd, (HMENU)IDM_FONT, g_hInstance, NULL);
  231. if (!m_hwndFontButton)
  232. {
  233. ERROR_OUT(("Couldn't create FONT button"));
  234. return(FALSE);
  235. }
  236. ::SendMessage(m_hwndFontButton, WM_SETFONT, (WPARAM)::GetStockObject(DEFAULT_GUI_FONT),
  237. FALSE);
  238. return(TRUE);
  239. }
  240. //
  241. // RecolorButtonImages()
  242. //
  243. BOOL WbAttributesGroup::RecolorButtonImages(void)
  244. {
  245. int i;
  246. HBITMAP hbmpNew;
  247. //
  248. // This creates button bitmaps tied to the 3D colors, and clears the old
  249. // ones/sets the new ones if the buttons are around.
  250. //
  251. for (i = 0; i < NUM_PAGE_CONTROLS; i++)
  252. {
  253. // No bitmaps for the edit field
  254. if (i == PGC_ANY)
  255. continue;
  256. hbmpNew = (HBITMAP)::LoadImage(g_hInstance, MAKEINTRESOURCE(g_uPageIds[i]),
  257. IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS | LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
  258. if (!hbmpNew)
  259. {
  260. ERROR_OUT(("AG::RecolorButtonImages faile to load bitmap ID %d",
  261. g_uPageIds[i]));
  262. return(FALSE);
  263. }
  264. // Set the new one
  265. if (m_uPageCtrls[i].hwnd != NULL)
  266. {
  267. ::SendMessage(m_uPageCtrls[i].hwnd, BM_SETIMAGE, IMAGE_BITMAP,
  268. (LPARAM)hbmpNew);
  269. }
  270. // Delete the old one
  271. if (m_uPageCtrls[i].hbmp != NULL)
  272. {
  273. ::DeleteBitmap(m_uPageCtrls[i].hbmp);
  274. }
  275. // Save this one
  276. m_uPageCtrls[i].hbmp = hbmpNew;
  277. // Put the page number on top
  278. if (m_uPageCtrls[i].hwnd != NULL)
  279. {
  280. if (i == PGC_FIRST)
  281. {
  282. SetPageButtonNo(i, 1);
  283. }
  284. else if (i == PGC_LAST)
  285. {
  286. SetPageButtonNo(i, 1);
  287. }
  288. }
  289. }
  290. return(TRUE);
  291. }
  292. //
  293. //
  294. // Function: GetNaturalSize
  295. //
  296. // Purpose: Return the natural size of the attributes group
  297. //
  298. //
  299. void WbAttributesGroup::GetNaturalSize(LPSIZE lpsize)
  300. {
  301. SIZE sizeCG;
  302. SIZE sizeFSG;
  303. RECT rc;
  304. m_colorsGroup.GetNaturalSize(&sizeCG);
  305. if (!m_hwndFontButton)
  306. {
  307. sizeFSG.cx = FONTBUTTONWIDTH;
  308. sizeFSG.cy = FONTBUTTONHEIGHT;
  309. }
  310. else
  311. {
  312. ::GetWindowRect(m_hwndFontButton, &rc);
  313. sizeFSG.cx = rc.right - rc.left;
  314. sizeFSG.cy = rc.bottom - rc.top;
  315. }
  316. // m_cxPageCtrls includes BORDER_SIZE_X on right side
  317. lpsize->cx = BORDER_SIZE_X
  318. + sizeCG.cx
  319. + SEPARATOR_SIZE_X
  320. + sizeFSG.cx
  321. + SEPARATOR_SIZE_X
  322. + m_cxPageCtrls;
  323. sizeFSG.cy = max(sizeFSG.cy, PAGEBTN_HEIGHT) + BORDER_SIZE_Y;
  324. lpsize->cy = BORDER_SIZE_Y
  325. + max(sizeCG.cy, sizeFSG.cy)
  326. + BORDER_SIZE_Y;
  327. }
  328. //
  329. // IsChildEditField()
  330. //
  331. BOOL WbAttributesGroup::IsChildEditField(HWND hwnd)
  332. {
  333. return(hwnd == m_uPageCtrls[PGC_ANY].hwnd);
  334. }
  335. //
  336. // GetCurrentPageNumber()
  337. //
  338. UINT WbAttributesGroup::GetCurrentPageNumber(void)
  339. {
  340. return(::GetDlgItemInt(m_hwnd, IDM_PAGE_ANY, NULL, FALSE));
  341. }
  342. //
  343. // SetCurrentPageNumber()
  344. //
  345. void WbAttributesGroup::SetCurrentPageNumber(UINT number)
  346. {
  347. ::SetDlgItemInt(m_hwnd, IDM_PAGE_ANY, number, FALSE);
  348. }
  349. //
  350. // SetLastPageNumber()
  351. //
  352. void WbAttributesGroup::SetLastPageNumber(UINT number)
  353. {
  354. SetPageButtonNo(PGC_LAST, number);
  355. }
  356. //
  357. // EnablePageCtrls()
  358. //
  359. void WbAttributesGroup::EnablePageCtrls(BOOL bEnable)
  360. {
  361. int i;
  362. for (i = 0; i < NUM_PAGE_CONTROLS; i++)
  363. {
  364. ::EnableWindow(m_uPageCtrls[i].hwnd, bEnable);
  365. }
  366. //
  367. // Insert is enabled if we are synced and didn't reach the limit
  368. //
  369. ::EnableWindow(m_uPageCtrls[PGC_INSERT].hwnd, g_pDraw->IsSynced() && (g_numberOfWorkspaces < 256) ? bEnable : FALSE);
  370. }
  371. //
  372. // EnableInsert()
  373. //
  374. void WbAttributesGroup::EnableInsert(BOOL bEnable)
  375. {
  376. ::EnableWindow(m_uPageCtrls[PGC_INSERT].hwnd, bEnable);
  377. }
  378. //
  379. // AGWndProc()
  380. //
  381. LRESULT CALLBACK AGWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  382. {
  383. LRESULT lResult = 0;
  384. WbAttributesGroup * pag = (WbAttributesGroup *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
  385. switch (message)
  386. {
  387. case WM_NCCREATE:
  388. pag = (WbAttributesGroup *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
  389. ASSERT(pag);
  390. pag->m_hwnd = hwnd;
  391. ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pag);
  392. goto DefWndProc;
  393. break;
  394. case WM_NCDESTROY:
  395. ASSERT(pag);
  396. pag->m_hwnd = NULL;
  397. break;
  398. case WM_SIZE:
  399. ASSERT(pag);
  400. pag->OnSize((UINT)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
  401. break;
  402. case WM_COMMAND:
  403. ASSERT(pag);
  404. pag->OnCommand(GET_WM_COMMAND_ID(wParam, lParam),
  405. GET_WM_COMMAND_CMD(wParam, lParam),
  406. GET_WM_COMMAND_HWND(wParam, lParam));
  407. break;
  408. default:
  409. DefWndProc:
  410. lResult = DefWindowProc(hwnd, message, wParam, lParam);
  411. break;
  412. }
  413. return(lResult);
  414. }
  415. //
  416. //
  417. // Function: OnSize
  418. //
  419. // Purpose: The tool window has been resized
  420. //
  421. //
  422. void WbAttributesGroup::OnSize(UINT, int, int)
  423. {
  424. RECT rc;
  425. int i;
  426. int x;
  427. RECT rcT;
  428. //
  429. // We haven't created our children yet.
  430. //
  431. if (!m_uPageCtrls[0].hwnd)
  432. return;
  433. ::GetClientRect(m_hwnd, &rc);
  434. x = rc.right - m_cxPageCtrls;
  435. //
  436. // Move the page controls to be right justified.
  437. //
  438. for (i = 0; i < NUM_PAGE_CONTROLS; i++)
  439. {
  440. // Get width of control
  441. ::GetWindowRect(m_uPageCtrls[i].hwnd, &rcT);
  442. rcT.right -= rcT.left;
  443. ::MoveWindow(m_uPageCtrls[i].hwnd, x, 2*BORDER_SIZE_Y,
  444. rcT.right, PAGEBTN_HEIGHT, TRUE);
  445. //
  446. // Move to the next one
  447. //
  448. x += rcT.right + BORDER_SIZE_X;
  449. }
  450. //
  451. // The color palette and font button are left justified, no need to
  452. // move them.
  453. //
  454. }
  455. //
  456. // SetPageButtonNo()
  457. //
  458. // Updates the page text in the first/last button
  459. //
  460. void WbAttributesGroup::SetPageButtonNo(UINT pgcIndex, UINT uiPageNumber )
  461. {
  462. HDC hdc;
  463. BITMAP bmpInfo;
  464. HBITMAP hbmp;
  465. HFONT hOldFont;
  466. HBITMAP hOldBitmap;
  467. RECT rectNumBox;
  468. TCHAR NumStr[16];
  469. TEXTMETRIC tm;
  470. HWND hwndButton;
  471. MLZ_EntryOut(ZONE_FUNCTION, "WbAttributesGroup::SetPageButtonNo");
  472. hwndButton = m_uPageCtrls[pgcIndex].hwnd;
  473. hbmp = m_uPageCtrls[pgcIndex].hbmp;
  474. ASSERT(hwndButton);
  475. ASSERT(hbmp);
  476. ASSERT(m_hPageCtrlFont);
  477. ::GetObject(hbmp, sizeof (BITMAP), (LPVOID)&bmpInfo);
  478. hdc = ::CreateCompatibleDC(NULL);
  479. hOldFont = SelectFont(hdc, m_hPageCtrlFont);
  480. hOldBitmap = SelectBitmap(hdc, hbmp);
  481. ::GetTextMetrics(hdc, &tm);
  482. rectNumBox.left = 10;
  483. rectNumBox.top = -(tm.tmInternalLeading/2);
  484. rectNumBox.right = bmpInfo.bmWidth;
  485. rectNumBox.bottom = bmpInfo.bmHeight;
  486. SelectBrush(hdc, ::GetSysColorBrush( COLOR_3DFACE ) );
  487. ::SetTextColor(hdc, ::GetSysColor( COLOR_BTNTEXT ) );
  488. ::SetBkColor(hdc, ::GetSysColor( COLOR_3DFACE ) );
  489. ::PatBlt(hdc, rectNumBox.left, rectNumBox.top,
  490. rectNumBox.right - rectNumBox.left, rectNumBox.bottom - rectNumBox.top,
  491. PATCOPY);
  492. wsprintf(NumStr, "%d", uiPageNumber);
  493. ::DrawText(hdc, NumStr, -1, &rectNumBox, DT_CENTER);
  494. SelectFont(hdc, hOldFont);
  495. SelectBitmap(hdc, hOldBitmap);
  496. ::DeleteDC(hdc);
  497. ::InvalidateRect(hwndButton, NULL, TRUE);
  498. ::UpdateWindow(hwndButton);
  499. }
  500. //
  501. //
  502. // Function: DisplayTool
  503. //
  504. // Purpose: Display a tool in the attributes group
  505. //
  506. //
  507. void WbAttributesGroup::DisplayTool(WbTool* pTool)
  508. {
  509. SIZE size;
  510. // Display the colors group if necessary
  511. if (!pTool->HasColor())
  512. {
  513. ::ShowWindow(m_colorsGroup.m_hwnd, SW_HIDE);
  514. }
  515. else
  516. {
  517. // Change the color button to match the tool
  518. m_colorsGroup.SetCurColor(pTool->GetColor());
  519. // If the group is currently hidden, show it
  520. if (!::IsWindowVisible(m_colorsGroup.m_hwnd))
  521. {
  522. ::ShowWindow(m_colorsGroup.m_hwnd, SW_SHOW);
  523. }
  524. }
  525. // Display the widths group if necessary
  526. if( (!pTool->HasWidth()) || (!g_pMain->IsToolBarOn()) )
  527. {
  528. ::ShowWindow(g_pMain->m_WG.m_hwnd, SW_HIDE);
  529. }
  530. else
  531. {
  532. UINT uiWidthIndex = pTool->GetWidthIndex();
  533. // If the width index isn't valid, then pop up all the buttons
  534. if (uiWidthIndex < NUM_OF_WIDTHS)
  535. {
  536. // Tell the widths group of the new selection
  537. g_pMain->m_WG.PushDown(uiWidthIndex);
  538. }
  539. // If the group is currently hidden, show it
  540. if (!::IsWindowVisible(g_pMain->m_WG.m_hwnd))
  541. {
  542. ::ShowWindow(g_pMain->m_WG.m_hwnd, SW_SHOW);
  543. }
  544. }
  545. // The font sample group is visible for text and select tools
  546. if (!pTool->HasFont())
  547. {
  548. ::ShowWindow(m_hwndFontButton, SW_HIDE);
  549. }
  550. else
  551. {
  552. if (!::IsWindowVisible(m_hwndFontButton))
  553. {
  554. ::ShowWindow(m_hwndFontButton, SW_SHOW);
  555. }
  556. }
  557. }
  558. //
  559. //
  560. // Function: Hide.
  561. //
  562. // Purpose: Hide the tool attributes bar.
  563. //
  564. //
  565. void WbAttributesGroup::Hide(void)
  566. {
  567. if (m_colorsGroup.m_hwnd != NULL)
  568. ::ShowWindow(m_colorsGroup.m_hwnd, SW_HIDE);
  569. if (m_hwndFontButton != NULL)
  570. ::ShowWindow(m_hwndFontButton, SW_HIDE);
  571. }
  572. //
  573. //
  574. // Function: SelectColor
  575. //
  576. // Purpose: Set the current color
  577. //
  578. //
  579. void WbAttributesGroup::SelectColor(WbTool* pTool)
  580. {
  581. if (pTool != NULL)
  582. {
  583. pTool->SetColor(m_colorsGroup.GetCurColor());
  584. }
  585. }
  586. //
  587. // This forwards all button commands to our main window
  588. //
  589. void WbAttributesGroup::OnCommand(UINT id, UINT cmd, HWND hwndCtl)
  590. {
  591. switch (id)
  592. {
  593. case IDM_PAGE_FIRST:
  594. case IDM_PAGE_PREV:
  595. case IDM_PAGE_NEXT:
  596. case IDM_PAGE_LAST:
  597. case IDM_PAGE_INSERT_AFTER:
  598. case IDM_FONT:
  599. if (cmd == BN_CLICKED)
  600. {
  601. ::PostMessage(g_pMain->m_hwnd, WM_COMMAND,
  602. GET_WM_COMMAND_MPS(id, cmd, hwndCtl));
  603. }
  604. break;
  605. case IDM_PAGE_ANY:
  606. if (cmd == EN_SETFOCUS)
  607. {
  608. ::SendMessage(hwndCtl, EM_SETSEL, 0, (LPARAM)-1);
  609. ::SendMessage(hwndCtl, EM_SCROLLCARET, 0, 0);
  610. }
  611. else if(cmd == EN_MAXTEXT)
  612. {
  613. ::PostMessage(g_pMain->m_hwnd, WM_COMMAND,
  614. GET_WM_COMMAND_MPS(id, cmd, hwndCtl));
  615. }
  616. break;
  617. }
  618. }