User:Dee/Flicker handling
From HashVB
This article is currently work in progress. Please come back later. |
This article is based on Visual Basic 6. Find other Visual Basic 6 articles. |
VB6 seems to ignore the erasebackground message and do it's background drawing internally in wm_paint. This can cause flickering so to "fix" this, we eat both messages and override VBs wm_paint handling, set everytign up and call the paint event ourselves. We make sure the messages are not passed on to the next handler by telling the subclasser not to call CallWindowProc() but return immediatly.
Private Function SubClassed_WindowProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long, Handled As Boolean) As Long Dim PaintInfo As PAINTSTRUCT Dim hDC As Long Select Case hWnd Case GraphFrame.hWnd Select Case Msg Case &HF 'WM_PAINT 'We handle WM_PAINT ourselves as VB6 seems to explicitly draw the background in its handler hDC = BeginPaint(hWnd, PaintInfo) GraphFrame_Paint EndPaint hWnd, PaintInfo 'We've handled it so VB doesn't do anything further SubClassed_WindowProc = 0 Handled = True Case &H14 'WM_ERASEBKGND 'WM_ERASEBKGND seems to be a noop, but we handle it here anyway SubClassed_WindowProc = -1 Handled = True Case &H137 'WM_CTLCOLORSCROLLBAR 'Ignore the message to fix the scrollbar background Handled = True End Select End Select End Function