[Mono-list] Backdrop behaving different in Mono

Glen Farrell glensmono at telus.net
Wed May 17 17:48:40 EDT 2006

Hi Peter, I'm just guessing, but somehow I don't think I can send an 
attachment through this list? Anyway, a quick testcase is just create a new 
"Windows Application" project. Change the IsMDIContainer property of Form1 
to True. Then add this code to the constructor:

System.Drawing.Bitmap Backdrop = new Bitmap(100,100);
System.Drawing.Graphics GBack = System.Drawing.Graphics.FromImage(Backdrop);
GBack.DrawRectangle(System.Drawing.Pens.Red, 10,10,80,80);
this.BackgroundImage = Backdrop;
Anyway, I've played around with it a bit more, and found the behaviour is a 
little different then I first thought. I believe the above actually does set 
the background image for the form - but the MDI client area is drawn over 
top of that. (And if you set IsMDIContainer to False, you will see the image 
in Mono).

With a toolbar, it's actually not that the toolbar gets the image, but that 
the toolbar is transparent, showing the underlying background. Resizing the 
window makes this obvious - you'll see the image scrolling by beneath the 

The interesting part is that Microsoft is inconsistent here - 
BackgroundImage works, but BackColor does not (neither work for Mono). So 
possibly Mono is the one doing it correctly? Anyway, did a search for MDI 
background color, and found this:


Basically, by looping through the MDI form's Controls collection, you can 
get a handle to the MDI client area. And then using that handle, set the 
BackColor ... or the BackgroundImage! And doing it this way works in both 
.Net and Mono.

So I'm happy doing it that way. Up to you if you want to consider this a 
Mono bug or a .Net bug ...


More information about the Mono-list mailing list