0

I've got a VB6 program. I'm using the Mainfest to apply "XP Themes" and give it the modern (as of 8 years ago!) look.

However, for graphical style Command buttons, I have to use some special code to redraw the button. Therein lies the problem.

When I click on one of this Graphical buttons it gets the proper "highlighting" of the background, but when another button gets the focus or mouseover, etc. that former button keeps the background highlighting.

If I move another window in front of it, the form redraws itself and this "residual" background color disappears.

I'm trying to figure out how to force that to happen.

What I've tried:

  • button.refresh
  • form.refresh
  • Doevents

Here is a video demo of the problem

1 Answer 1

0

I don't have anything like your setup to try this in, but you can try using the API call InvalidateRect. I've shown the declarations and created a Sub that uses it. It should be a simple copy and paste to try.

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT, ByVal bErase As Long) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

Private Sub RefreshMe()
    Dim udtRect As RECT

    Call GetClientRect(Me.hwnd, udtRect)
    InvalidateRect Me.hwnd, udtRect, 1
    DoEvents 'give windows a chance to handle the event

End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.