XTFlatComboBox.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:16k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTFlatComboBox.cpp : implementation of the CXTFlatComboBox class.
  2. //
  3. // This file is a part of the XTREME CONTROLS MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "Resource.h"
  22. #include "Common/XTPResourceManager.h"
  23. #include "Common/XTPDrawHelpers.h"
  24. #include "XTDefines.h"
  25. #include "XTGlobal.h"
  26. #include "XTFlatComboBox.h"
  27. #include "XTFlatControlsTheme.h"
  28. #include "XTFunctions.h"
  29. #ifdef _DEBUG
  30. #define new DEBUG_NEW
  31. #undef THIS_FILE
  32. static char THIS_FILE[] = __FILE__;
  33. #endif
  34. #define EVENT_TIMER   1000
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CXTFlatComboBox
  37. CXTFlatComboBox::CXTFlatComboBox()
  38. : CXTThemeManagerStyleHost(GetThemeFactoryClass())
  39. , m_bDisableAC(FALSE)
  40. , m_bFlatLook(TRUE)
  41. , m_bPainted(FALSE)
  42. , m_bHasFocus(FALSE)
  43. , m_bAutoComp(FALSE)
  44. , m_nStyle(0)
  45. , m_nStyleEx(0)
  46. , m_crBack(COLORREF_NULL)
  47. , m_crText(COLORREF_NULL)
  48. {
  49. }
  50. CXTFlatComboBox::~CXTFlatComboBox()
  51. {
  52. }
  53. IMPLEMENT_THEME_HOST(CXTFlatComboBox)
  54. IMPLEMENT_THEME_REFRESH(CXTFlatComboBox, CComboBox)
  55. IMPLEMENT_DYNAMIC(CXTFlatComboBox, CComboBox)
  56. BEGIN_MESSAGE_MAP(CXTFlatComboBox, CComboBox)
  57. //{{AFX_MSG_MAP(CXTFlatComboBox)
  58. ON_WM_TIMER()
  59. ON_WM_PAINT()
  60. ON_CONTROL_REFLECT_EX(CBN_SETFOCUS, OnSetFocus)
  61. ON_CONTROL_REFLECT_EX(CBN_KILLFOCUS, OnKillFocus)
  62. ON_WM_SETCURSOR()
  63. ON_CONTROL_REFLECT_EX(CBN_EDITUPDATE, OnEditUpdate)
  64. ON_CONTROL_REFLECT_EX(CBN_CLOSEUP, OnEndSel)
  65. ON_WM_ERASEBKGND()
  66. ON_MESSAGE(WM_PRINTCLIENT, OnPrintClient)
  67. //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CXTFlatComboBox message handlers
  71. BOOL CXTFlatComboBox::PointInRect()
  72. {
  73. ASSERT(::IsWindow(m_hWnd));
  74. CRect rc;
  75. GetWindowRect(rc);
  76. CPoint pt;
  77. GetCursorPos(&pt);
  78. return rc.PtInRect(pt);
  79. }
  80. BOOL CXTFlatComboBox::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
  81. {
  82. if (IsFlat() && (message == WM_MOUSEMOVE) && PointInRect())
  83. {
  84. SetTimer(EVENT_TIMER, 10, NULL);
  85. OnTimer(EVENT_TIMER);
  86. }
  87. return CComboBox::OnSetCursor(pWnd, nHitTest, message);
  88. }
  89. void CXTFlatComboBox::DisableFlatLook(BOOL bDisable)
  90. {
  91. if (IsFlat() == bDisable)
  92. {
  93. m_bFlatLook = !bDisable;
  94. if (::IsWindow(m_hWnd))
  95. {
  96. if (IsFlat())
  97. {
  98. // save style.
  99. m_nStyle = GetStyle() & (WS_BORDER);
  100. m_nStyleEx = GetExStyle() & (WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
  101. ModifyStyle(WS_BORDER, 0);
  102. ModifyStyleEx(WS_EX_CLIENTEDGE | WS_EX_STATICEDGE, 0);
  103. }
  104. else
  105. {
  106. ModifyStyle(0, m_nStyle);
  107. ModifyStyleEx(0, m_nStyleEx);
  108. }
  109. SetWindowPos(NULL, 0, 0, 0, 0,
  110. SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_NOZORDER);
  111. }
  112. }
  113. }
  114. void CXTFlatComboBox::OnTimer(UINT_PTR nIDEvent)
  115. {
  116. if (EVENT_TIMER == nIDEvent)
  117. {
  118. if (!PointInRect())
  119. {
  120. KillTimer(EVENT_TIMER);
  121. if (m_bPainted == TRUE)
  122. {
  123. RedrawWindow();
  124. }
  125. m_bPainted = FALSE;
  126. }
  127. // on mouse over, show raised.
  128. else if (!m_bPainted)
  129. {
  130. RedrawWindow();
  131. m_bPainted = TRUE;
  132. }
  133. }
  134. else
  135. {
  136. CComboBox::OnTimer(nIDEvent);
  137. }
  138. }
  139. BOOL CXTFlatComboBox::OnEraseBkgnd(CDC* /*pDC*/)
  140. {
  141. return TRUE;
  142. }
  143. void CXTFlatComboBox::OnPaint()
  144. {
  145. // do default rendering first.
  146. CComboBox::OnPaint();
  147. // get the client device context.
  148. CClientDC dc(this);
  149. DoPaint(&dc);
  150. }
  151. void CXTFlatComboBox::CalcClientRect(CRect& rc)
  152. {
  153. // deflate by 3D border, 3D edge and drop arrow (thumb).
  154. rc.DeflateRect(GetTheme()->GetBorderSize());
  155. rc.DeflateRect(GetTheme()->GetEdgeSize());
  156. rc.right -= GetTheme()->GetThumbSize().cx;
  157. }
  158. // a helper for rendering the control appearance
  159. void CXTFlatComboBox::DoPaint(CDC* pDC)
  160. {
  161. // draw theme.
  162. if (IsFlat())
  163. {
  164. // Get the client rect.
  165. CXTPClientRect r(this);
  166. // exclude client portions from redraw.
  167. CRect rClip(r);
  168. CalcClientRect(rClip);
  169. pDC->ExcludeClipRect(&rClip);
  170. // Paint to a memory device context to help
  171. // eliminate screen flicker.
  172. CXTPBufferDC memDC(*pDC, r);
  173. memDC.FillSolidRect(r, GetXtremeColor(COLOR_3DFACE));
  174. if (m_bHasFocus || PointInRect())
  175. {
  176. DrawCombo(&memDC, GetDroppedState() ? xtMouseSelect : xtMouseHover);
  177. }
  178. else
  179. {
  180. DrawCombo(&memDC, xtMouseNormal);
  181. }
  182. }
  183. }
  184. void CXTFlatComboBox::DrawCombo(CDC* pDC, XTMouseState  eState)
  185. {
  186. GetTheme()->DrawFlatComboBox(pDC, this, eState);
  187. }
  188. BOOL CXTFlatComboBox::OnSetFocus()
  189. {
  190. if (IsFlat())
  191. {
  192. m_bHasFocus = TRUE;
  193. RedrawWindow();
  194. }
  195. return FALSE;
  196. }
  197. BOOL CXTFlatComboBox::OnKillFocus()
  198. {
  199. if (IsFlat())
  200. {
  201. m_bHasFocus = FALSE;
  202. RedrawWindow();
  203. }
  204. return FALSE;
  205. }
  206. BOOL CXTFlatComboBox::PreTranslateMessage(MSG* pMsg)
  207. {
  208. // Make sure that the keystrokes continue to the edit control.
  209. if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP)
  210. {
  211. // if tab, return or escape key, just use default.
  212. switch (pMsg->wParam)
  213. {
  214. case VK_DELETE:
  215. case VK_BACK:
  216. {
  217. if (m_bAutoComp)
  218. {
  219. m_bDisableAC = (pMsg->message == WM_KEYDOWN);
  220. }
  221. break;
  222. }
  223. case VK_TAB:
  224. case VK_RETURN:
  225. case VK_ESCAPE:
  226. {
  227. return CComboBox::PreTranslateMessage(pMsg);
  228. }
  229. }
  230. // If the combo box has an edit control, don't allow
  231. // the framework to process accelerators, let the edit
  232. // control handle it instead.  GetEditSel() will return
  233. // CB_ERR if there is no edit control present...
  234. if (GetEditSel() != (DWORD)CB_ERR)
  235. {
  236. ::TranslateMessage(pMsg);
  237. ::DispatchMessage(pMsg);
  238. return TRUE;
  239. }
  240. }
  241. return CComboBox::PreTranslateMessage(pMsg);
  242. }
  243. BOOL CXTFlatComboBox::OnEditUpdate()
  244. {
  245. // if we are not to auto update the text, get outta here
  246. if (m_bAutoComp)
  247. {
  248. if (m_bDisableAC)
  249. {
  250. Default();
  251. }
  252. else
  253. {
  254. // Get the text in the edit box
  255. CString strItemTyped;
  256. GetWindowText(strItemTyped);
  257. int nLength = strItemTyped.GetLength();
  258. if (nLength >= 1)
  259. {
  260. // Currently selected range
  261. DWORD dwCurSel = GetEditSel();
  262. int nStart = LOWORD(dwCurSel);
  263. int nEnd = HIWORD(dwCurSel);
  264. // Search for, and select in, and string in the combo box that is prefixed
  265. // by the text in the edit box
  266. if (SelectString(-1, strItemTyped) == CB_ERR)
  267. {
  268. SetWindowText(strItemTyped);     // No text selected, so restore what was there before
  269. if (dwCurSel != (DWORD)CB_ERR)
  270. {
  271. SetEditSel(nStart, nEnd);   //restore cursor postion
  272. }
  273. }
  274. // Set the text selection as the additional text that we have added
  275. if (nEnd < nLength && dwCurSel != (DWORD)CB_ERR)
  276. {
  277. SetEditSel(nStart, nEnd);
  278. }
  279. else
  280. {
  281. SetEditSel(nLength, -1);
  282. }
  283. }
  284. }
  285. }
  286. return FALSE;
  287. }
  288. BOOL CXTFlatComboBox::OnEndSel()
  289. {
  290. if (IsFlat())
  291. {
  292. Invalidate();
  293. }
  294. return FALSE;
  295. }
  296. LRESULT CXTFlatComboBox::OnPrintClient(WPARAM wp, LPARAM)
  297. {
  298. LRESULT lResult = Default();
  299. CDC* pDC = CDC::FromHandle((HDC)wp);
  300. DoPaint(pDC);
  301. return lResult;
  302. }
  303. /////////////////////////////////////////////////////////////////////////////
  304. // CXTEdit
  305. /////////////////////////////////////////////////////////////////////////////
  306. CXTEdit::CXTEdit()
  307. : m_pParentWnd(NULL)
  308. {
  309. }
  310. CXTEdit::~CXTEdit()
  311. {
  312. }
  313. IMPLEMENT_DYNAMIC(CXTEdit, CEdit)
  314. BEGIN_MESSAGE_MAP(CXTEdit, CEdit)
  315. //{{AFX_MSG_MAP(CXTEdit)
  316. ON_WM_CONTEXTMENU()
  317. ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
  318. ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
  319. ON_COMMAND(ID_EDIT_CUT, OnEditCut)
  320. ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut)
  321. ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  322. ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
  323. ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  324. ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
  325. ON_COMMAND(ID_EDIT_CLEAR, OnEditClear)
  326. ON_UPDATE_COMMAND_UI(ID_EDIT_CLEAR, OnUpdateEditClear)
  327. ON_COMMAND(ID_EDIT_SELECT_ALL, OnEditSelectAll)
  328. ON_UPDATE_COMMAND_UI(ID_EDIT_SELECT_ALL, OnUpdateEditSelectAll)
  329. ON_WM_ERASEBKGND()
  330. ON_WM_PAINT()
  331. ON_WM_INITMENUPOPUP()
  332. //}}AFX_MSG_MAP
  333. END_MESSAGE_MAP()
  334. /////////////////////////////////////////////////////////////////////////////
  335. // CXTEdit message handlers
  336. bool CXTEdit::Initialize(CWnd* pParentWnd)
  337. {
  338. // edit control must be valid in order to initialize.
  339. ASSERT_VALID(this);
  340. if (!::IsWindow(m_hWnd))
  341. return false;
  342. // If the parent is not valid, return false.
  343. ASSERT_VALID(pParentWnd);
  344. if (!pParentWnd || !::IsWindow(pParentWnd->m_hWnd))
  345. return false;
  346. // set the font and parent for the browse edit.
  347. SetFont(&XTAuxData().font);
  348. m_pParentWnd = pParentWnd;
  349. return true;
  350. }
  351. void CXTEdit::OnContextMenu(CWnd*, CPoint point)
  352. {
  353. if (point.x == -1 && point.y == -1)
  354. {
  355. //keystroke invocation
  356. CRect rect;
  357. GetClientRect(rect);
  358. ClientToScreen(rect);
  359. point = rect.TopLeft();
  360. point.Offset(5, 5);
  361. }
  362. SetFocus();
  363. CMenu menu;
  364. VERIFY(XTPResourceManager()->LoadMenu(&menu, XT_IDM_POPUP));
  365. CMenu* pPopup = menu.GetSubMenu(1);
  366. ASSERT(pPopup != NULL);
  367. CWnd* pWndPopupOwner = this;
  368. XTFuncContextMenu(pPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON,
  369. point.x, point.y, pWndPopupOwner, XT_IDR_TBAR_HEXEDIT, FALSE);
  370. }
  371. void CXTEdit::OnEditUndo()
  372. {
  373. Undo();
  374. }
  375. void CXTEdit::OnUpdateEditUndo(CCmdUI* pCmdUI)
  376. {
  377. pCmdUI->Enable(CanUndo());
  378. }
  379. void CXTEdit::OnEditCut()
  380. {
  381. Cut();
  382. }
  383. void CXTEdit::OnUpdateEditCut(CCmdUI* pCmdUI)
  384. {
  385. pCmdUI->Enable(SelectionMade() && ((GetStyle() & ES_READONLY) == 0));
  386. }
  387. void CXTEdit::OnEditCopy()
  388. {
  389. Copy();
  390. }
  391. void CXTEdit::OnUpdateEditCopy(CCmdUI* pCmdUI)
  392. {
  393. pCmdUI->Enable(SelectionMade());
  394. }
  395. void CXTEdit::OnEditPaste()
  396. {
  397. Paste();
  398. }
  399. void CXTEdit::OnUpdateEditPaste(CCmdUI* pCmdUI)
  400. {
  401. pCmdUI->Enable(CanPaste());
  402. }
  403. void CXTEdit::OnEditClear()
  404. {
  405. Clear();
  406. }
  407. void CXTEdit::OnUpdateEditClear(CCmdUI* pCmdUI)
  408. {
  409. pCmdUI->Enable(SelectionMade() && ((GetStyle() & ES_READONLY) == 0));
  410. }
  411. void CXTEdit::OnEditSelectAll()
  412. {
  413. SetSel(0, -1);
  414. }
  415. void CXTEdit::OnUpdateEditSelectAll(CCmdUI* pCmdUI)
  416. {
  417. pCmdUI->Enable(GetWindowTextLength() > 0);
  418. }
  419. BOOL CXTEdit::CanPaste()
  420. {
  421. return IsWindowEnabled() && ((GetStyle() & ES_READONLY) == 0) & ::IsClipboardFormatAvailable(CF_TEXT);
  422. }
  423. BOOL CXTEdit::SelectionMade()
  424. {
  425. int nStartChar, nEndChar;
  426. GetSel(nStartChar, nEndChar);
  427. return (nStartChar < nEndChar);
  428. }
  429. BOOL CXTEdit::OnEraseBkgnd(CDC* /*pDC*/)
  430. {
  431. return TRUE;
  432. }
  433. void CXTEdit::OnPaint()
  434. {
  435. CPaintDC dc(this); // device context for painting
  436. // Get the client rect.
  437. CRect r;
  438. GetClientRect(&r);
  439. // Paint to a memory device context to help
  440. // eliminate screen flicker.
  441. CXTPBufferDC memDC(dc);
  442. memDC.FillSolidRect(r, IsWindowEnabled() ? GetXtremeColor(COLOR_WINDOW) : GetXtremeColor(COLOR_3DFACE));
  443. // Now let the window do its default painting...
  444. CEdit::DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0);
  445. }
  446. void CXTEdit::OnInitMenuPopup(CMenu* pPopupMenu, UINT /*nIndex*/, BOOL bSysMenu)
  447. {
  448. Default();
  449. if (!bSysMenu)
  450. {
  451. ASSERT(pPopupMenu != NULL);
  452. if (!pPopupMenu)
  453. return;
  454. // check the enabled state of various menu items
  455. CCmdUI state;
  456. state.m_pMenu = pPopupMenu;
  457. ASSERT(state.m_pOther == NULL);
  458. state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
  459. for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
  460. state.m_nIndex++)
  461. {
  462. state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
  463. if (state.m_nID == 0)
  464. continue; // menu separator or invalid cmd - ignore it
  465. ASSERT(state.m_pOther == NULL);
  466. ASSERT(state.m_pMenu != NULL);
  467. if (state.m_nID == (UINT)-1)
  468. {
  469. // possibly a popup menu, route to first item of that popup
  470. state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
  471. if (state.m_pSubMenu == NULL)
  472. continue;
  473. state.m_nID = state.m_pSubMenu->GetMenuItemID(0);
  474. if (state.m_nID == 0 || state.m_nID == (UINT)-1)
  475. continue; // first item of popup can't be routed to
  476. state.DoUpdate(this, FALSE);  // popups are never auto disabled
  477. }
  478. else
  479. {
  480. // normal menu item
  481. // Auto enable/disable if command is _not_ a system command
  482. state.m_pSubMenu = NULL;
  483. state.DoUpdate(this, state.m_nID < 0xF000);
  484. }
  485. }
  486. }
  487. }
  488. /////////////////////////////////////////////////////////////////////////////
  489. // CXTFlatEdit
  490. /////////////////////////////////////////////////////////////////////////////
  491. IMPLEMENT_THEME_HOST(CXTFlatEdit)
  492. IMPLEMENT_THEME_REFRESH(CXTFlatEdit, CXTEdit)
  493. CXTFlatEdit::CXTFlatEdit()
  494. : CXTThemeManagerStyleHost(GetThemeFactoryClass())
  495. , m_bFlatLook(TRUE)
  496. , m_bHasFocus(FALSE)
  497. , m_bPainted(FALSE)
  498. {
  499. m_nStyle = m_nStyleEx = 0;
  500. }
  501. CXTFlatEdit::~CXTFlatEdit()
  502. {
  503. }
  504. IMPLEMENT_DYNAMIC(CXTFlatEdit, CXTEdit)
  505. BEGIN_MESSAGE_MAP(CXTFlatEdit, CXTEdit)
  506. //{{AFX_MSG_MAP(CXTFlatEdit)
  507. ON_WM_NCPAINT()
  508. ON_WM_TIMER()
  509. ON_WM_SETCURSOR()
  510. ON_WM_SETFOCUS()
  511. ON_WM_KILLFOCUS()
  512. //}}AFX_MSG_MAP
  513. END_MESSAGE_MAP()
  514. /////////////////////////////////////////////////////////////////////////////
  515. // CXTFlatEdit message handlers
  516. BOOL CXTFlatEdit::PointInRect()
  517. {
  518. ASSERT(::IsWindow(m_hWnd));
  519. CRect rc;
  520. GetWindowRect(rc);
  521. CPoint pt;
  522. GetCursorPos(&pt);
  523. return rc.PtInRect(pt);
  524. }
  525. BOOL CXTFlatEdit::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
  526. {
  527. if (IsFlat() && (message == WM_MOUSEMOVE) && PointInRect())
  528. {
  529. SetTimer(EVENT_TIMER, 10, NULL);
  530. OnTimer(EVENT_TIMER);
  531. }
  532. return CXTEdit::OnSetCursor(pWnd, nHitTest, message);
  533. }
  534. void CXTFlatEdit::DisableFlatLook(BOOL bDisable)
  535. {
  536. if (m_bFlatLook == bDisable)
  537. {
  538. m_bFlatLook = !bDisable;
  539. SendMessage(WM_NCPAINT);
  540. }
  541. }
  542. void CXTFlatEdit::OnTimer(UINT_PTR nIDEvent)
  543. {
  544. if (EVENT_TIMER == nIDEvent)
  545. {
  546. if (!PointInRect())
  547. {
  548. KillTimer(EVENT_TIMER);
  549. if (m_bPainted == TRUE)
  550. {
  551. SendMessage(WM_NCPAINT);
  552. }
  553. m_bPainted = FALSE;
  554. }
  555. // on mouse over, show raised.
  556. else if (!m_bPainted)
  557. {
  558. SendMessage(WM_NCPAINT);
  559. m_bPainted = TRUE;
  560. }
  561. }
  562. else
  563. {
  564. CXTEdit::OnTimer(nIDEvent);
  565. }
  566. }
  567. void CXTFlatEdit::OnNcPaint()
  568. {
  569. if (IsFlat())
  570. {
  571. CWindowDC dc(this);
  572. CXTPClientRect rClient(this);
  573. CXTPWindowRect rWindow(this);
  574. ScreenToClient(rWindow);
  575. rClient.OffsetRect(-rWindow.left, -rWindow.top);
  576. dc.ExcludeClipRect(rClient);
  577. rWindow.OffsetRect(-rWindow.left, -rWindow.top);
  578. CXTPBufferDC memDC(dc, rWindow);
  579. dc.FillSolidRect(rWindow, IsWindowEnabled() ? GetXtremeColor(COLOR_WINDOW) : GetXtremeColor(COLOR_3DFACE));
  580. DrawBorders(&memDC, rWindow);
  581. }
  582. else
  583. {
  584. Default();
  585. }
  586. }
  587. // a helper for rendering the control appearance
  588. void CXTFlatEdit::DrawBorders(CDC* pDC, const CRect& rWindow)
  589. {
  590. if (m_bHasFocus || PointInRect())
  591. {
  592. GetTheme()->DrawBorders(pDC, this, rWindow, xtMouseHover);
  593. }
  594. else
  595. {
  596. GetTheme()->DrawBorders(pDC, this, rWindow, xtMouseNormal);
  597. }
  598. }
  599. void CXTFlatEdit::OnSetFocus(CWnd* pOldWnd)
  600. {
  601. CXTEdit::OnSetFocus(pOldWnd);
  602. if (IsFlat())
  603. {
  604. m_bHasFocus = TRUE;
  605. Invalidate();
  606. SendMessage(WM_NCPAINT);
  607. }
  608. }
  609. void CXTFlatEdit::OnKillFocus(CWnd* pNewWnd)
  610. {
  611. CXTEdit::OnKillFocus(pNewWnd);
  612. if (IsFlat())
  613. {
  614. m_bHasFocus = FALSE;
  615. Invalidate();
  616. SendMessage(WM_NCPAINT);
  617. }
  618. }