• aaa


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    namespace WpfApplication1
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            System.Windows.Threading.DispatcherTimer timmer;
            const int WM_CLOSE = 0x00000111;
            [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);
    
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void msgShow_Click1(object sender, RoutedEventArgs e)
            {
                timmer = new System.Windows.Threading.DispatcherTimer();
                timmer.Tick += Timmer_Tick;
                timmer.Interval = new TimeSpan(0, 0, 3);
                timmer.Start();
    
                MessageBoxResult result = MessageBox.Show("hello", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                if (result == MessageBoxResult.OK)
                {
                    Console.WriteLine("OK");
                }
    
                ToolTip toolTip = grid.ToolTip as ToolTip;
                toolTip.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
                toolTip.PlacementTarget = sender as Button;
                toolTip.Visibility = Visibility.Visible;
                toolTip.IsOpen = true;
                toolTip.Content = "zhang : 3 
    zhou : 5";
            }
    
            private void msgShow_Click2(object sender, RoutedEventArgs e)
            {
                timmer = new System.Windows.Threading.DispatcherTimer();
                timmer.Tick += Timmer_Tick;
                timmer.Interval = new TimeSpan(0, 0, 3);
                timmer.Start();
    
                MessageBoxResult result = MessageBox.Show("hello", "Information", MessageBoxButton.YesNo, MessageBoxImage.Information);
                if (result == MessageBoxResult.Yes)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
    
                ToolTip toolTip = grid.ToolTip as ToolTip;
                toolTip.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
                toolTip.PlacementTarget = sender as Button;
                toolTip.Visibility = Visibility.Visible;
                toolTip.IsOpen = true;
                toolTip.Content = "zhang : 7 
    zhou : 8";
            }
    
            private void msgShow_Click3(object sender, RoutedEventArgs e)
            {
                timmer = new System.Windows.Threading.DispatcherTimer();
                timmer.Tick += Timmer_Tick;
                timmer.Interval = new TimeSpan(0, 0, 3);
                timmer.Start();
    
                MessageBoxResult result = MessageBox.Show("hello", "Information", MessageBoxButton.OKCancel, MessageBoxImage.Information);
                if (result == MessageBoxResult.OK)
                {
                    Console.WriteLine("ok");
                }
                else
                {
                    Console.WriteLine("Cancle");
                }
    
                ToolTip toolTip = grid.ToolTip as ToolTip;
                toolTip.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
                toolTip.PlacementTarget = sender as Button;
                toolTip.Visibility = Visibility.Visible;
                toolTip.IsOpen = true;
                toolTip.Content = "zhang : 9 
    zhou : 10";
            }
    
            private void msgShow_Click4(object sender, RoutedEventArgs e)
            {
                timmer = new System.Windows.Threading.DispatcherTimer();
                timmer.Tick += Timmer_Tick;
                timmer.Interval = new TimeSpan(0, 0, 3);
                timmer.Start();
    
                MessageBoxResult result = MessageBox.Show("hello", "Information", MessageBoxButton.YesNoCancel, MessageBoxImage.Information);
                if (result == MessageBoxResult.Yes)
                {
                    Console.WriteLine("Yes");
                }
                else if (result == MessageBoxResult.Cancel)
                {
                    Console.WriteLine("No");
                }
                else
                {
                    Console.WriteLine("Cancle");
                }
    
                ToolTip toolTip = grid.ToolTip as ToolTip;
                toolTip.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
                toolTip.PlacementTarget = sender as Button;
                toolTip.Visibility = Visibility.Visible;
                toolTip.IsOpen = true;
                toolTip.Content = "zhang : 11 
    zhou : 12";
            }
    
            private void Timmer_Tick(object sender, EventArgs e)
            {
                timmer.Stop();
    
                IntPtr mbWnd = FindWindow(null, "Information");
                if (mbWnd != IntPtr.Zero)
                {
                    SendMessage(mbWnd, WM_CLOSE, new IntPtr(7), IntPtr.Zero);
                }
            }
    
            private void msgShow_MouseLeave(object sender, MouseEventArgs e)
            {
                ToolTip toolTip = grid.ToolTip as ToolTip;
                toolTip.Visibility = Visibility.Hidden;
            }
        }
    }
    
  • 相关阅读:
    2020年捌月份生活随笔
    2020年柒月份生活随笔
    2020年陆月份生活随笔
    第二次:郑州银行杯|2019郑州国际马拉松
    第一次:海尔|2017年青岛马拉松
    专项测试技能和线上线下监控
    实用
    Oracle 数据库 有用的sql语句
    Qt demo
    springboot demo
  • 原文地址:https://www.cnblogs.com/keyiei/p/6471658.html
Copyright © 2020-2023  润新知