VB NET自定义控件在没有重点关注时会被破坏
我创建了一个VB NET自定义控件-一个带有一些文本的简单图形.
在其上拖动另一个窗口会浪费我绘制的文本和线条.
我正在使用Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
绘制文本和线条,并且在聚焦时,该控件显示正常.
在未聚焦的情况下如何拖动垃圾箱,并在其上拖动另一个窗口?
这些似乎无能为力:''g.Flush() doesn''t help
''MyBase.OnPaint(e) doesn''t help
I''ve created a VB NET Custom Control - a simple graph with some text.
Dragging another window over it trashes the text and lines I''ve drawn.
I''m using Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
to paint the text and lines, and while focused, the control displays fine.
How do I prevent the trashing while it''s not focused and I drag another window over it?
These seem to do nothing:''g.Flush() doesn''t help
''MyBase.OnPaint(e) doesn''t help
下面是在图片上拖动另一个窗口之前和之后的照片:
http://phactor.com/t.gif
我的代码:
Here is a pic before and after dragging another window over it:
http://phactor.com/t.gif
My code:
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim r As System.Drawing.Rectangle = e.ClipRectangle
Dim g As Graphics = e.Graphics
Dim p As New Pen(Color.White)
Dim hFont As IntPtr = GetStockObject(17)
Dim hFFont As Font = Font.FromHfont(hFont)
g.Clear(Color.FromArgb(80, 80, 80))
... code that paints my text and lines
g.Dispose()
End Sub