0

我有一个VB6程序。我正在使用 Mainfest 应用“XP 主题”并赋予它现代(截至 8 年前!)的外观。

但是,对于图形样式的命令按钮,我必须使用一些特殊的代码来重绘按钮。问题就在于此。

当我单击其中一个图形按钮时,它会正确“突出显示”背景,但是当另一个按钮获得焦点或鼠标悬停等时,前一个按钮会保持背景突出显示

如果我在它前面移动另一个窗口,表单会自行重绘,并且这种“剩余”背景颜色会消失。

我试图弄清楚如何迫使这种情况发生。

我试过的:

  • 按钮.刷新
  • 表单刷新
  • 事件

这是该问题的视频演示

4

1 回答 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
于 2016-05-14T00:31:39.893 回答