国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#定時關閉窗體實例

2020-01-24 02:22:08
字體:
來源:轉載
供稿:網友

本文實例講述了C#定時關閉窗體的方法,分享給大家供大家參考。具體方法如下:

復制代碼 代碼如下:
public partial class Form2 : Form 

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 style="white-space:pre">  <span style="font-family: monospace; white-space: pre; background-color: rgb(240, 240, 240); ">[DllImport("user32.dll",SetLastError=true)]</span><br style="font-family: monospace; white-space: pre; background-color: rgb(240, 240, 240); "><span style="font-family: monospace; white-space: pre; background-color: rgb(240, 240, 240); ">        public static extern int PostMessage(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam);</span> 
</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"); 
        } 
    }

希望本文所述對大家的C#程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 丹凤县| 临沂市| 佛学| 互助| 定安县| 广河县| 临颍县| 泰兴市| 新邵县| 新宁县| 连云港市| 九江县| 广汉市| 隆昌县| 三门峡市| 吉林省| 大竹县| 邹平县| 论坛| 万荣县| 陆河县| 子长县| 岚皋县| 中宁县| 临朐县| 闵行区| 烟台市| 常山县| 北京市| 长寿区| 怀宁县| 蒲城县| 青田县| 三亚市| 离岛区| 鄂托克旗| 灌南县| 兴隆县| 明星| 达日县| 资阳市|