Code:
CreateWindow( "Button", "My Button", WS_CHILD|WS_VISIBLE, 10, 10, 60, 30, hwndParent, (HMENU)MY_BUTTON_ID, hInstance, NULL );
...
case WM_DRAWITEM: {
DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)lParam;
RECT rc;
GetWindowRect( hwnd, &rc );
rc.right-=rc.left
rc.bottom-=rc.top;
rc.top = rc.left = 0;
HBRUSH red = CreateSolidBrush( RGB( 255,0,0 ) );
HBRUSH green = CreateSolidBrush( RGB( 0,255,0 ) );
if ( dis->itemAction&ODA_FOCUS && dis->itemStat&ODS_FOCUS ) {
FillRect( dis->hDC, &rc, green );
}else if ( dis->itemAction&ODA_FOCUS ) {
FillRect( dis->hDC, &rc, red );
}
SetBkMode( dis->hDC, TRANSPARENT );
int txtLen = GetWindowTextLength( hwnd );
char buff[txtLen];
GetWindowText( hwnd, buff, txtLen);
DrawText( dis->hDC, buff, txtLen, &rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE );
DeleteObject( red );
DeleteObject( green );
return TRUE;
}
...
That's a pretty lame example, if it even works... There are a few things that you would not do there, like use GetWindowRect() normally because it supplies a rect but I wasn't sure if it was client or screen so I didn't use it.. That is essentially all you need though.
I'm not sure if the dc is released for you either, the documentation didn't say. Probably best to do that as well.