Leaked source code of windows server 2003
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.

759 lines
18 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[] = "WB_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, g_pwbCore->WBP_ContentsCountPages());
  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. //
  368. // EnableInsert()
  369. //
  370. void WbAttributesGroup::EnableInsert(BOOL bEnable)
  371. {
  372. ::EnableWindow(m_uPageCtrls[PGC_INSERT].hwnd, bEnable);
  373. }
  374. //
  375. // AGWndProc()
  376. //
  377. LRESULT CALLBACK AGWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  378. {
  379. LRESULT lResult = 0;
  380. WbAttributesGroup * pag = (WbAttributesGroup *)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
  381. switch (message)
  382. {
  383. case WM_NCCREATE:
  384. pag = (WbAttributesGroup *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
  385. ASSERT(pag);
  386. pag->m_hwnd = hwnd;
  387. ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pag);
  388. goto DefWndProc;
  389. break;
  390. case WM_NCDESTROY:
  391. ASSERT(pag);
  392. pag->m_hwnd = NULL;
  393. break;
  394. case WM_SIZE:
  395. ASSERT(pag);
  396. pag->OnSize((UINT)wParam, LOWORD(lParam), HIWORD(lParam));
  397. break;
  398. case WM_COMMAND:
  399. ASSERT(pag);
  400. pag->OnCommand(GET_WM_COMMAND_ID(wParam, lParam),
  401. GET_WM_COMMAND_CMD(wParam, lParam),
  402. GET_WM_COMMAND_HWND(wParam, lParam));
  403. break;
  404. default:
  405. DefWndProc:
  406. lResult = DefWindowProc(hwnd, message, wParam, lParam);
  407. break;
  408. }
  409. return(lResult);
  410. }
  411. //
  412. //
  413. // Function: OnSize
  414. //
  415. // Purpose: The tool window has been resized
  416. //
  417. //
  418. void WbAttributesGroup::OnSize(UINT, int, int)
  419. {
  420. RECT rc;
  421. int i;
  422. int x;
  423. RECT rcT;
  424. //
  425. // We haven't created our children yet.
  426. //
  427. if (!m_uPageCtrls[0].hwnd)
  428. return;
  429. ::GetClientRect(m_hwnd, &rc);
  430. x = rc.right - m_cxPageCtrls;
  431. //
  432. // Move the page controls to be right justified.
  433. //
  434. for (i = 0; i < NUM_PAGE_CONTROLS; i++)
  435. {
  436. // Get width of control
  437. ::GetWindowRect(m_uPageCtrls[i].hwnd, &rcT);
  438. rcT.right -= rcT.left;
  439. ::MoveWindow(m_uPageCtrls[i].hwnd, x, 2*BORDER_SIZE_Y,
  440. rcT.right, PAGEBTN_HEIGHT, TRUE);
  441. //
  442. // Move to the next one
  443. //
  444. x += rcT.right + BORDER_SIZE_X;
  445. }
  446. //
  447. // The color palette and font button are left justified, no need to
  448. // move them.
  449. //
  450. }
  451. //
  452. // SetPageButtonNo()
  453. //
  454. // Updates the page text in the first/last button
  455. //
  456. void WbAttributesGroup::SetPageButtonNo(UINT pgcIndex, UINT uiPageNumber )
  457. {
  458. HDC hdc;
  459. BITMAP bmpInfo;
  460. HBITMAP hbmp;
  461. HFONT hOldFont;
  462. HBITMAP hOldBitmap;
  463. RECT rectNumBox;
  464. TCHAR NumStr[16];
  465. TEXTMETRIC tm;
  466. HWND hwndButton;
  467. MLZ_EntryOut(ZONE_FUNCTION, "WbAttributesGroup::SetPageButtonNo");
  468. hwndButton = m_uPageCtrls[pgcIndex].hwnd;
  469. hbmp = m_uPageCtrls[pgcIndex].hbmp;
  470. ASSERT(hwndButton);
  471. ASSERT(hbmp);
  472. ASSERT(m_hPageCtrlFont);
  473. ::GetObject(hbmp, sizeof (BITMAP), (LPVOID)&bmpInfo);
  474. hdc = ::CreateCompatibleDC(NULL);
  475. hOldFont = SelectFont(hdc, m_hPageCtrlFont);
  476. hOldBitmap = SelectBitmap(hdc, hbmp);
  477. ::GetTextMetrics(hdc, &tm);
  478. rectNumBox.left = 10;
  479. rectNumBox.top = -(tm.tmInternalLeading/2);
  480. rectNumBox.right = bmpInfo.bmWidth;
  481. rectNumBox.bottom = bmpInfo.bmHeight;
  482. SelectBrush(hdc, ::GetSysColorBrush( COLOR_3DFACE ) );
  483. ::SetTextColor(hdc, ::GetSysColor( COLOR_BTNTEXT ) );
  484. ::SetBkColor(hdc, ::GetSysColor( COLOR_3DFACE ) );
  485. ::PatBlt(hdc, rectNumBox.left, rectNumBox.top,
  486. rectNumBox.right - rectNumBox.left, rectNumBox.bottom - rectNumBox.top,
  487. PATCOPY);
  488. wsprintf(NumStr, "%d", uiPageNumber);
  489. ::DrawText(hdc, NumStr, -1, &rectNumBox, DT_CENTER);
  490. SelectFont(hdc, hOldFont);
  491. SelectBitmap(hdc, hOldBitmap);
  492. ::DeleteDC(hdc);
  493. ::InvalidateRect(hwndButton, NULL, TRUE);
  494. ::UpdateWindow(hwndButton);
  495. }
  496. //
  497. //
  498. // Function: DisplayTool
  499. //
  500. // Purpose: Display a tool in the attributes group
  501. //
  502. //
  503. void WbAttributesGroup::DisplayTool(WbTool* pTool)
  504. {
  505. SIZE size;
  506. // make width bar, etc, obey locks (bug 433)
  507. if (WB_Locked())
  508. {
  509. if (g_pMain->m_WG.m_hwnd != NULL)
  510. {
  511. ::ShowWindow(g_pMain->m_WG.m_hwnd, SW_HIDE);
  512. }
  513. Hide();
  514. return;
  515. }
  516. // Display the colors group if necessary
  517. if (!pTool->HasColor())
  518. {
  519. ::ShowWindow(m_colorsGroup.m_hwnd, SW_HIDE);
  520. }
  521. else
  522. {
  523. // Change the color button to match the tool
  524. m_colorsGroup.SetCurColor(pTool->GetColor());
  525. // If the group is currently hidden, show it
  526. if (!::IsWindowVisible(m_colorsGroup.m_hwnd))
  527. {
  528. ::ShowWindow(m_colorsGroup.m_hwnd, SW_SHOW);
  529. }
  530. }
  531. // Display the widths group if necessary
  532. if( (!pTool->HasWidth()) || (!g_pMain->IsToolBarOn()) )
  533. {
  534. ::ShowWindow(g_pMain->m_WG.m_hwnd, SW_HIDE);
  535. }
  536. else
  537. {
  538. UINT uiWidthIndex = pTool->GetWidthIndex();
  539. // If the width index isn't valid, then pop up all the buttons
  540. if (uiWidthIndex < NUM_OF_WIDTHS)
  541. {
  542. // Tell the widths group of the new selection
  543. g_pMain->m_WG.PushDown(uiWidthIndex);
  544. }
  545. // If the group is currently hidden, show it
  546. if (!::IsWindowVisible(g_pMain->m_WG.m_hwnd))
  547. {
  548. ::ShowWindow(g_pMain->m_WG.m_hwnd, SW_SHOW);
  549. }
  550. }
  551. // The font sample group is visible for text and select tools
  552. if (!pTool->HasFont())
  553. {
  554. ::ShowWindow(m_hwndFontButton, SW_HIDE);
  555. }
  556. else
  557. {
  558. if (!::IsWindowVisible(m_hwndFontButton))
  559. {
  560. ::ShowWindow(m_hwndFontButton, SW_SHOW);
  561. }
  562. }
  563. }
  564. //
  565. //
  566. // Function: Hide.
  567. //
  568. // Purpose: Hide the tool attributes bar.
  569. //
  570. //
  571. void WbAttributesGroup::Hide(void)
  572. {
  573. if (m_colorsGroup.m_hwnd != NULL)
  574. ::ShowWindow(m_colorsGroup.m_hwnd, SW_HIDE);
  575. if (m_hwndFontButton != NULL)
  576. ::ShowWindow(m_hwndFontButton, SW_HIDE);
  577. }
  578. //
  579. //
  580. // Function: SelectColor
  581. //
  582. // Purpose: Set the current color
  583. //
  584. //
  585. void WbAttributesGroup::SelectColor(WbTool* pTool)
  586. {
  587. if (pTool != NULL)
  588. {
  589. pTool->SetColor(m_colorsGroup.GetCurColor());
  590. }
  591. }
  592. //
  593. // This forwards all button commands to our main window
  594. //
  595. void WbAttributesGroup::OnCommand(UINT id, UINT cmd, HWND hwndCtl)
  596. {
  597. switch (id)
  598. {
  599. case IDM_PAGE_FIRST:
  600. case IDM_PAGE_PREV:
  601. case IDM_PAGE_NEXT:
  602. case IDM_PAGE_LAST:
  603. case IDM_PAGE_INSERT_AFTER:
  604. case IDM_FONT:
  605. if (cmd == BN_CLICKED)
  606. {
  607. ::PostMessage(g_pMain->m_hwnd, WM_COMMAND,
  608. GET_WM_COMMAND_MPS(id, cmd, hwndCtl));
  609. }
  610. break;
  611. case IDM_PAGE_ANY:
  612. if (cmd == EN_SETFOCUS)
  613. {
  614. ::SendMessage(hwndCtl, EM_SETSEL, 0, (LPARAM)-1);
  615. ::SendMessage(hwndCtl, EM_SCROLLCARET, 0, 0);
  616. }
  617. break;
  618. }
  619. }
  620.