[Resolved] Subclass of Paul Caton crash WM_PAINT + BeginPaint
hello, I have problem with the class Subclass of Paul Caton, when I try to use the msg WM_Paint with BeginPaint, the project crash
I think everything's fine, but that is not happening
Code:
Option Explicit
Private Declare Function EndPaint Lib "user32" (ByVal hwnd As Long, lpPaint As PAINTSTRUCT) As Long
Private Declare Function BeginPaint Lib "user32" (ByVal hwnd As Long, lpPaint As PAINTSTRUCT) As Long
Private Type RECT
left As Long
top As Long
Right As Long
Bottom As Long
End Type
Private Type PAINTSTRUCT
hdc As Long
fErase As Long
rcPaint As RECT
fRestore As Long
fIncUpdate As Long
rgbReserved As Byte
End Type
Private Const WM_PAINT As Long = &HF&
Private Const WM_MOUSEMOVE As Long = &H200
Private cSubClass As ClsSubclass
Private PS As PAINTSTRUCT
Private Sub Form_Load()
Set cSubClass = New ClsSubclass
If cSubClass.ssc_Subclass(Command1.hwnd, , , Me) Then
cSubClass.ssc_AddMsg Command1.hwnd, WM_PAINT, MSG_BEFORE
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
cSubClass.ssc_UnSubclass Command1.hwnd
Set cSubClass = Nothing
End Sub
' Ordinal 1
Private Sub WndProc(ByVal bBefore As Boolean, _
ByRef bHandled As Boolean, _
ByRef lReturn As Long, _
ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long, _
ByRef lParamUser As Long)
If uMsg = WM_PAINT Then
BeginPaint hwnd, PS
'Debug.Print Now
EndPaint hwnd, PS
End If
End Sub
Last edited by LeandroA; Apr 6th, 2009 at 06:15 AM.