Starting to dive into the WIN32 API (windows.h) and I've noticed that static text boxes have a grey BG and editable text boxes are white. I suppose this is because the static one is "greyed out" because it's to remain static and not change it's value.
The problem is I am using a static text box as a label to store user entered info into it via a WM_COMMAND. That all works just fine but it looks pretty ugly being greyed out on my white bg window. Is there a Label handle that I should use instead of using static text boxes? If not, how do I change the bg color of a static text field?
If what you are trying to do is change the background color of a "static" (label) control, you need to use the WM_CTLCOLORSTATIC message for that. Its just a bit complicated, but I can provide an example if you need it.
Yeah I'm not really seeing where to utilize this code with my own. As you can see I have the textLabel handle. Outside of that I'm not sure where to use this WM_CTLCOLORSTATIC code
Your program must have a Window Procedure. If you've created child window controls on your main program window, Windows (the Operating System) will send WM_CTLCOLORSTATIC messages to the parent window's Window Procedure. Here is what MSDN says (just as tath told you to look up)...
A static control, or an edit control that is read-only or disabled, sends the WM_CTLCOLORSTATIC message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the static control.
WM_CTLCOLORSTATIC
hdcStatic = (HDC) wParam; // handle to display context
hwndStatic = (HWND) lParam; // handle to static control
Parameters
hdcStatic
Value of wParam. Handle to the device context for the static control window.
hwndStatic
Value of lParam. Handle to the static control.
You need to handle the WM_CTLCOLORSTATIC message. In doing that you create an HBRUSH of the color you want to color the background of the control. That HBRUSH gets returned by the Window Procedure. As Windows messages go, its a bit unusual. That's why I said its a bit tricky and involved.
Sorry CGunn86. Windows Api coding, as well as using any class framework code to wrap it in the hope of making it easier, takes awhile to master. By 'awhile', I mean like x number of months, where x is typically something like 6. Would you like if I posted a very simple and compilable program with just a couple text boxes and labels on it that show how to do it?