日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
C#中怎么實(shí)現(xiàn)倒計(jì)時(shí)關(guān)閉提示框功能-創(chuàng)新互聯(lián)

C#中怎么實(shí)現(xiàn)倒計(jì)時(shí)關(guān)閉提示框功能,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

十年的精河網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都全網(wǎng)營(yíng)銷的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整精河建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)建站從事“精河網(wǎng)站設(shè)計(jì)”,“精河網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

其核心方法在timer(TimerCallBack,Object,int32,int32) TimerCallBack是一個(gè)委托 ,代表要執(zhí)行的方法,其用途可以用在各個(gè)定時(shí)去調(diào)用方法的場(chǎng)景,而且可以設(shè)置窗體的FormBorderStyle的屬性為None,設(shè)置窗體邊框和標(biāo)題欄外觀不顯示.

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace NewuView.Mix{  public partial class AutoCloseMessageBox : Form  {    public AutoCloseMessageBox()    {      InitializeComponent();    }    public void getMassage(string text)    {      label1.Text = text;    }    public void GetText(string caption)    {      this.Text = caption;    }    System.Threading.Timer _timeoutTimer;    string _caption;    AutoCloseMessageBox(string text, string caption, int timeout)    {      _caption = caption;      _timeoutTimer = new System.Threading.Timer(OnTimerElapsed,        null, timeout, System.Threading.Timeout.Infinite);      AutoCloseMessageBox m_MassageBox = new AutoCloseMessageBox();      m_MassageBox.getMassage(text);      m_MassageBox.GetText(caption);      m_MassageBox.ShowDialog();    public static void Show(string text, string caption, int timeout)    {      new AutoCloseMessageBox(text, caption, timeout);    }    void OnTimerElapsed(object state)    {      IntPtr mbWnd = FindWindow(null, _caption);      if (mbWnd != IntPtr.Zero)        SendMessage(mbWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);      _timeoutTimer.Dispose();    }    const int WM_CLOSE = 0x0010;    [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);    [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]    static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);  }}

調(diào)用時(shí)直接使用類名.show(text,captiom,timeout)直接調(diào)用即可

下邊是當(dāng)時(shí)的項(xiàng)目使用場(chǎng)景的解決辦法

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace NewuView.Mix{  public partial class ErrorForm : Form  {    public ErrorForm()    {      InitializeComponent();    }    private void BarcodeErrorForm_Load(object sender, EventArgs e)    {      this.ShowInTaskbar = false;    }    public void Clear()    {      if (this.InvokeRequired)      {        this.BeginInvoke(new MethodInvoker(Clear));      }      else      {        this.richTextBox1.Clear();      }    }    public void SetMsg(string msg)    {      if (this.InvokeRequired)      {        this.BeginInvoke(new Action(SetMsg), msg);      }      else      {        this.richTextBox1.AppendText(msg + Environment.NewLine);      }    }    public Point Point1 { get; set; }    public void ShowForm()    {      if (this.InvokeRequired)      {        this.Invoke(new MethodInvoker(ShowForm));      }      else      {        this.Location = Point1;        this.BringToFront();        this.Visible = true;      }    }    public void HideForm()    {      if (this.InvokeRequired)      {        this.Invoke(new MethodInvoker(HideForm));      }      else      {        this.richTextBox1.Clear();        this.Visible = false;      }    }  }}

該窗體可以用于實(shí)時(shí)監(jiān)控某一個(gè)狀態(tài)時(shí) 而彈出的提示框 并根據(jù)狀態(tài)改變而隱藏

使用時(shí),new一個(gè)該errorForm

在該窗體有一個(gè)RichTextBox,用來(lái)顯示提示信息,使用SetMsg,設(shè)置要顯示的信息

需要彈出時(shí),實(shí)例調(diào)用Show()方法 實(shí)際就是講該窗體的visible屬性置為true,讓窗體顯示,并且調(diào)用Clear方法,清除提示信息

需要隱藏時(shí),實(shí)例調(diào)用HideForm()方法,將窗體visible屬性設(shè)置為false,調(diào)用clear方法,清除提示信息

關(guān)于C#中怎么實(shí)現(xiàn)倒計(jì)時(shí)關(guān)閉提示框功能問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。


網(wǎng)頁(yè)題目:C#中怎么實(shí)現(xiàn)倒計(jì)時(shí)關(guān)閉提示框功能-創(chuàng)新互聯(lián)
文章URL:http://www.dlmjj.cn/article/dsijos.html