Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1739
  • Last Modified:

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.


0
raiderjakk
Asked:
raiderjakk
1 Solution
 
iboutchkineCommented:
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
0
 
raiderjakkAuthor Commented:
Nope.... that doesn't seem to do it.... MDI forms are special cases it seems.  :-)


0
 
raiderjakkAuthor Commented:
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
0
 
Bob LearnedCommented:
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
0
 
Computer101Commented:
PAQed, with points refunded (50)

Computer101
E-E Admin
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Tackle projects and never again get stuck behind a technical roadblock.
Join Now