I am a beginner in using API functions to do graphics.
I tried this simple program which loads a BMP into Picture1 and then copies part of the image to Picture2.
(I realize there is a simpler way to do this but I want to learn to use the API calls.)
Option Explicit
Dim Result As Long
Dim hCC As Long
Private Sub cmdLoadPic_Click()
Picture1.Picture = LoadPicture("midcity.bmp"
hCC = CreateCompatibleDC(Picture1.hdc)
Result = SelectObject(hCC, Picture1.hdc)
MsgBox "hCC = " & hCC & " SelectObject returned " & Result, vbOKOnly
' Result is now zero
End Sub
Private Sub cmdBitBlt_Click()
Result = BitBlt(Picture2.hdc, 0, 0, 40, 40, _
hCC, 10, 10, SRCCOPY)
End Sub
hCC has a positive value, but Result is 0.
What is the sequence of API calls needed to accomplish this task?
I tried this simple program which loads a BMP into Picture1 and then copies part of the image to Picture2.
(I realize there is a simpler way to do this but I want to learn to use the API calls.)
Option Explicit
Dim Result As Long
Dim hCC As Long
Private Sub cmdLoadPic_Click()
Picture1.Picture = LoadPicture("midcity.bmp"
hCC = CreateCompatibleDC(Picture1.hdc)
Result = SelectObject(hCC, Picture1.hdc)
MsgBox "hCC = " & hCC & " SelectObject returned " & Result, vbOKOnly
' Result is now zero
End Sub
Private Sub cmdBitBlt_Click()
Result = BitBlt(Picture2.hdc, 0, 0, 40, 40, _
hCC, 10, 10, SRCCOPY)
End Sub
hCC has a positive value, but Result is 0.
What is the sequence of API calls needed to accomplish this task?