By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,804 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,804 IT Pros & Developers. It's quick & easy.

Making a Picture Background for the Form

P: 12
I'm trying to make make the background of the form a picture. So far I got this.

Private Sub Form_Load()
FrmStarship.WindowState = vbMaximized
FrmStarship.Picture = LoadPicture(App.Path & "\Pics\MenuScreen1.bmp")
'How do I change the the size from here?
End Sub

The problem is that I can't get the picture to be as big as the window. At the site below, it says that the size attribute for Loadpicture() is only for cursor and icon files. I tried the example but the defining the Height and Width changed the form size itself.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbfctloadpicture.asp

Thanx for any help you guys can give me. ^^
Apr 1 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 5K+
P: 8,434
If you're trying to stretch out the picture to cover the entire form, you could try placing it in an ImageBox, with the .Stretch property set to True, and size the control to cover the form.

Note that if you do this in the form's Resize event procedure, you may need to check the WindowState and do nothing if it's vbMinimized.
Apr 1 '07 #2

vijaydiwakar
100+
P: 579
I'm trying to make make the background of the form a picture. So far I got this.

Private Sub Form_Load()
FrmStarship.WindowState = vbMaximized
FrmStarship.Picture = LoadPicture(App.Path & "\Pics\MenuScreen1.bmp")
'How do I change the the size from here?
End Sub

The problem is that I can't get the picture to be as big as the window. At the site below, it says that the size attribute for Loadpicture() is only for cursor and icon files. I tried the example but the defining the Height and Width changed the form size itself.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbfctloadpicture.asp

Thanx for any help you guys can give me. ^^
image box is the best option so far
Apr 2 '07 #3

P: 31
Change the form's AutoRedraw property to "True". Insert a picture into the form's Picture property.

General Code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.     PaintPicture Picture, 0, 0, ScaleWidth, ScaleHeight
  4.  
  5. End Sub
  6.  
  7. Private Sub Form_Resize()
  8.  
  9.     If ScaleHeight > 0 Then
  10.         PaintPicture Picture, 0, 0, ScaleWidth, ScaleHeight
  11.     End If
  12.  
  13. End Sub
Somewhat better than using a large image control, though it works in pretty much the same way.
Apr 5 '07 #4

Expert 5K+
P: 8,434
Change the form's AutoRedraw property...
Nice one, Tristan. Thanks for the input.
Apr 6 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.