I am creating a basic GUI with the Windows API and I am having a problem. It starts from the main window, which opens with a special background color that I set (RGB(230,230,230)). Then it displays the text in the upper left corner with static control.
settingstext = CreateWindow("STATIC",
"SETTINGS",
SS_LEFT | WS_CHILD,
12,
20,
100,
20,
hwnd,
NULL,
proginstance,
NULL);
ShowWindow(settingstext, 1);
This works, but when the text is displayed, I need to change the background to fit the main window, otherwise it just looks as if it is not mixing.
My question is: how do I do this? I am currently using the method below and it works, but I wanted to know if there is a way to set the background color somehow right after the function CreateWindowfor the static control without changing the system colors, and just apply it to that one control and nothing sends a message WM_CTLCOLORSTATIC. I experimented using the function GetDCand SetBkColoroutside the message loop, but nothing works.
case WM_CTLCOLORSTATIC:
{
HDC hdcStatic = (HDC) wParam;
SetTextColor(hdcStatic, RGB(0,0,0));
SetBkColor(hdcStatic, RGB(230,230,230));
return (INT_PTR)CreateSolidBrush(RGB(230,230,230));
}
I want to do this because ...
- I do not want to fill my message loop with functions that need to be called every time the window is redrawn.
- Whether the changes apply only to this static control.
I would be very grateful for any help that could be provided, at least pointing me in the right direction, thanks.