Link to home
Start Free TrialLog in
Avatar of raiderjakk
raiderjakk

asked on

MDI Parent Form - Background Image Stretching

Is there anyway to set an image as the background of an MDI parent form in VB.Net, and have it stretch to fill the window?  I haven't seen anything anywhere to do this.  I am able to create a picture box over the form surface, but the child controls are then hidden.


Avatar of iboutchkine
iboutchkine

I used this code for the Form background image. Maybe it will work for MDI parent (Inever tried)

' Paint an image loaded from a file directly on the form.
' This example hooks into the form's Paint event using the
' Handles clause.
'
Private Sub PaintImageOnForm( _
    ByVal sender As Object, _
    ByVal e As System.Windows.Forms.PaintEventArgs) _
    Handles MyBase.Paint

    e.Graphics.DrawImage( _
         Image.FromFile("C:\windows\web\wallpaper\wind.jpg"), 2, 2)

End Sub
Avatar of raiderjakk

ASKER

Nope.... that doesn't seem to do it.... MDI forms are special cases it seems.  :-)


Actually, I figured out how to do this.

You can't subclass the paint event to get the graphics context because the background image isn't part of the signature for that event.  

Instead, I invoke a procedure that scales the image after a resize or move that redraws the background.  

The other oddity is that you have to have to refresh the parent form from within the child, otherwise, the image takes the forefront.

I will post code and accept the answer when I have it handy.  :-)


Thanks,

rj
Avatar of Bob Learned
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ/Refund

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial