|
-
May 20th, 2007, 10:23 PM
#1
Thread Starter
Junior Member
Help with picturebox background images
I am trying to have a image with another image layed on top of it. i made one the background and one the main image. but i need a way to make the background image of the picturebox scale like the image does, instead of tiling.
-
May 20th, 2007, 11:47 PM
#2
Re: Help with picturebox background images
The Image and BackgroundImage properties do not behave the same way. The Image appearance is controlled by the SizeMode property while the BackgroundImage appearance is controlled by the BackgroundImageLayout property. There is some similarity but they are not the same.
If you cannot get the effect you want with the BackgroundImage property then you can use GDI+ to draw an Image directly onto either the Image property or the PictureBox itself. The first is permanent while the second is not.
-
May 21st, 2007, 09:16 AM
#3
Thread Starter
Junior Member
Re: Help with picturebox background images
i have tried to draw it on with GDI+ but whenever i do that it goes behind the picture in the picturebox.
And could you provide an example of the backgroundimagelayout property, i havent heard of this before.
-
May 21st, 2007, 05:53 PM
#4
Re: Help with picturebox background images
I've never had any problem when drawing on a PictureBox using GDI+. If you are then we'd need to see what you're actually doing.
You don't need any examples from me. It's a property of the PictureBox so you set it in the Properties window. As you change its value you'll immediately see its effect in the designer. If you want an explanation of the property or the values it can take then the MSDN library is the place to look.
-
May 21st, 2007, 07:23 PM
#5
Thread Starter
Junior Member
Re: Help with picturebox background images
its not that i have trouble drawing on them, i can draw but then they immediatly dissapear, if i have it fire on the forms paint command it severely lags the program and the overlay flashes but it stays on top.
Also i do not see that property thing your talking about.
thx for your help
-
May 21st, 2007, 07:27 PM
#6
Re: Help with picturebox background images
1. What version are you using? BackgroundImageLayout is new in .NET 2.0. If you always specify your version then we shouldn't make invalid assumptions.
2. If you want to draw on a control you do so on that control's Paint event. If you want to draw on a PictureBox then you do so in the Paint event handler of that PictureBox; not the Paint event handler of the form or anywhere else.
-
May 21st, 2007, 07:33 PM
#7
Thread Starter
Junior Member
Re: Help with picturebox background images
Im sorry but i am a gigantic noob, how would i check the version.
And thanks for the advice ill try it.
-
May 21st, 2007, 07:34 PM
#8
Re: Help with picturebox background images
 Originally Posted by Just_Another_noob
Im sorry but i am a gigantic noob, how would i check the version.
The same way you get information about any application: Help -> About.
-
May 21st, 2007, 07:37 PM
#9
Thread Starter
Junior Member
Re: Help with picturebox background images
im running 1.1, so i guess i should probably upgrade. How would one go about doing this?
Also when i put the draw thing on the image boxes paint handle it shows up even less.
-
May 21st, 2007, 07:59 PM
#10
Re: Help with picturebox background images
You are using VS.NET 2003, which targets .NET 1.1 by default. You don't necessarily have to upgrade, but VS 2005 and .NET 2.0 do have more features. VB Express 2005 is a VB-only version of VS 2005 with fewer features and it costs nothing. It supports all features of VB 2005 and .NET 2.0 but the IDE itself has fewer features. If you don't need those lacking features, which its target audience of students and hobbyists don't really, then VB Express is a great product. By all means give it a go and see what you think. If you find you do need the extra features then you can always buy VS Standard or Pro later.
Drawing on a PictureBox works. If it's not working for you then you're doing it wrong. If you don't show us what you're doing then we can't see what the issue might be.
-
May 21st, 2007, 08:32 PM
#11
Thread Starter
Junior Member
Re: Help with picturebox background images
Code:
Private Sub GS1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Menu_Slot_1.Paint
ol = Me.overlay.Image
ol.MakeTransparent(Color.White)
Me.Menu_Slot_1.CreateGraphics.DrawImage(ol, 0, 0, Menu_Slot_1.Width, Menu_Slot_1.Height)
End Sub
as you can see im trying to lay an overlay on top of a picturebox with an image in it.
-
May 21st, 2007, 08:45 PM
#12
Re: Help with picturebox background images
Firstly you're creating a Graphics object and not disposing it, which is a big no-no. Secondly you shouldn't be creating a Graphics object at all. One is already provided for the purpose in the e.Graphics property.
-
May 21st, 2007, 08:48 PM
#13
Thread Starter
Junior Member
Re: Help with picturebox background images
ok thank you, how should i go about this without creating a surface?
-
May 21st, 2007, 08:52 PM
#14
Re: Help with picturebox background images
As I said in my previous post, a Graphics object is already provided for you in the Paint event handler via the e.Graphics property. The object itself creates the Graphics object, uses it to draw itself, passes it to the event handler(s) so if there are multiple handlers they all use the same one, then destroys the object once it's done.
-
May 21st, 2007, 08:55 PM
#15
Thread Starter
Junior Member
Re: Help with picturebox background images
OMG dude, i have to thank you sooo much, no wonder it was sooo laggy. That works like a charm.
You sir, are one smart person
-
May 21st, 2007, 08:58 PM
#16
Re: Help with picturebox background images
Don't mistake experience for intelligence.
-
May 21st, 2007, 09:20 PM
#17
Thread Starter
Junior Member
Re: Help with picturebox background images
now im having another problem, i am trying to have a hover effect.
heres my code:
Code:
Dim ol As Bitmap
Dim pcb As PictureBox
Private Sub GS1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Menu_Slot_1.Paint
ol = pcb.Image
ol.MakeTransparent(Color.White)
e.Graphics.DrawImage(ol, 0, 0, Menu_Slot_1.Width + 1, Menu_Slot_1.Height + 1)
End Sub
Private Sub Menu_Slot_1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menu_Slot_1.MouseEnter
pcb = Me.overlay_2
End Sub
Private Sub Menu_Slot_1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menu_Slot_1.MouseLeave
pcb = Me.overlay
End Sub
It works a few times then stops working, im guessing im not disposing something or having it load too many times. Some insight would be appreciated.
-
May 21st, 2007, 09:51 PM
#18
Re: Help with picturebox background images
Call the Refresh method of the PictureBox you want to change the appearance of in order to force it to repaint. That means in your MouseEnter and MouseLeave event handlers.
-
May 22nd, 2007, 08:33 AM
#19
Thread Starter
Junior Member
-
May 22nd, 2007, 11:51 PM
#20
Thread Starter
Junior Member
Re: Help with picturebox background images
Ummmmm, i need some more help.
I have the new VB.NET but whenever i set the background image and image the background image sticks out like one pixel farther than the image. When i was drawing with GDI+ i fixed this by drawing it with picturebox.width +1.
Is there anyway to do this in net 2.0 without GDI+?
-
May 23rd, 2007, 09:12 PM
#21
Thread Starter
Junior Member
Re: Help with picturebox background images
No one?
Sorry for being imaptient. (and triple posting )
-
May 23rd, 2007, 11:55 PM
#22
Thread Starter
Junior Member
Re: Help with picturebox background images
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
|