J
Das ist seit XP nicht mehr so einfach, da hier ja Themes und Styles verwendet werden... aber siehe
http://msdn.microsoft.com/library/en-us/dnwxp/html/xptheming.asp
Ganz grob solltest Du wie folgt vorgehen:
HTHEME hTheme = NULL;
hTheme = OpenThemeData(hwndButton, L"Button");
...
DrawMyControl(hDC, hwndButton, hTheme, iState);
...
if (hTheme)
{
CloseTheme(hTheme);
}
void DrawMyControl(HDC hDC, HWND hwndButton, HTHEME hTheme, int iState)
{
RECT rc, rcContent;
TCHAR szButtonText[255];
HRESULT hr;
size_t cch;
GetWindowRect(hwndButton, &rc);
GetWindowText(hwndButton, szButtonText,
(sizeof(szButtonText)/sizeof(szButtonText[0])+1));
hr = StringCchLength(szButtonText,
(sizeof(szButtonText)/sizeof(szButtonText[0])), &cch);
if (hTheme)
{
hr = DrawThemeBackground(hTheme, hDC, BP_BUTTON,
iState, &rc, 0);
// Always check your result codes.
hr = GetThemeBackgroundContentRect(hTheme, hDC,
BP_BUTTON, iState, &rc, &rcContent);
hr = DrawThemeText(hTheme, hDC, BP_BUTTON, iState,
szButtonText, cch,
DT_CENTER | DT_VCENTER | DT_SINGLELINE,
0, &rcContent);
}
else
{
// Draw the control without using visual styles.
}
}