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.

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