Results 1 to 2 of 2

Thread: Simple GDI+ not working

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    14

    Simple GDI+ not working

    Hello,

    I'm playing with GDI+(Am completely new to this side of things)
    I've been going through MSDN to try and understand it.
    The problem.....
    I've follwed the MSDN example of displaying an existing bitmap image and i have to admit i'm stumped!
    As per the example in MSDN i wrote the following code in the form_load event of my form.
    Code:
            Dim myBitmap As New Bitmap("C:\pic1.bmp")
    
            Dim g As Graphics = Button1.CreateGraphics
            g.DrawImage(myBitmap, 1, 1)
    Where pic1.bmp was an image on my c drive and Button1 was a button on the form.
    But it doesn't work.
    It loads fine however it doesn't display the image is not displayed.
    What am i doing wrong?

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    The problem is that the image is actually drawn ok, but the next time the form refreshes the button draws itself normally. That is way it doesn't work in Form_Load. The form will display itself AFTER form load, so the button is redrawn normally.

    Try using another event like form_click.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

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