Mag*_*son 15
我没有找到SuspendLayout()并ResumeLayout()做你想要的.
LockWindowsUpdate() moobaa提到的诀窍.但是,一次 LockWindowUpdate只适用于一个窗口.
你也可以试试这个:
using System;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Runtime.InteropServices;
public partial class Form1 : Form
{
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
private const int WM_SETREDRAW = 11;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SendMessage(this.Handle, WM_SETREDRAW, false, 0);
// Do your thingies here
SendMessage(this.Handle, WM_SETREDRAW, true, 0);
this.Refresh();
}
}
Run Code Online (Sandbox Code Playgroud)
您可以使用旧的Win32 LockWindowUpdate函数:
[DllImport("user32.dll")]
private static extern long LockWindowUpdate(long Handle);
try {
// Lock Window...
LockWindowUpdate(frm.Handle);
// Perform your painting / updates...
}
finally {
// Release the lock...
LockWindowUpdate(0);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20211 次 |
| 最近记录: |