基本上我已經建立了一個類來處理髮送WM_SETREDRAW消息像這樣:C# - 鎖拉絲
public static class DrawingLocker
{
[DllImport("user32", CharSet = CharSet.Auto)]
private extern static IntPtr SendMessage(IntPtr hWnd,
int msg, int wParam, IntPtr lParam);
private const int WM_SETREDRAW = 11; //0xB
public static void LockDrawing(IntPtr Handle)
{
SendMessage(Handle, WM_SETREDRAW, 0, IntPtr.Zero);
}
public static void UnlockDrawing(IntPtr Handle)
{
SendMessage(Handle, WM_SETREDRAW, 1, IntPtr.Zero);
}
}
然後我在我的自定義用戶控件再拉法:
public void Redraw()
{
try
{
DrawingLocker.LockDrawing(Handle);
using (Graphics graphics = Graphics.FromHwnd(Handle))
{
//Draw Stuff
}
}
finally { DrawingLocker.UnlockDrawing(Handle); }
}
我問題是我沒有畫「繪製東西」評論的地方。我究竟做錯了什麼? (重繪被調用時,影響繪圖變化,包括調整大小的值)
...爲什麼你首先使用該標誌? – 2010-08-28 12:42:58
停止繪畫時閃爍,如果有更好的方式,我已經錯過了隨時張貼它作爲答案。 – Blam 2010-08-28 12:46:14