displaying wmf from resources in picturebox
I have several images loaded as resources and would like to display them programatically to picturebox
Howerver
Pic1.Image = My.Resources.ResourceManager.GetObject("111.wmf")
does not work
Pic1.Image = CType(My.Resources.ResourceManager.GetObject("111.wmf"), Image)
doesnt work either
Pic1.Image = My.Resources._111
works but i cant use a variable
any help?
thanks
Re: displaying wmf from resources in picturebox
I like to use a graphics object to paint into PictureBoxes. You must go into the PictureBox1_Paint sub to do this.
First of all, I've always created my images this way:
vb Code:
Dim JeepBmp As New Bitmap(My.Resources.Jeep)
And here's the code:
vb Code:
Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
e.Graphics.DrawImage(JeepBmp, 0, 0)
End Sub
Private Sub CallPaintEvent()
PictureBox1.Invalidate()
End Sub
"e.Graphics" can only be used in Paint subs, but it has so many useful functions especially for game developers! Also, use "CallPaintEvent()" or just "PictureBox1.Invalidate()" to draw/reload the PictureBox. Good luck! I will be glad to help if you need more.
Re: displaying wmf from resources in picturebox
Game developers don't use PictureBoxes or paint call events ;)
Also, who on earth uses wmfs? Whats wrong with jpegs or pngs?
Re: displaying wmf from resources in picturebox
the point is why the "hardwired" way of accesing the resource works and the programmactic does not
Re: displaying wmf from resources in picturebox
i use wmf so the image is the same whe i resize the picturebox, although is possible that using a jpeg with high resolution would work
anyway the problem is about accesing the resource