#ifndef __CeStaticGroup_h__
#define __CeStaticGroup_h__
#include "CeWnd.h"
#include "CeMisc.h"
#include "CeString.h"
class CeStaticGroup: public CeWnd
{
public:
void OnPaint(bool& bHandled)
{
bHandled = true;
PAINTSTRUCT ps;
HDC hDC = ::BeginPaint(*this, &ps);
// Set the proper font
HFONT hFontCreated = NULL;
HFONT hFont = (HFONT) ::SendMessage(m_hWnd, WM_GETFONT, 0, 0);
LOGFONT lf;
if (GetObject(hFont, sizeof LOGFONT, &lf))
{
lf.lfWeight = 900;
hFontCreated = CreateFontIndirect(&lf);
hFont = hFontCreated;
}
HFONT hFontOld = (HFONT) ::SelectObject(hDC, hFont);
//TEXTMETRIC tm;
//::GetTextMetrics(hDC, &tm);
//tm.tmHeight;
COLORREF clrStatic = GetSysColor(COLOR_STATIC);
#if defined(_WIN32_WCE_EMULATION)
COLORREF clrStaticText = GetSysColor(COLOR_BTNTEXT);
#else
COLORREF clrStaticText = GetSysColor(COLOR_STATICTEXT);
#endif
// Paint the text
CeRect rc;
CeString strWnd(m_hWnd);
GetClientRect(rc);
::SetTextColor(hDC, clrStaticText);
COLORREF cr = ::SetBkColor(hDC, clrStatic);
DrawText( hDC, strWnd, strWnd.GetLength(), rc,
DT_LEFT | DT_VCENTER | DT_SINGLELINE);
// Paint the line
CeSize sz;
::GetTextExtentPoint32(hDC, strWnd, strWnd.GetLength(), &sz);
rc.left += sz.cx;
::SetBkColor(hDC, clrStatic);
::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
::SetBkColor(hDC, clrStaticText);
rc.top += rc.Height()/2 - 1;
rc.bottom = rc.top + 2;
rc.left += 4;
::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
::SelectObject(hDC, hFontOld);
::SetBkColor(hDC, cr);
if (hFontCreated)
::DeleteObject(hFontCreated);
::EndPaint(*this, &ps);
}
};
#endif // __CeStaticGroup_h__