BitBlt LoadImage
-
:(( Can someone PLEASE tell me why this won't work? :((
**_******** Declarations ********_** Private Declare Auto Function BitBlt Lib "GDI32.DLL" ( byVal hdcDest As IntPtr, ByVal nXDest As Integer, _ ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As Long, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As Int32) As Boolean Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, _ ByVal dwImageType As Long, ByVal dwDesiredWidth As Long, ByVal dwDesiredHeight As Long, ByVal dwFlags 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 DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long **_******** Consts ********_** Private Const LR_LOADFROMFILE = &H10 Private Const IMAGE_BITMAP = 0 Private SRCCOPY as Integer = &HCC0020 **_******** Sub that won't work ********_**
Private Sub ShowPicture(ByVal File As String) Dim MemBmpHandle As Long Dim MemHdc As Long Dim Result As Long ' MemBmpHandle = LoadImage(0, File, IMAGE_BITMAP, 776, 84, LR_LOADFROMFILE) MemHdc = CreateCompatibleDC(0) Result = SelectObject(MemHdc, MemBmpHandle) ' Dim Grp As Graphics = PictureBox1.CreateGraphics ' Creating graphics object to BitBlt on Dim TargetDC As IntPtr = Grp.GetHdc() 'Creating target HDC ' BitBlt(TargetDC, 0, 0, 776, 84, MemHdc, 0, 0, SRCCOPY) ' Blitting' Grp.ReleaseHdc(TargetDC) Grp.Dispose() DeleteDC(MemHdc) DeleteObject(MemBmpHandle) End Sub
Fade (Amit BS)