GroupBoxExt.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // CheckBoxExt.cpp: implementation of the CGroupBoxExt class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "GroupBoxExt.h"
  6. #include "library.h"
  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[]=__FILE__;
  10. #define new DEBUG_NEW
  11. #endif
  12. WNDPROC CGroupBoxExt::m_cWndProc = NULL;
  13. int CGroupBoxExt::pos =0;
  14. //////////////////////////////////////////////////////////////////////
  15. // Construction/Destruction
  16. //////////////////////////////////////////////////////////////////////
  17. LRESULT CGroupBoxExt::DefWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
  18. {
  19. CPoint point;
  20. LRESULT lReturn;
  21. switch( message )
  22. {
  23. case WM_ERASEBKGND:
  24. return 1;
  25. /* case WM_SIZE:
  26. CallWindowProc( m_cWndProc, hWnd, message, wParam, lParam );
  27. OnPaint( hWnd );
  28. return 1;*/
  29. case WM_PAINT:
  30. CallWindowProc( m_cWndProc, hWnd, message, wParam, lParam );
  31. OnPaint( hWnd );
  32. return 1;
  33. case WM_SETTEXT: // 设置窗口文本
  34. lReturn = (LONG) CallWindowProc( m_cWndProc, hWnd, message, wParam, lParam );
  35. OnPaint( hWnd );
  36. return lReturn;
  37. default:
  38. break;
  39. }
  40. return CallWindowProc( m_cWndProc, hWnd, message, wParam, lParam );
  41. }
  42. void CGroupBoxExt::OnPaint( HWND hWnd )
  43. {
  44. RECT Rect;
  45. char szTemp[256];
  46. HANDLE hHandle,hBrush;
  47. DWORD dwStyle;
  48. //取设置句柄
  49. MEMDCXP Mdcxp;
  50. HDC hDC ;
  51. // 获取内存兼容设备场景
  52. Mdcxp.hWnd = hWnd;
  53. Mdcxp.bTransfer = FALSE;
  54. Mdcxp.hBitmap = NULL;
  55. g_bDrawBk=1;
  56. GetMemDCXP(&Mdcxp);
  57. hDC = Mdcxp.hMemDC;
  58. // 获取窗口大小
  59. GetWindowRect(hWnd, &Rect);
  60. Rect.right -= Rect.left;
  61. Rect.bottom -= Rect.top;
  62. Rect.left = Rect.top = 0;
  63. // DeleteObject(hHandle);
  64. // ::SetBkColor (hDC, g_crDialogbkColor );
  65. // 画最外面的框,颜色与系统按钮颜色一直
  66. hBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH));
  67. hHandle=SelectObject(hDC, g_frameedgepen);
  68. RoundRect(hDC, Rect.left,Rect.top+6,Rect.right,Rect.bottom,6,6);
  69. SelectObject(hDC, hBrush);
  70. SelectObject(hDC, hHandle);
  71. // 写文字
  72. dwStyle = (DWORD)GetWindowLong(hWnd, GWL_STYLE);
  73. if (GetWindowText(hWnd, szTemp, sizeof(szTemp)))
  74. {
  75. SetTextColor(hDC,
  76. ((g_wndstatelist.ElementAt (pos) & CXPS_INDETERMINATE) || (g_wndstatelist.ElementAt (pos) & CXPS_DISABLED)) ?
  77. 0x0094A2A5: 0x00000000);
  78. hHandle = (HANDLE) SelectObject(hDC,
  79. (HGDIOBJ) SendMessage(hWnd, WM_GETFONT, 0, 0));
  80. Rect.left+=5;
  81. DrawText(hDC, szTemp, -1, &Rect, DT_LEFT);
  82. SelectObject(hDC, (HGDIOBJ) hHandle);
  83. }
  84. Mdcxp.bTransfer = TRUE;
  85. ReleaseMemDCXP(&Mdcxp);
  86. }