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.

671 lines
19 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1998
  4. *
  5. * TITLE: WIATEXTC.H
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 7/30/1999
  12. *
  13. * DESCRIPTION: Highlighted static control. Like a static, but acts like a
  14. * hyperlink
  15. *
  16. *
  17. * Use the following values in the dialog resource editor to put it in a dialog:
  18. *
  19. * Style:
  20. * Hyperlink: 0x50010000 (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
  21. * IconStatic: 0x50010008 (WS_CHILD|WS_VISIBLE|0x00000008)
  22. * Class: WiaTextControl
  23. * ExStyle: 0x00000000
  24. *
  25. * Register before use using:
  26. * CWiaTextControl::RegisterClass(g_hInstance);
  27. *
  28. *******************************************************************************/
  29. #ifndef __WIATEXTC_H_INCLUDED
  30. #define __WIATEXTC_H_INCLUDED
  31. #include <windows.h>
  32. #include <windowsx.h>
  33. #include "simcrack.h"
  34. #include "miscutil.h"
  35. #define WIATEXT_STATIC_CLASSNAMEW L"WiaTextControl"
  36. #define WIATEXT_STATIC_CLASSNAMEA "WiaTextControl"
  37. #ifdef UNICODE
  38. #define WIATEXT_STATIC_CLASSNAME WIATEXT_STATIC_CLASSNAMEW
  39. #else
  40. #define WIATEXT_STATIC_CLASSNAME WIATEXT_STATIC_CLASSNAMEA
  41. #endif
  42. // Styles
  43. #define WTS_SINGLELINE 0x00000001 // Single line
  44. #define WTS_PATHELLIPSIS 0x00000002 // Use to truncate string in the middle
  45. #define WTS_ENDELLIPSIS 0x00000004 // Use to truncate string at the end
  46. #define WTS_ICONSTATIC 0x00000008 // Static control with an icon
  47. #define WTS_RIGHT 0x00000010 // Right aligned
  48. // Undefined in VC6 SDK
  49. #ifndef COLOR_HOTLIGHT
  50. #define COLOR_HOTLIGHT 26
  51. #endif
  52. // Undefined in VC6 SDK
  53. #ifndef IDC_HAND
  54. #define IDC_HAND MAKEINTRESOURCE(32649)
  55. #endif
  56. #define DEFAULT_ICON_STATIC_BACKGROUND_COLOR GetSysColor(COLOR_3DFACE)
  57. #define DEFAULT_ICON_STATIC_FOREGROUND_COLOR GetSysColor(COLOR_WINDOWTEXT)
  58. #define WM_WIA_STATIC_SETICON (WM_USER+1)
  59. class CWiaTextControl
  60. {
  61. private:
  62. enum
  63. {
  64. StateNormal = 0,
  65. StateHover = 1,
  66. StateFocus = 2,
  67. StateDisabled = 4
  68. };
  69. // Timer IDs
  70. enum
  71. {
  72. IDT_MOUSEPOS = 1
  73. };
  74. enum
  75. {
  76. IconMargin = 0
  77. };
  78. private:
  79. HWND m_hWnd;
  80. COLORREF m_crColorNormal;
  81. COLORREF m_crColorHover;
  82. COLORREF m_crColorFocus;
  83. COLORREF m_crColorDisabled;
  84. COLORREF m_crForegroundColor;
  85. RECT m_rcTextWidth;
  86. HFONT m_hFont;
  87. int m_CurrentState;
  88. RECT m_rcHighlight;
  89. HCURSOR m_hHandCursor;
  90. HBITMAP m_hBitmap;
  91. SIZE m_sizeWindow;
  92. bool m_bIconStaticMode;
  93. HBRUSH m_hBackgroundBrush;
  94. HICON m_hIcon;
  95. private:
  96. CWiaTextControl(void);
  97. CWiaTextControl( const CWiaTextControl & );
  98. CWiaTextControl &operator=( const CWiaTextControl & );
  99. private:
  100. CWiaTextControl( HWND hWnd )
  101. : m_hWnd(hWnd),
  102. m_crColorNormal(GetSysColor(COLOR_HOTLIGHT)),
  103. m_crColorHover(RGB(255,0,0)),
  104. m_crColorFocus(GetSysColor(COLOR_HOTLIGHT)),
  105. m_crColorDisabled(GetSysColor(COLOR_GRAYTEXT)),
  106. m_crForegroundColor(DEFAULT_ICON_STATIC_FOREGROUND_COLOR),
  107. m_hFont(NULL),
  108. m_hHandCursor(NULL),
  109. m_hBitmap(NULL),
  110. m_hBackgroundBrush(NULL),
  111. m_hIcon(NULL),
  112. m_CurrentState(StateNormal),
  113. m_bIconStaticMode(false)
  114. {
  115. CreateNewFont(reinterpret_cast<HFONT>(GetStockObject(SYSTEM_FONT)));
  116. }
  117. ~CWiaTextControl(void)
  118. {
  119. m_hWnd = NULL;
  120. if (m_hIcon)
  121. {
  122. DestroyIcon(m_hIcon);
  123. m_hIcon = NULL;
  124. }
  125. if (m_hHandCursor)
  126. {
  127. m_hHandCursor = NULL;
  128. }
  129. if (m_hFont)
  130. {
  131. DeleteObject(m_hFont);
  132. m_hFont = NULL;
  133. }
  134. if (m_hBitmap)
  135. {
  136. DeleteObject(m_hBitmap);
  137. m_hBitmap = NULL;
  138. }
  139. if (m_hBackgroundBrush)
  140. {
  141. DeleteObject(m_hBackgroundBrush);
  142. m_hBackgroundBrush = NULL;
  143. }
  144. }
  145. COLORREF GetCurrentColor(void)
  146. {
  147. if (StateDisabled & m_CurrentState)
  148. return m_crColorDisabled;
  149. if (StateHover & m_CurrentState)
  150. return m_crColorHover;
  151. if (StateFocus & m_CurrentState)
  152. return m_crColorFocus;
  153. else return m_crColorNormal;
  154. }
  155. void CreateNewFont( HFONT hFont )
  156. {
  157. if (m_hFont)
  158. {
  159. DeleteObject(m_hFont);
  160. m_hFont = NULL;
  161. }
  162. if (hFont)
  163. {
  164. LOGFONT lf;
  165. if (GetObject( hFont, sizeof(LOGFONT), &lf ))
  166. {
  167. lf.lfUnderline = TRUE;
  168. m_hFont = CreateFontIndirect( &lf );
  169. }
  170. }
  171. }
  172. private:
  173. LRESULT OnEraseBkgnd( WPARAM wParam, LPARAM lParam )
  174. {
  175. RedrawBitmap(false);
  176. return TRUE;
  177. }
  178. LRESULT OnSetIcon( WPARAM, LPARAM lParam )
  179. {
  180. if (m_hIcon)
  181. {
  182. DestroyIcon(m_hIcon);
  183. m_hIcon = NULL;
  184. }
  185. m_hIcon = reinterpret_cast<HICON>(lParam);
  186. RedrawBitmap(true);
  187. return 0;
  188. }
  189. LRESULT OnSetFocus( WPARAM, LPARAM )
  190. {
  191. m_CurrentState |= StateFocus;
  192. RedrawBitmap(true);
  193. return 0;
  194. }
  195. LRESULT OnKillFocus( WPARAM, LPARAM )
  196. {
  197. m_CurrentState &= ~StateFocus;
  198. RedrawBitmap(true);
  199. return 0;
  200. }
  201. void DrawHyperlinkControl( HDC hDC )
  202. {
  203. RECT rcClient;
  204. GetClientRect(m_hWnd,&rcClient);
  205. // Make sure we start with a fresh rect
  206. ZeroMemory( &m_rcHighlight, sizeof(m_rcHighlight) );
  207. HBRUSH hbrBackground = NULL;
  208. HWND hWndParent = GetParent(m_hWnd);
  209. if (hWndParent)
  210. hbrBackground = reinterpret_cast<HBRUSH>(SendMessage(hWndParent,WM_CTLCOLORSTATIC,reinterpret_cast<WPARAM>(hDC),reinterpret_cast<LPARAM>(m_hWnd)));
  211. if (!hbrBackground)
  212. hbrBackground = reinterpret_cast<HBRUSH>(GetSysColorBrush(COLOR_WINDOW));
  213. FillRect( hDC, &rcClient, hbrBackground );
  214. LRESULT nWindowTextLength = SendMessage(m_hWnd,WM_GETTEXTLENGTH,0,0);
  215. LPTSTR pszWindowText = new TCHAR[nWindowTextLength+1];
  216. if (pszWindowText)
  217. {
  218. if (SendMessage( m_hWnd, WM_GETTEXT, nWindowTextLength+1, reinterpret_cast<LPARAM>(pszWindowText) ) )
  219. {
  220. int nDrawTextFlags = DT_WORDBREAK|DT_TOP|DT_NOPREFIX;
  221. INT_PTR nStyle = GetWindowLongPtr( m_hWnd, GWL_STYLE );
  222. if (nStyle & WTS_SINGLELINE)
  223. nDrawTextFlags |= DT_SINGLELINE;
  224. if (nStyle & WTS_RIGHT)
  225. nDrawTextFlags |= DT_RIGHT;
  226. else nDrawTextFlags |= DT_LEFT;
  227. if (nStyle & WTS_PATHELLIPSIS)
  228. nDrawTextFlags |= DT_PATH_ELLIPSIS | DT_SINGLELINE;
  229. if (nStyle & WTS_ENDELLIPSIS)
  230. nDrawTextFlags |= DT_END_ELLIPSIS | DT_SINGLELINE;
  231. m_rcHighlight = rcClient;
  232. int nOldBkMode = SetBkMode( hDC, TRANSPARENT );
  233. HFONT hOldFont = NULL;
  234. if (m_hFont)
  235. hOldFont = reinterpret_cast<HFONT>(SelectObject( hDC, m_hFont ));
  236. COLORREF crOldColor = SetTextColor( hDC, GetCurrentColor() );
  237. InflateRect(&m_rcHighlight,-1,-1);
  238. DrawTextEx( hDC, pszWindowText, -1, &m_rcHighlight, nDrawTextFlags, NULL );
  239. SetTextColor( hDC, crOldColor );
  240. SetBkMode( hDC, nOldBkMode );
  241. DrawTextEx( hDC, pszWindowText, -1, &m_rcHighlight, DT_CALCRECT|nDrawTextFlags , NULL );
  242. InflateRect(&m_rcHighlight,1,1);
  243. if (nStyle & WTS_RIGHT)
  244. {
  245. m_rcHighlight.left = rcClient.right - WiaUiUtil::Min<int>(rcClient.right,m_rcHighlight.right);
  246. m_rcHighlight.right = rcClient.right;
  247. m_rcHighlight.bottom = WiaUiUtil::Min<int>(rcClient.bottom,m_rcHighlight.bottom);
  248. }
  249. else
  250. {
  251. m_rcHighlight.right = WiaUiUtil::Min<int>(rcClient.right,m_rcHighlight.right);
  252. m_rcHighlight.bottom = WiaUiUtil::Min<int>(rcClient.bottom,m_rcHighlight.bottom);
  253. }
  254. if (m_CurrentState & StateFocus)
  255. DrawFocusRect( hDC, &m_rcHighlight );
  256. if (m_hFont)
  257. SelectObject( hDC, hOldFont );
  258. }
  259. delete[] pszWindowText;
  260. }
  261. }
  262. void DrawIconStatic( HDC hDC )
  263. {
  264. RECT rcClient;
  265. GetClientRect( m_hWnd, &rcClient );
  266. FrameRect( hDC, &rcClient, GetSysColorBrush( COLOR_WINDOWFRAME ) );
  267. InflateRect( &rcClient, -1, -1 );
  268. FillRect( hDC, &rcClient, m_hBackgroundBrush );
  269. InflateRect( &rcClient, -1, -1 );
  270. CSimpleString str;
  271. str.GetWindowText(m_hWnd);
  272. if (str.Length())
  273. {
  274. int nDrawTextFlags = DT_WORDBREAK|DT_TOP|DT_LEFT|DT_NOPREFIX;
  275. INT_PTR nStyle = GetWindowLongPtr( m_hWnd, GWL_STYLE );
  276. if (nStyle & WTS_SINGLELINE)
  277. nDrawTextFlags |= DT_SINGLELINE | DT_VCENTER;
  278. if (nStyle & WTS_PATHELLIPSIS)
  279. nDrawTextFlags |= DT_PATH_ELLIPSIS | DT_SINGLELINE;
  280. if (nStyle & WTS_ENDELLIPSIS)
  281. nDrawTextFlags |= DT_END_ELLIPSIS | DT_SINGLELINE;
  282. if (m_hIcon)
  283. {
  284. int nIconMargin;
  285. // Center the icon vertically
  286. if (nStyle & WTS_SINGLELINE)
  287. {
  288. nIconMargin = (WiaUiUtil::RectHeight(rcClient) - GetSystemMetrics(SM_CYSMICON)) / 2;
  289. }
  290. else
  291. {
  292. nIconMargin = IconMargin;
  293. }
  294. DrawIconEx( hDC, rcClient.left+nIconMargin, rcClient.top+nIconMargin, m_hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL );
  295. rcClient.left += rcClient.left + GetSystemMetrics(SM_CXSMICON) + nIconMargin*2;
  296. }
  297. int nOldBkMode = SetBkMode( hDC, TRANSPARENT );
  298. HFONT hOldFont = NULL, hFont = (HFONT)SendMessage( m_hWnd, WM_GETFONT, 0, 0 );
  299. if (!hFont)
  300. hFont = (HFONT)SendMessage( GetParent(m_hWnd), WM_GETFONT, 0, 0 );
  301. if (hFont)
  302. hOldFont = SelectFont( hDC, hFont );
  303. COLORREF crOldColor = SetTextColor( hDC, m_crForegroundColor );
  304. DrawTextEx( hDC, const_cast<LPTSTR>(str.String()), str.Length(), &rcClient, nDrawTextFlags, NULL );
  305. SetTextColor( hDC, crOldColor );
  306. if (hOldFont)
  307. SelectFont( hDC, hOldFont );
  308. SetBkMode( hDC, nOldBkMode );
  309. }
  310. }
  311. void RedrawBitmap( bool bRedraw )
  312. {
  313. if (m_hBitmap)
  314. {
  315. HDC hDC = GetDC(m_hWnd);
  316. if (hDC)
  317. {
  318. HDC hMemDC = CreateCompatibleDC(hDC);
  319. if (hMemDC)
  320. {
  321. HBITMAP hOldBitmap = SelectBitmap( hMemDC, m_hBitmap );
  322. if (!m_bIconStaticMode)
  323. DrawHyperlinkControl( hMemDC );
  324. else DrawIconStatic( hMemDC );
  325. SelectBitmap( hMemDC, hOldBitmap );
  326. DeleteDC(hMemDC);
  327. }
  328. ReleaseDC(m_hWnd, hDC);
  329. }
  330. }
  331. if (bRedraw)
  332. {
  333. InvalidateRect( m_hWnd, NULL, FALSE );
  334. UpdateWindow( m_hWnd );
  335. }
  336. }
  337. void CheckMousePos(void)
  338. {
  339. POINT pt;
  340. GetCursorPos(&pt);
  341. MapWindowPoints( NULL, m_hWnd, &pt, 1 );
  342. if (PtInRect( &m_rcHighlight, pt ))
  343. {
  344. if ((m_CurrentState & StateHover)==0)
  345. {
  346. m_CurrentState |= StateHover;
  347. RedrawBitmap(true);
  348. }
  349. }
  350. else
  351. {
  352. if (m_CurrentState & StateHover)
  353. {
  354. m_CurrentState &= ~StateHover;
  355. RedrawBitmap(true);
  356. }
  357. }
  358. }
  359. LRESULT OnTimer( WPARAM wParam, LPARAM lParam )
  360. {
  361. if (wParam == IDT_MOUSEPOS)
  362. {
  363. CheckMousePos();
  364. return 0;
  365. }
  366. return DefWindowProc( m_hWnd, WM_TIMER, wParam, lParam );
  367. }
  368. LRESULT OnMove( WPARAM wParam, LPARAM lParam )
  369. {
  370. CheckMousePos();
  371. return 0;
  372. }
  373. LRESULT OnSize( WPARAM wParam, LPARAM lParam )
  374. {
  375. if (SIZE_RESTORED == wParam || SIZE_MAXIMIZED == wParam)
  376. {
  377. if (m_hBitmap)
  378. {
  379. DeleteBitmap(m_hBitmap);
  380. m_hBitmap = NULL;
  381. }
  382. HDC hDC = GetDC(m_hWnd);
  383. if (hDC)
  384. {
  385. m_sizeWindow.cx = LOWORD(lParam);
  386. m_sizeWindow.cy = HIWORD(lParam);
  387. m_hBitmap = CreateCompatibleBitmap( hDC, LOWORD(lParam), HIWORD(lParam) );
  388. ReleaseDC(m_hWnd,hDC);
  389. }
  390. }
  391. RedrawBitmap(true);
  392. CheckMousePos();
  393. return 0;
  394. }
  395. LRESULT OnCreate( WPARAM, LPARAM )
  396. {
  397. if (!IsWindowEnabled(m_hWnd))
  398. m_CurrentState |= StateDisabled;
  399. INT_PTR nStyle = GetWindowLongPtr( m_hWnd, GWL_STYLE );
  400. if (nStyle & WTS_ICONSTATIC)
  401. m_bIconStaticMode = true;
  402. SetTimer( m_hWnd, IDT_MOUSEPOS, 56, NULL );
  403. m_hHandCursor = LoadCursor( NULL, IDC_HAND );
  404. m_hBackgroundBrush = CreateSolidBrush(DEFAULT_ICON_STATIC_BACKGROUND_COLOR);
  405. return 0;
  406. }
  407. LRESULT OnSetFont( WPARAM wParam, LPARAM lParam )
  408. {
  409. LRESULT lRes = DefWindowProc( m_hWnd, WM_SETFONT, wParam, lParam );
  410. CreateNewFont(reinterpret_cast<HFONT>(wParam));
  411. RedrawBitmap(LOWORD(lParam) != 0);
  412. return lRes;
  413. }
  414. LRESULT OnSetText( WPARAM wParam, LPARAM lParam )
  415. {
  416. LRESULT lRes = DefWindowProc( m_hWnd, WM_SETTEXT, wParam, lParam );
  417. RedrawBitmap(true);
  418. return lRes;
  419. }
  420. LRESULT OnGetDlgCode( WPARAM, LPARAM )
  421. {
  422. if (!m_bIconStaticMode)
  423. return DLGC_BUTTON;
  424. return DLGC_STATIC;
  425. }
  426. void FireNotification( int nCode )
  427. {
  428. HWND hwndParent = GetParent(m_hWnd);
  429. if (hwndParent)
  430. {
  431. SendNotifyMessage( hwndParent, WM_COMMAND, MAKEWPARAM(GetWindowLongPtr(m_hWnd,GWLP_ID),nCode), reinterpret_cast<LPARAM>(m_hWnd) );
  432. }
  433. }
  434. LRESULT OnKeyDown( WPARAM wParam, LPARAM lParam )
  435. {
  436. if (!m_bIconStaticMode)
  437. {
  438. if (wParam == VK_SPACE)
  439. FireNotification(BN_CLICKED);
  440. else if (wParam == VK_RETURN)
  441. FireNotification(BN_CLICKED);
  442. }
  443. return 0;
  444. }
  445. LRESULT OnNcHitTest( WPARAM, LPARAM lParam )
  446. {
  447. if (!m_bIconStaticMode)
  448. {
  449. POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
  450. MapWindowPoints( NULL, m_hWnd, &pt, 1 );
  451. if (PtInRect( &m_rcHighlight, pt ))
  452. {
  453. return HTCLIENT;
  454. }
  455. }
  456. return HTTRANSPARENT;
  457. }
  458. LRESULT OnEnable( WPARAM wParam, LPARAM lParam )
  459. {
  460. if (wParam)
  461. {
  462. m_CurrentState &= ~StateDisabled;
  463. }
  464. else
  465. {
  466. m_CurrentState |= StateDisabled;
  467. }
  468. RedrawBitmap(true);
  469. return 0;
  470. }
  471. LRESULT OnLButtonDown( WPARAM wParam, LPARAM lParam )
  472. {
  473. if (!m_bIconStaticMode)
  474. {
  475. POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
  476. if (PtInRect(&m_rcHighlight,pt))
  477. {
  478. SetFocus(m_hWnd);
  479. SetCapture(m_hWnd);
  480. }
  481. }
  482. return 0;
  483. }
  484. LRESULT OnLButtonUp( WPARAM wParam, LPARAM lParam )
  485. {
  486. if (!m_bIconStaticMode)
  487. {
  488. if (GetCapture() == m_hWnd)
  489. {
  490. ReleaseCapture();
  491. POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
  492. if (PtInRect(&m_rcHighlight,pt))
  493. {
  494. FireNotification(BN_CLICKED);
  495. }
  496. }
  497. }
  498. return 0;
  499. }
  500. LRESULT OnSetCursor( WPARAM wParam, LPARAM lParam )
  501. {
  502. if (!m_bIconStaticMode)
  503. {
  504. POINT pt;
  505. GetCursorPos(&pt);
  506. MapWindowPoints( NULL, m_hWnd, &pt, 1 );
  507. if (PtInRect( &m_rcHighlight, pt ))
  508. {
  509. SetCursor( m_hHandCursor );
  510. return 0;
  511. }
  512. }
  513. return DefWindowProc( m_hWnd, WM_SETCURSOR, wParam, lParam );
  514. }
  515. LRESULT OnStyleChanged( WPARAM wParam, LPARAM lParam )
  516. {
  517. RedrawBitmap(true);
  518. return 0;
  519. }
  520. LRESULT OnSysColorChange( WPARAM wParam, LPARAM lParam )
  521. {
  522. m_crColorNormal = GetSysColor(COLOR_HOTLIGHT);
  523. m_crColorHover = RGB(255,0,0);
  524. m_crColorFocus = GetSysColor(COLOR_HOTLIGHT);
  525. m_crColorDisabled = GetSysColor(COLOR_GRAYTEXT);
  526. RedrawBitmap(true);
  527. return 0;
  528. }
  529. LRESULT OnPaint( WPARAM wParam, LPARAM lParam )
  530. {
  531. PAINTSTRUCT ps;
  532. HDC hDC = BeginPaint( m_hWnd, &ps );
  533. if (hDC)
  534. {
  535. if (ps.fErase)
  536. {
  537. RedrawBitmap(false);
  538. }
  539. if (m_hBitmap)
  540. {
  541. HDC hMemDC = CreateCompatibleDC(hDC);
  542. if (hMemDC)
  543. {
  544. HBITMAP hOldBitmap = SelectBitmap(hMemDC,m_hBitmap);
  545. BitBlt( hDC, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right-ps.rcPaint.left, ps.rcPaint.bottom-ps.rcPaint.top, hMemDC, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY );
  546. SelectBitmap(hMemDC,hOldBitmap);
  547. DeleteDC(hMemDC);
  548. }
  549. }
  550. EndPaint( m_hWnd, &ps );
  551. }
  552. return 0;
  553. }
  554. public:
  555. static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  556. {
  557. SC_BEGIN_MESSAGE_HANDLERS(CWiaTextControl)
  558. {
  559. SC_HANDLE_MESSAGE( WM_CREATE, OnCreate );
  560. SC_HANDLE_MESSAGE( WM_SETFONT, OnSetFont );
  561. SC_HANDLE_MESSAGE( WM_PAINT, OnPaint );
  562. SC_HANDLE_MESSAGE( WM_SETFOCUS, OnSetFocus );
  563. SC_HANDLE_MESSAGE( WM_KILLFOCUS, OnKillFocus );
  564. SC_HANDLE_MESSAGE( WM_SETTEXT, OnSetText );
  565. SC_HANDLE_MESSAGE( WM_GETDLGCODE, OnGetDlgCode );
  566. SC_HANDLE_MESSAGE( WM_ERASEBKGND, OnEraseBkgnd );
  567. SC_HANDLE_MESSAGE( WM_TIMER, OnTimer );
  568. SC_HANDLE_MESSAGE( WM_SIZE, OnSize );
  569. SC_HANDLE_MESSAGE( WM_MOVE, OnMove );
  570. SC_HANDLE_MESSAGE( WM_KEYDOWN, OnKeyDown );
  571. SC_HANDLE_MESSAGE( WM_LBUTTONDOWN, OnLButtonDown );
  572. SC_HANDLE_MESSAGE( WM_LBUTTONUP, OnLButtonUp );
  573. SC_HANDLE_MESSAGE( WM_SETCURSOR, OnSetCursor );
  574. SC_HANDLE_MESSAGE( WM_ENABLE, OnEnable );
  575. SC_HANDLE_MESSAGE( WM_NCHITTEST, OnNcHitTest );
  576. SC_HANDLE_MESSAGE( WM_STYLECHANGED, OnStyleChanged );
  577. SC_HANDLE_MESSAGE( WM_SYSCOLORCHANGE, OnSysColorChange );
  578. SC_HANDLE_MESSAGE( WM_WIA_STATIC_SETICON, OnSetIcon );
  579. }
  580. SC_END_MESSAGE_HANDLERS();
  581. }
  582. static BOOL RegisterClass( HINSTANCE hInstance )
  583. {
  584. WNDCLASSEX wcex;
  585. ZeroMemory(&wcex,sizeof(wcex));
  586. wcex.cbSize = sizeof(wcex);
  587. wcex.style = CS_DBLCLKS;
  588. wcex.lpfnWndProc = WndProc;
  589. wcex.hInstance = hInstance;
  590. wcex.lpszClassName = WIATEXT_STATIC_CLASSNAME;
  591. return ::RegisterClassEx( &wcex );
  592. }
  593. };
  594. #endif //__WIATEXTC_H_INCLUDED