本文介绍了通过enablewindow方法禁用窗口形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我使用此代码进行窗口启用,并且过程可以继续,但是有时它可以工作,或者有时它无法禁用窗口,请帮助我在这段代码中可以做什么.
hello, i use this code for window enable and process can continue, but sometimes it works or sometimes it fails to disable window, please help me what can i do in this code.
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(String sClassName, String sAppName);
[DllImport("user32.dll")]
static extern bool EnableWindow(IntPtr hwnd, bool bEnable);
private void button1_Click(object sender, EventArgs e)
{
try
{
Form2 obj = new Form2();
IntPtr hwnd = FindWindow(null, "Form1");
EnableWindow(hwnd, false);
Refresh();
obj.Show();
listView2.View = View.Details;
listView2.Items.Clear();
for (int j = 0; j <1000; j++)
{
listView2.GridLines = true;
if (listView2.Items.Count < str)
{
listView2.Items.Add(j.ToString());
}
Application.DoEvents();
}
obj.Close();
EnableWindow(hwnd, true);
// this.Show();
}
推荐答案
这篇关于通过enablewindow方法禁用窗口形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!