Results 1 to 3 of 3

Thread: Pullin out my hair... image from mem, DC

  1. #1

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    Pullin out my hair... image from mem, DC

    Ok i got this code from the forum somewhere... sorry I really forget where but its not mine.

    Code:
    Private Const LR_LOADFROMFILE As Long = &H10
    Private Const IMAGE_BITMAP As Long = &H0
    Private Const SRCCOPY = &HCC0020
    
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function loadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    
    Private Sub loadBitImage()
        Dim lngDC As Long
        Dim lngBitmap As Long
        Dim lngOldBitmap As Long
        
        lngDC = CreateCompatibleDC(picMain.hdc)
        
        lngBitmap = loadImage(0, appPath & "1.jpg", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
        
        lngOldBitmap = SelectObject(lngDC, lngBitmap)
        
        BitBlt picMain.hdc, 0, 0, 256, 256, lngDC, 0, 0, SRCCOPY
        
        Call SelectObject(lngDC, lngOldBitmap)
        DeleteObject lngBitmap
        DeleteDC lngDC
        
    End Sub
    But it does not work, its exactly what im looking for... yet it wont work. What am i doing wrong? Everything looks good ... yet the picture wont load into my picmain control
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

  2. #2

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    never mind... i solved my problem. I didnt look carefully enough, and it looks like it only loads BMPS right now, anyhow... ill have to fix that
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

  3. #3

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    I desided not to use that code, instead I just did this

    Code:
    Private Sub loadBitImage()
        DoEvents
        Dim myPicture As New StdPicture
        Set myPicture = LoadPicture(appPath & "1.tmp")
        
        picMain.PaintPicture myPicture, 1, 1
        
    
        
    End Sub
    For all ya ppl who like examples
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

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