Creating a static window

I'm trying to create a static control into a program.
It usually works fine for me, but now I have a window which is completely white, and when I create the static controll, the text has a grey background...

It's all WinAPI, C++.

This is my code :

 
CreateWindow( TEXT("static"), "Welcome!", WS_CHILD | WS_VISIBLE, 200, 50, 100, 20, MainHwnd, NULL, hInstance, NULL);


Here is how it looks like :

http://up404.siz.co.il/up1/ntcihk52mwtz.jpg

What is the fastest and easiest way to make the text "blend" with the background (I want it to be black text, just without this grey background near)

Thanks!
Last edited on
You can change static control background to match while processing WM_CTLCOLORSTATIC message in the parent:
1
2
3
4
5
6
7
8
9
10
11
case WM_CTLCOLORSTATIC:
        // Set the colour of the text for our URL
        if ((HWND)lParam == GetDlgItem(hDlg, IDC_WARNING)) 
        {
                // we're about to draw the static
                // set the text colour in (HDC)lParam
                SetBkMode((HDC)wParam,TRANSPARENT);
                SetTextColor((HDC)wParam, RGB(255,0,0));
                return (BOOL)CreateSolidBrush (GetSysColor(COLOR_MENU));
        }
        break;


More info on MSDN.
http://msdn.microsoft.com/en-us/library/bb787524%28VS.85%29.aspx
Last edited on
Thanks, but I'm getting unregonized identifier to those :
(hDlg, IDC_WARNING)) It doesnt recognize both of the paramters...
Yes, adapt it to your needa, you have the documentation for WM_CTLCOLORSTATIC. Don't copy paste anything before you read what it does (and change it).

For your specific case, this GetDlgItem(hDlg, IDC_WARNING)) needs to be replaced with what CreateWindow() returns.
Last edited on
Thank you! it works!!
What a lovely forum page. I’ll undoubtedly be back again. Please maintain writing!
[url=http://www.bcpartners-llc.com/]high risk merchant account[/url]
[url=http://www.bcpartners-llc.com/]high risk credit card processing[/url]
[url=http://www.bcpartners-llc.com/]high risk processing[/url]
[url=http://www.bcpartners-llc.com/]credit card processing[/url]
Topic archived. No new replies allowed.