02对话框显示一会自动消失

01 添加引用

 [DllImport("user32.dll")]
        public static extern int MessageBoxTimeoutA(IntPtr hWnd, string msg, string Caps, int type, int Id, int time);   //引用DLL

02 调用代码

 MessageBoxTimeoutA((IntPtr)0, "3秒后自动关闭", "消息框", 64, 0, 2000);    // 直接调用  3秒后自动关闭 

03 typede 类型值

 04 返回值

 05 现在的问题是 如何倒计时?(以后再写)

06实际案例

 public partial class MainWindow : Window
    {
        [DllImport("user32.dll")]
        public static extern int MessageBoxTimeoutA(IntPtr hWnd, string msg, string Caps, int type, int Id, int time);   //引用DLL
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxTimeoutA((IntPtr)0, "3秒后自动关闭", "消息框", 64, 0, 2000);    // 直接调用  3秒后自动关闭 

        }
    }

猜你喜欢

转载自www.cnblogs.com/Record-experience/p/12515221.html
今日推荐