Code:
struct
{
int iStyle ;
TCHAR * szText ;
}
button[] =
{
BS_GROUPBOX, TEXT ("Colours"),
WS_CHILD | BS_AUTORADIOBUTTON, TEXT ("Red"),
WS_CHILD | BS_AUTORADIOBUTTON, TEXT ("Green"),
WS_CHILD | BS_AUTORADIOBUTTON, TEXT ("Blue"),
} ;
#define NUM (sizeof button / sizeof button[0])
LRESULT CALLBACK HelloWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps ;
static RECT rect;
static int cxChar, cyChar ;
HDC hdc;
static COLORREF colours[3]={RGB(255,0,0),RGB(0,255,0),RGB(0,0,255)};
static TCHAR* colour[3] = {TEXT("Red"), TEXT("Green"), TEXT("Blue")};
static HWND hwndButton[NUM] ;
int i;
switch (message)
{
case WM_CREATE:
cxChar = LOWORD (GetDialogBaseUnits ()) ;
cyChar = HIWORD (GetDialogBaseUnits ()) ;
for (i = 0 ; i < NUM ; i++)
hwndButton[i] = CreateWindow ( TEXT("button"),
button[i].szText,
WS_CHILD | WS_VISIBLE | button[i].iStyle,
cxChar, cyChar * (1 + 2 * i),
20 * cxChar, 7 * cyChar / 4,
hwnd, (HMENU) i,
((LPCREATESTRUCT) lParam)->hInstance, NULL) ;
return 0;
case WM_PAINT :
InvalidateRect (hwnd, &rect, TRUE) ;
hdc = BeginPaint (hwnd, &ps) ;
SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)) ;
SetBkMode (hdc, TRANSPARENT) ;
EndPaint (hwnd, &ps) ;
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}