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.

73 lines
1.7 KiB

  1. // StaticBold.h : Declaration of the CStaticBold
  2. #ifndef __STATICBOLD_H_
  3. #define __STATICBOLD_H_
  4. #include "resource.h" // main symbols
  5. #include <atlhost.h>
  6. #include <atlapp.h>
  7. #include <atlctrls.h>
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CStaticBold
  10. class CStaticBold : public CWindowImpl<CStaticBold>
  11. {
  12. private:
  13. HFONT m_hFont;
  14. public:
  15. DECLARE_WND_SUPERCLASS( _T("CStaticBold"), _T("Static") )
  16. BEGIN_MSG_MAP(CStaticBold)
  17. MESSAGE_HANDLER(OCM_CTLCOLORSTATIC, OnCtlColor)
  18. MESSAGE_HANDLER( WM_DESTROY, OnDestroy) // not a reflected message
  19. DEFAULT_REFLECTION_HANDLER()
  20. END_MSG_MAP()
  21. CStaticBold():m_hFont(NULL),m_bBold(TRUE),m_bCaption(FALSE)
  22. {
  23. }
  24. LRESULT OnDestroy( UINT, WPARAM, LPARAM, BOOL& )
  25. {
  26. if( m_hFont )
  27. DeleteObject( m_hFont );
  28. return 0;
  29. }
  30. LRESULT OnCtlColor( UINT, WPARAM wParam, LPARAM, BOOL& )
  31. {
  32. // notify bit must be set to get STN_* notifications
  33. ModifyStyle( 0, SS_NOTIFY );
  34. HBRUSH hBr = NULL;
  35. if( (GetStyle() & 0xff) <= SS_RIGHT )
  36. {
  37. CDCHandle dcHandle = (HDC)wParam;
  38. if( !m_hFont )
  39. {
  40. LOGFONT lf;
  41. GetObject(GetFont(), sizeof(lf), &lf );
  42. if (m_bBold == TRUE)
  43. lf.lfWeight = FW_BOLD;
  44. if (m_bCaption == TRUE)
  45. {
  46. lf.lfHeight = -MulDiv(15, dcHandle.GetDeviceCaps(LOGPIXELSY), 72);
  47. }
  48. m_hFont = CreateFontIndirect( &lf );
  49. }
  50. dcHandle.SelectFont(m_hFont);
  51. dcHandle.SetBkMode(TRANSPARENT);
  52. dcHandle.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
  53. hBr = (HBRUSH)GetStockObject(HOLLOW_BRUSH);
  54. }
  55. return (LRESULT)hBr;
  56. }
  57. BOOL m_bBold;
  58. BOOL m_bCaption;
  59. };
  60. #endif //__STATICBOLD_H_