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