radio button
-
Hi, is there any simple way how to change radio-button,check box and group box TEXT COLOR? OnCtlColor evidently doesn't work :-( Or some class to do it for me? Thanx
viliam
Try playing around with this...
ON_MESSAGE(WM_CTLCOLORSTATIC, OnCtlColorStatic)
...
// Just an example - there's stuff in this method you don't need
// and/or that isn't usedLRESULT CMyDlg::OnCtlColorStatic( WPARAM wParam, LPARAM lParam)
{
LRESULT lRet = Default();HDC hDC = (HDC)wParam;
HWND hWnd = (HWND)lParam;::SetTextColor(hDC, RGB(0x00,0xFF,0xFF));
//::SetBkColor(hDC, RGB(0xFF,0x00,0x00));
::SetBkMode(hDC, TRANSPARENT);//return lRet;
return (LRESULT)::GetStockObject(NULL_BRUSH);
}Don't ask me why WM_CTLCOLORSTATIC is used for radio buttons, check boxes, and group boxes :) Maybe because their text is static! Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Try playing around with this...
ON_MESSAGE(WM_CTLCOLORSTATIC, OnCtlColorStatic)
...
// Just an example - there's stuff in this method you don't need
// and/or that isn't usedLRESULT CMyDlg::OnCtlColorStatic( WPARAM wParam, LPARAM lParam)
{
LRESULT lRet = Default();HDC hDC = (HDC)wParam;
HWND hWnd = (HWND)lParam;::SetTextColor(hDC, RGB(0x00,0xFF,0xFF));
//::SetBkColor(hDC, RGB(0xFF,0x00,0x00));
::SetBkMode(hDC, TRANSPARENT);//return lRet;
return (LRESULT)::GetStockObject(NULL_BRUSH);
}Don't ask me why WM_CTLCOLORSTATIC is used for radio buttons, check boxes, and group boxes :) Maybe because their text is static! Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
thank you, it pushed me closer. I tried your code - and modified it and try it again: - it works to set backgroung color of all controls like radio, check and so on but only Text controls change text color. Radio-Button control, Check-box control even Group-box controls have still default color. I am getting this messages for them but SetTextColor function seems to have no effect called from there ??
viliam
-
thank you, it pushed me closer. I tried your code - and modified it and try it again: - it works to set backgroung color of all controls like radio, check and so on but only Text controls change text color. Radio-Button control, Check-box control even Group-box controls have still default color. I am getting this messages for them but SetTextColor function seems to have no effect called from there ??
viliam
It works for me on XP SP2 without the common controls 6.0.0.0 manifest entry (no themes). With the themes, radio buttons work, check boxes and group boxes do not. There's no guarantee any of this will work, especially with buttons. You have to experiment, and then hope it doesn't change in the future. Owner drawn or custom controls are the only guarantee... Good luck :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
It works for me on XP SP2 without the common controls 6.0.0.0 manifest entry (no themes). With the themes, radio buttons work, check boxes and group boxes do not. There's no guarantee any of this will work, especially with buttons. You have to experiment, and then hope it doesn't change in the future. Owner drawn or custom controls are the only guarantee... Good luck :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
clear now, i try to take manifest entry away and everything works fine. Now I wonder if is possible to skip manifest just for some part of program - i dont want to lose messageboxes and this better looking Win XP advantages stuff. Thank you for help and advices
viliam