Results 1 to 5 of 5

Thread: [Resolved] Subclass of Paul Caton crash WM_PAINT + BeginPaint

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    [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
    Attached Files Attached Files
    Last edited by LeandroA; Apr 6th, 2009 at 06:15 AM.

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    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

  4. #4
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Subclass of Paul Caton crash WM_PAINT + BeginPaint

    Quote Originally Posted by LeandroA View Post
    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
    it's for. Net
    nop it has for both verison vb6 and .net

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    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.
    leandroascierto.com Visual Basic 6 projects

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width