Static Control SS_WHITERECT

Greetings,

I am having a problem with the color of my static control.
The main window has a white background color, and the static control has a "read only" color.
My goal is for the static control to blend in, so I want to change the static control's color to white. I tried to use SS_WHITEFRAME and SS_WHITERECT to achieve it, but something else went wrong.

The static control had "Name:" as its text, but after applying SS_WHITERECT, the text was erased. Now, I have a static control with nothing as its text, and I can't write to it either.

Here is my static control:

hsClock = CreateWindowEx( 0,
"Static",
"Name:",
WS_CHILD | WS_VISIBLE | SS_CENTER | SS_WHITERECT,
5, 5, 50, 15,
hwnd,
0,
hInst,
0);

Any suggestions?

Thank you
[901 byte] By [kabilius] at [2007-11-20 8:47:51]
# 1 Re: Static Control SS_WHITERECT
Hello

SS_WHITEFRAME or SS_WHITERECT will result the static to show as a white colored bar without text. To do what you want is to process the WM_CTLCOLORSTATIC in your window procedure. This message is received by the parent window of the control when static control is to be colored.

and example would be:

switch(msg) {
case WM_CTLCOLORSTATIC: {
SetBkMode((HDC)wParam,TRANSPARENT);
return (long)CreateSolidBrush(0xFFFFFF);
}
}

I hope it helps.
Ali Imran at 2007-11-9 13:30:45 >
# 2 Re: Static Control SS_WHITERECT
Greetings Ali Imran,

Thank you for the detailed explanation; it led me to believe that SS_WHITERECT is useless. Does anyone know under what circumstances would one uses SS_WHITERECT?

Ali Imran,
Your code solved my problem!
Nevertheless, it gave me a truncating warning for type casting of HBRUSH to Long.
The weird thing is that after I replaced:
return (long)CreateSolidBrush(0xFFFFFF);
with
return (LRESULT)CreateSolidBrush(0xFFFFFF);
The problem melts away!

Thank you again!
kabilius at 2007-11-9 13:31:44 >