现在,我正在窗口的标题栏上绘制一个 16x16 的小图像。它工作得很好,除了我无法弄清楚如何摆脱的令人讨厌的闪烁。
我只是像这样绘制图像:
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SIZE Then
wnd_size = New Size(New Point(CInt(m.LParam)))
End If
If m.Msg = WM_ACTIVATE _
OrElse m.Msg = WM_SIZE _
OrElse m.Msg = WM_SYNCPAINT _
OrElse m.Msg = WM_NCACTIVATE _
OrElse m.Msg = WM_NCCREATE _
OrElse m.Msg = WM_NCPAINT _
OrElse m.Msg = WM_NCACTIVATE _
OrElse m.Msg = WM_NCHITTEST _
OrElse m.Msg = WM_PAINT _
OrElse m.Msg = WM_MOUSEMOVE Then
Dim g As Graphics = Graphics.FromHdc(CType(GetWindowDC(CInt(Handle)), IntPtr))
g.DrawImage(My.Resources.drag, 0, 0, 16, 16)
End If
MyBase.WndProc(m)
End Sub
每次更改某些内容(单击,鼠标悬停在角落按钮等)时,它都会重新绘制整个标题栏,并且在重新绘制期间我会闪烁。
还有其他人遇到过这个问题吗?