-
[RESOLVED] Bitblt Error.
Code:
Option Explicit
' Icon Constants
Global Const MAXICON = 8
Global Const ICONINC = 200
' Windows API
Global Const SRCCOPY = &HCC0020
Global Const SRCAND = &H8800C6
Global Const SCRPAINT = &HEE0086
Global Const SRCINVERT = &H660046
' Icon Variables
Global IconNum As Integer
' Windows API functions
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
Code:
Dim ydest As Long
Dim xdest As Long
Private Sub refreshscreen()
Frmbitblt.Cls
Call BitBlt(Frmbitblt.hDC, 0, 0, 350, 275, picback.hDC, 0, 0, SRCCOPY)
Call BitBlt(Frmbitblt.hDC, xdest, ydest, 46, 49, Picture1.hDC, 0, 0, SRCAND)
Call BitBlt(picbuf.hDC, xdest, ydest, 46, 49, Picture2.hDC, 0, 0, SRCINVERT)
Call BitBlt(Frmbitblt.hDC, 0, 0, 0, 0, Form1.hDC, 0, 0, SRCCOPY)
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight
xdest = xdest + 10
refreshscreen
Case vbKeyLeft
xdest = xdest - 10
refreshscreen
Case vbKeyUp
ydest = ydest - 10
refreshscreen
Case vbKeyDown
ydest = ydest + 10
refreshscreen
End Select
If xdest < -25 Then xdest = 325
If xdest > 325 Then xdest = -25
If ydest < -25 Then ydest = 250
If ydest > 250 Then ydest = -25
End Sub
Private Sub Form_Load()
' Center on the screen
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
xdest = 200
ydest = 100
refreshscreen
End Sub
run-time error 424
Object required.
The code below turns yellow
Code:
Call BitBlt(Frmbitblt.hDC, 0, 0, 350, 275, picback.hDC, 0, 0, SRCCOPY)
-
Re: Bitblt Error.
See the article What does this error mean, and how do I fix it? from our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)