Results 1 to 5 of 5

Thread: displaying wmf from resources in picturebox

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    57

    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
    Last edited by edubnmrg; Mar 11th, 2016 at 04:59 PM.

  2. #2
    Addicted Member NinjaNic's Avatar
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    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:
    1. Dim JeepBmp As New Bitmap(My.Resources.Jeep)

    And here's the code:

    vb Code:
    1. Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
    2.  
    3.         e.Graphics.DrawImage(JeepBmp, 0, 0)
    4.  
    5.     End Sub
    6.  
    7.     Private Sub CallPaintEvent()
    8.         PictureBox1.Invalidate()
    9.     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.

  3. #3
    Computer Science BS Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    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?

  4. #4

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    57

    Re: displaying wmf from resources in picturebox

    the point is why the "hardwired" way of accesing the resource works and the programmactic does not

  5. #5

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    57

    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

Tags for this Thread

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