1 Attachment(s)
[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
Re: Subclass of Paul Caton crash WM_PAINT + BeginPaint
Hai leandro,
you also want to take a look at this one.i am using it and i have no problm with that.
http://www.vbforums.com/showthread.php?t=391338
Re: Subclass of Paul Caton crash WM_PAINT + BeginPaint
Thanks but it's for. Net, and it is a dll, I want to use the module Caton paul, but I can not WM_Paint BeginPaint if the window is a child.
someone else has another suggestion
Re: Subclass of Paul Caton crash WM_PAINT + BeginPaint
Quote:
Originally Posted by
LeandroA
Thanks but it's for. Net, and it is a dll, I want to use the module Caton paul, but I can not WM_Paint BeginPaint if the window is a child.
someone else has another suggestion
nop it has for both verison vb6 and .net ;)
Re: Subclass of Paul Caton crash WM_PAINT + BeginPaint
hello, I found it was error, extracted structure from ApiViewer and this is mistaken
Bad
Code:
Private Type PAINTSTRUCT
hdc As Long
fErase As Long
rcPaint As RECT
fRestore As Long
fIncUpdate As Long
rgbReserved As Byte
End Type
Good
Code:
Private Type PAINTSTRUCT
hDC As Long
fErase As Long
rcPaint As RECT
fRestore As Long
fIncUpdate As Long
rgbReserved(1 To 32) As Byte
End Type
Saludos.