Results 1 to 3 of 3

Thread: Annoying problem

  1. #1

    Thread Starter
    Addicted Member kikelinus's Avatar
    Join Date
    Nov 2000
    Posts
    219

    Talking Annoying problem

    I am trying to load an image into the screen using api, and no picture box controls...I have the following code:

    VB Code:
    1. Private Sub Form_Activate()
    2.  
    3.     'Create dc device
    4.     BackDC = CreateCompatibleDC(Me.hdc)
    5.  
    6.     'Load Image into dc
    7.     BackIM = LoadImage(0, App.Path & "\back.bmp", 0, 0, 0, &H10)
    8.  
    9.     'Associate dc with loaded image
    10.     SelectObject BackDC, BackIM
    11.  
    12.     'Draw image
    13.     BitBlt Me.hdc, 10, 10, 50, 50, BackDC, 0, 0, vbSrcCopy
    14.  
    15. End Sub

    I don't get any error, but the image simply doesn't appear in the screen. I have my form set to pixels, and I've also tried setting the AutoRedraw to true, and add a Form1.cls, but that doesn't work either....

    Any idea?

    Thanks

  2. #2
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    Try this...

    VB Code:
    1. Private Sub Form_Activate()
    2.  
    3.     Dim BackDC As Long
    4.     Dim BackIM As Long
    5.     Me.AutoRedraw = True
    6.     'Create dc device
    7.     BackDC = CreateCompatibleDC(Me.hdc)
    8.  
    9.     'Load Image into dc
    10.     BackIM = LoadImage(0, "C:\windows\pinstripe.bmp", 0, 0, 0, &H10)
    11.  
    12.     'Associate dc with loaded image
    13.     SelectObject BackDC, BackIM
    14.  
    15.     'Draw image
    16.     BitBlt Me.hdc, 10, 10, 50, 50, BackDC, 0, 0, vbSrcCopy
    17.     Me.Refresh
    18. End Sub

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  3. #3

    Thread Starter
    Addicted Member kikelinus's Avatar
    Join Date
    Nov 2000
    Posts
    219
    OOps....

    I forgot I had my image file stored at App.Path & "\images\back.bmp"



    Thanks anyways

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