im using simple button in win32 application and i like to change its color and text but i can't find from all searching in google how to do it. i have this code that represent a button: this is in the rc file :
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG1 DIALOG 0, 0, 273, 209
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Win32 demo"
FONT 8, "Ms Shell Dlg"
{
DEFPUSHBUTTON "My Button1 ", IDOK, 59, 176, 69, 14
PUSHBUTTON "Log Off", IDC_BUTTON1, 155, 175, 54, 14
}
and in the main cpp file i only triger simple Massegebox alerts
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
MessageBox(NULL, L"IDOK button pressed!", L"Pinky says...", MB_OK | MB_ICONEXCLAMATION);
break;
case IDC_BUTTON1:
MessageBox(NULL, L"IDC_BUTTON1 button pressed!",L"Pinky says...", MB_OK | MB_ICONEXCLAMATION);
break;
break;
}
break;
where and how i change the buttons background colors and text?
There are several approaches you could take for this:
The easiest way is just to handle WM_CTLCOLORBTN.
You can't, or at least you can't do so simply. If you want a coloured button then you need to set the owner-draw style and draw it yourself. Plain old buttons don't have customisable colours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With