1
我想要檢索的用戶自定義面板的OnPaint
方法更新矩形電流控制手柄,但需要這種面板的手柄。我徘徊如何獲得當前控制的處理。該代碼是如下:如何獲得用戶定義的控件類
class MyPanel : Panel
{
[DllImport("User32.dll")]
public static extern bool GetUpdateRect(IntPtr hWnd, out Rectangle lpRect, bool bErase);
protected override void OnPaint(PaintEventArgs e)
{
Rectangle updateRect;
IntPtr hWnd = IntPtr.Zero;
// hWnd = ?; I wonder how to get handle of this panel
GetUpdateRect(hWnd, out updateRect, false);
base.OnPaint(e);
// following drawing code is omited
}
}
'IntPtr hWnd = this.Handle;'? –
也許[this.Handle](https://msdn.microsoft.com/en-us/library/system.windows.forms.control.handle(v = vs.110).aspx)? –
謝謝你的回答! – proshm