Results 1 to 9 of 9

Thread: BackgroundImage

  1. #1

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    BackgroundImage

    hi all,

    in runtime, i want to change background image of my mdi form. i tried the following code.

    VB Code:
    1. mdiForm.BackgroundImage.FromFile("c:\windows\xyz.jpg")

    but that isn't working.

    pls guide

    regards,

    prakash

  2. #2
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    This will work:

    Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim ctl As Control
            For Each ctl In Me.Controls
                If TypeOf ctl Is MdiClient Then
                    ctl.BackgroundImage = Image.FromFile("C:\form.jpg")
                End If
            Next
        End Sub

  3. #3

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    got thru. but the image gets tiled. is there any way thru which i can centre the background image.

    regards

  4. #4
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    No, as far as I now backgroundimage is always tiled, but when you got the reference to the MDIClient, maybe you can add a handler to it's paint event, and do the drawing yourself.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  5. #5
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224
    Hi,

    Put a PictureBox on your ndi form
    Propeties of the PictureBox:
    Doc=Fill
    SizeMode=Stretchimage


    Private Sub Form1_Load...

    PictureBox1.Image = New System.Drawing.Imaging.Metafile _
    ("c:\test\Pic.wmf")

    End Sub

    The Picture type must be *.wmf

    Have a nice day

  6. #6

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    Put a PictureBox on your ndi form
    Propeties of the PictureBox:
    Doc=Fill
    SizeMode=Stretchimage


    Private Sub Form1_Load...

    PictureBox1.Image = New System.Drawing.Imaging.Metafile _
    ("c:\test\Pic.wmf")

    End Sub
    i did the same. but instead of wmf file i used jpg file

    PictureBox1.Image = Image.FromFile("c:\windows\Wallpaper.jpg")

    now what happens is that whenever i call a form it is appearing behind the picture box. being picture box's dock property as 'fill' the form becomes invisible.

    at form load event i tried 'PictureBox1.SendToBack'. but this makes the PictureBox itself invisible.

    any solution for this??

    regards

    prakash

  7. #7
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224
    Hi,

    The Picture type must be *.wmf

    PictureBox1.Image = New System.Drawing.Imaging.Metafile _
    ("c:\test\Pic.wmf")


    Have a nice day

  8. #8

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    but what if i want to put a jpg or bmp file???

  9. #9
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224
    Hi,

    The "jpg" do not have the property of the "wmf"

    You can convert "jpg" file to "wmf" file

    Have a nice day

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width