Painting in the MDI client area

E

Ed

Hi there,

I have been using the c# code in the article in the link below in several
apps.
http://www.vbaccelerator.com/home/net/Code/Libraries/Windows/MDI_Client_Area_Painting/article.asp

It is a mechanism for showing a nice background gradient and some text on
the background of a MDI shell form.

It has one problem: when moving an external window above the shell area, it
is not always repainted painted correctly, resulting in ugly stripes in the
background. An example of this can be seen here:
http://esonn.home.xs4all.nl/mdiproblem.jpg

The problem only occurs in when visual themes are _not_ used in Windows. It
happens in XP to 7.

The code itself is a bit over my head. I tried contacting the author, but to
no avail. I have tried several things with the code, but I haven't got it
right.

In the first link a small example project can be downloaded.
Anybody got a hint how this could be solved?

Regards, Ed
 
E

Ed

I haven't had time to look at the code or do any debugging. But the image
shows a problem that is almost always the result of failing to invalidate
a control when needed. In this particular case, it appears that the
original background is getting drawn (the gray) but then your custom
graphics over that are not always.

Why in this case the window would not always get properly invalidated when
the child window is moved, I can't say. Windows is usually pretty good
about at least dealing with overlapping windows moving around.

It leads me to wonder if an alternative explanation is needed: that the
area is getting invalidated, but for some reason your own code is not
getting all of the WM_ERASEBKGND messages, and so it misses out getting to
draw during some of them.

As a user, I don't really like MDI apps that much anyway. Reminds me too
much of the old File Manager GUI in early versions of Windows. :) So I
haven't done much playing around with MDI issues.

So, no answers, but I do suggest you look at the questions of invalidation
and messages. You can use a tool like Spy++ to watch, and especially look
for WM_ERASEBKGND and WM_PAINT (if you're handling that as well), to see
if the window gets those messages when your own code does not.

Hi Peter,

Thanks for your comments. Btw, the problem is only when and _external_
window is dragged over the client area. A mdi client form does work fine.

I'll investigate further.

Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top