C#定時(shí)關(guān)閉窗體實(shí)例
本文實(shí)例講述了C#定時(shí)關(guān)閉窗體的方法,分享給大家供大家參考。具體方法如下:
{
private System.Timers.Timer timer = new System.Timers.Timer();
public Form2()
{
InitializeComponent();
InitStatus();
timer.Interval = 4000;
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Enabled = true;
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
IntPtr hDlog = FindWindow(null, "Show");
if (IntPtr.Zero != hDlog)
{
IntPtr result;
EndDialog(hDlog, out result);
}
}
private void InitStatus()
{
this.panel1.Controls.Clear();
Form1 from1 = new Form1();
from1.TopLevel = false;
from1.FormBorderStyle = FormBorderStyle.None;
this.panel1.Controls.Add(from1);
from1.Show();
}
[DllImport("user32.dll",SetLastError=true)]
public static extern IntPtr FindWindow(string lpClassName, string caption);
</span>
[DllImport("user32.dll",SetLastError=true)]
public static extern bool EndDialog(IntPtr hDlg, out IntPtr nResult);
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("corning", "Show");
}
}
希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
相關(guān)文章
Unity3D基于OnGUI實(shí)時(shí)顯示FPS
這篇文章主要介紹了Unity3D基于OnGUI實(shí)時(shí)顯示FPS,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-11-11C#開發(fā)WinForm清空DataGridView控件綁定的數(shù)據(jù)
本文詳細(xì)講解了C#開發(fā)WinForm清空DataGridView控件綁定數(shù)據(jù)的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-03-03C#使用SqlDataAdapter對(duì)象獲取數(shù)據(jù)的方法
這篇文章主要介紹了C#使用SqlDataAdapter對(duì)象獲取數(shù)據(jù)的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了SqlDataAdapter對(duì)象獲取數(shù)據(jù)具體步驟與相關(guān)使用技巧,需要的朋友可以參考下2016-02-02C#保存listbox中數(shù)據(jù)到文本文件的方法
這篇文章主要介紹了C#保存listbox中數(shù)據(jù)到文本文件的方法,涉及C#操作listbox數(shù)據(jù)的相關(guān)技巧,需要的朋友可以參考下2015-04-04WPF實(shí)現(xiàn)Badge標(biāo)識(shí)的示例代碼
這篇文章主要為大家詳細(xì)介紹了WPF如何實(shí)現(xiàn)Badge標(biāo)識(shí),文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)或工作有一定幫助,感興趣的小伙伴可以了解一下2023-06-06C#調(diào)用mmpeg進(jìn)行各種視頻轉(zhuǎn)換的類實(shí)例
這篇文章主要介紹了C#調(diào)用mmpeg進(jìn)行各種視頻轉(zhuǎn)換的類,實(shí)例分析了C#調(diào)用mmpeg操作視頻文件的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-03-03