|
-
Feb 15th, 2004, 07:17 AM
#1
Thread Starter
Fanatic Member
BackgroundImage
hi all,
in runtime, i want to change background image of my mdi form. i tried the following code.
VB Code:
mdiForm.BackgroundImage.FromFile("c:\windows\xyz.jpg")
but that isn't working.
pls guide
regards,
prakash
-
Feb 15th, 2004, 09:33 AM
#2
Addicted Member
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
-
Feb 16th, 2004, 02:52 AM
#3
Thread Starter
Fanatic Member
got thru. but the image gets tiled. is there any way thru which i can centre the background image.
regards
-
Feb 16th, 2004, 06:12 AM
#4
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...
-
Feb 16th, 2004, 02:16 PM
#5
Addicted Member
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
-
Feb 26th, 2004, 08:49 AM
#6
Thread Starter
Fanatic Member
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
-
Feb 27th, 2004, 12:34 AM
#7
Addicted Member
Hi,
The Picture type must be *.wmf
PictureBox1.Image = New System.Drawing.Imaging.Metafile _
("c:\test\Pic.wmf")
Have a nice day
-
Feb 27th, 2004, 03:26 AM
#8
Thread Starter
Fanatic Member
but what if i want to put a jpg or bmp file???
-
Feb 27th, 2004, 09:44 AM
#9
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|