C\C++ - win32: how redraw a transparent control with parent WS_CLIPCHILDREN style?

Started by
7 comments, last by cambalinho 9 years ago

1 - the child control is transparent:


case WM_ERASEBKGND:
            case WM_CTLCOLORBTN:
            case WM_CTLCOLORSTATIC:
            {
                return (LRESULT)GetStockObject(NULL_BRUSH);
            }
            break;

2 - on paint i can't draw a filled rectangle or will not be transparent;

3 - the parent window have the WS_CLIPCHILDREN style;

4 - for redraw the child control i do(for animation):


RECT d;
                GetClientRect(hwnd,&d);
                RedrawWindow(hwnd,&d,nullptr,RDW_UPDATENOW | RDW_INVALIDATE);

- if the child control isn't transparent, the flicker is out and the child control is drawed normaly, if i draw the filled rectangle;

- if the child control is transparent, the flicker is out.. but the child control isn't drawed correctly(the image is showed 1 above another) :(

(see the image problem)

how can i redraw, correctly, the child control using the WS_CLIPCHILDREN style?

Advertisement

Drawing controls transparent is always a problem, and basically can't be gotten to work without major hackarounds in both child and parent.

What exactly are you trying to achieve?

Your thumbnail is way too small to recognize what you mean.

Are you trying to display game objects with child windows? If yes, don't even try, that'll only end in tears. If you do want to use Win32 API only look into CreateDIBSection etc.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Drawing controls transparent is always a problem, and basically can't be gotten to work without major hackarounds in both child and parent.

What exactly are you trying to achieve?

Your thumbnail is way too small to recognize what you mean.

Are you trying to display game objects with child windows? If yes, don't even try, that'll only end in tears. If you do want to use Win32 API only look into CreateDIBSection etc.

i mean showing the controls transparent(like label\button\checkbox\option\group or panel.

i can do it easely. but i need avoid the flickers.. thats why i use the WS_CLIPCHILDREN style on parent window :(

The only way I ever solved this with pure Win32 was to render the background of the window to an offscreen bitmap, then draw the appropriate rectangle when drawing the child. There is no easy way around this issue. If you don't clip children, you get flicker. If you do, your background doesn't render to that part of the window so you need to be able to repaint the right bit when you paint the child.

My advice - use Qt. It seamlessly looks after all of this for you and you never have to even think about it again.

The only way I ever solved this with pure Win32 was to render the background of the window to an offscreen bitmap, then draw the appropriate rectangle when drawing the child. There is no easy way around this issue. If you don't clip children, you get flicker. If you do, your background doesn't render to that part of the window so you need to be able to repaint the right bit when you paint the child.

My advice - use Qt. It seamlessly looks after all of this for you and you never have to even think about it again.

by some reason, i don't get the mail notification :(

why the WS_CLIPCHILDREN style, on parent window, don't let me clear the child control?

Sorry, I don't understand your question.

if i use WS_CLIPCHILDREN, i have notice, the control never is clear... why?

Because it's clipped out of any painting done by the parent control. You have to clear it, or do whatever painting you need, within the child control's own paint event.

This is how clipping children avoids flicker, by stopping the parent window painting over the top of it. Flicker is caused by the parent window painting the area then the child control painting again on top of that.

Because it's clipped out of any painting done by the parent control. You have to clear it, or do whatever painting you need, within the child control's own paint event.

This is how clipping children avoids flicker, by stopping the parent window painting over the top of it. Flicker is caused by the parent window painting the area then the child control painting again on top of that.

that's why i'm trying do the Region by bitmap. but i, always, faild with code :(

i'm confused why my code is getting problems :(

This topic is closed to new replies.

Advertisement