Transparent Button?

Hi, im trying to make my button edges blend into the background. Right now when i use

CreateWindowExA(WS_EX_TRANSPARENT,"BUTTON", "Msg", WS_VISIBLE|WS_CHILD, 156, 1, 86, 22, hWnd, NULL, NULL, NULL);

it does this

http://i55.tinypic.com/21kb1g2.png

Is there another way to make the background of the button to be the background color of the window.
Last edited on
Do you mean you want to get rid of that black border that defines the area of the button?
Yes, sorry for explaining it incorrectly.
I've encountered this problem too...

Try to handle WM_CTLCOLORBTN message

1
2
3
4
5
6
7
8
9
10
switch (message)
{
    case WM_CTLCOLORBTN:
            HBRUSH hBrushBtn;
            hBrushBtn = (HBRUSH) GetStockObject(NULL_BRUSH);
            SetBkMode((HDC) wParam, TRANSPARENT);
    return ((LRESULT) hBrushBtn);
}

return 0;


I suppose you know how to handle the messages :)

And create your button with CreateWindow() function. If you use CreateWindowEx() or other,
DON'T ADD WS_EX_TRANSPARENT FLAG !
Last edited on
O.o I took out "WS_EX_TRANSPARENT" and the same thing happened. : (
Last edited on
Then I don't know what happened when you've removed it :D
It didn't work for me when I added WS_EX_TRANSPARENT flag so if it works for you with that flag do it your way :) Windows is a really messed up thing...

And what Windows do you have ? 7 or XP ?
Last edited on
Topic archived. No new replies allowed.