The reason i got into low level stuff in the first place was that i wanted to
reserve space in a controls nc-area and then use that space to draw my own
fancy looking borders. So i started handing WM_NCCALCSIZE (both with wparam=0
(RECT) and wparam != 0 (NCCALCSIZE). My next task was to draw the non-client
borders with round corners and in some areas with lower alpha than 255 (to
create a smooth transition between the corners and the background).
Unfortunately, Windows does not handle true transparency very good (you'll
end up seeing through to the underlying desktop in transparent areas), so my
buest guess was to change the control region (didn't fix my
semi-transparency, but atleast i got round corners). Not i got a new problem,
because WM_NCPAINT was posted earlier than WM_SIZE when resizing the control,
the control region was not properly sized, and the nc area got clipped when i
tried to paint it. To counter this, i had to handle the WM_WINDOWPOSCHANGING,
marshal out the WINDOWPOS structure and utilize the given bounds to update
the control region prior to any WM_NCPAINT messages. Now, as i mentioned my
control can be moved and resized at runtime. The only way i got this to work
was to handle WM_NCHITTEST and manipulate the message return value to tell
the operaing system my intentions. This is the main reasons for going
low-level, if anyone can tell me to do the exact same things simple and
managed, i would love to hear it. Regards, marius
[quoted text, click to view] "Oliver Sturm" wrote:
> MariusI wrote:
>
> >The OnPaint
> >method is not responsible for drawing contained controls, and according to
> >my
> >tests, the WM_PAINT message sent to the parent does not trigger a
> >corresponding WM_PAINT event on the contained controls. I tried to block
> >the
> >WM_PAINT message sent to a container control to see if its child controls
> >still painted, and they did. According to my knowledge, there is only on
> >message queue which dispatch messages to the focused window. Does this mean
> >that you cannot control painting of child control through their container?
> >You see, i'm having trouble with flickering child controls when i resize
> >the
> >parent control. My idea was to use the WM_PRINTCLIENT to draw everything
> >to a
> >buffer between BeginPaint and EndPaint, before finally painting to screen.
>
> I reckon you have overridden WndProc to receive the messages for your
> control. In addition to that, you could install a message filter that
> would let you have access to messages that are destined for other controls
> than your own, like your child controls. See the IMessageFilter docs in
> MSDN for more information about this.
>
> That said, I don't really believe your problems with flickering child
> controls should have much to do with what you're doing in the parent
> control. Talking about that blog post I told you about - there are two
> versions of that one online, the older one is here:
>
http://www.sturmnet.org/blog/archives/2005/08/26/explorer-rubber-band/ >
> In this older version, the rubber band selection didn't draw itself in
> front of child controls, if there were any there, but I'm sure it did that
> without any flickering whatsoever. Try it - it looks interesting how the
> rectangle you're dragging appears smoothly behind any controls you have on
> the form.
>
> I guess it's possible that you're doing some drawing that actually draws
> *over* the child controls somehow, so the flickering you're seeing might
> be the child controls restoring their visual state.
>
> A last thing - you seem to be doing an awful lot of low level stuff in
> your control. In my experience, this isn't usually necessary when creating
> custom controls in .NET. Maybe you could post a more detailed description
> of what exactly you want to achieve, so that somebody else can suggest
> ways of doing it; I imagine you might find that there are easier ways to
> do the same things.
>
>
> Oliver Sturm
> --
> Expert programming and consulting services available
> See
http://www.sturmnet.org (try /blog as well)
>