zoukankan      html  css  js  c++  java
  • 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;
            }
        }
    }
    
  • 相关阅读:
    css设置兄弟节点的样式(相邻的前一个节点)
    css文本强制两行超出就显示省略号,不显示省略号
    Adobe Photoshop CC2014 for MAC 详细破解步骤
    CSS实现背景图片透明和文字不透明效果
    jquery实现搜索框从中间向两边扩展(左右放大)
    微信小程序拒绝授权后提示信息以及重新授权
    linux下的 sudo ln -s 源文件 目标文件
    小程序实现倒计时:解决ios倒计时失效(setInterval失效)
    浅谈CSS高度坍塌
    sourcetree安装以及跳过sourcetree注册登录
  • 原文地址:https://www.cnblogs.com/keyiei/p/6471658.html
Copyright © 2011-2022 走看看