鼠标在一段时间内静止贴出提示标签的效果
来源:互联网 发布:windows域的作用 编辑:程序博客网 时间:2024/05/19 08:45
后台代码:<span style="font-family: Arial, Helvetica, sans-serif;">public partial class MainWindow : Window</span>
{ public MainWindow() { InitializeComponent(); } DispatcherTimer dtimer = new DispatcherTimer(); Point p; private void Grid_MouseEnter(object sender, MouseEventArgs e) { Point p = Mouse.GetPosition(e.Source as IInputElement); textBox1.Text = p.X.ToString() + ", " + p.Y.ToString(); } #region 鼠标悬浮在按钮上1s private void startTimer(object sender, MouseEventArgs e) { if (dtimer.IsEnabled == true) { dtimer.Stop(); } dtimer = new DispatcherTimer(); dtimer.Interval = TimeSpan.FromMilliseconds(1000); dtimer.Tick += show; dtimer.Start(); dtimer.Tag = sender; p = e.GetPosition(e.Source as IInputElement); } private void stopTimer() { if (dtimer.IsEnabled == true) { dtimer.Stop(); } } private void show(object o, EventArgs e) { DispatcherTimer objTimer = (DispatcherTimer)o; Button objButton = (Button)objTimer.Tag; MessageBox.Show(p.X.ToString() + "," + p.Y.ToString() + "\n" + objButton.Content.ToString()); dtimer.Stop(); } #endregion #region 各个按钮的悬浮事件、鼠标离开事件 private void btnOK_MouseMove(object sender, MouseEventArgs e) { startTimer(sender, e); } private void btnOK_MouseLeave(object sender, MouseEventArgs e) { stopTimer(); } private void button1_MouseMove(object sender, MouseEventArgs e) { startTimer(sender, e); } private void button1_MouseLeave(object sender, MouseEventArgs e) { stopTimer(); } #endregion }
<span style="font-family: Arial, Helvetica, sans-serif;">前台代码:</span><span style="font-family: Arial, Helvetica, sans-serif;"><pre name="code" class="html"><Window x:Class="MouseEnterMakeTag.MainWindow"</span>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" > <Grid MouseEnter="Grid_MouseEnter"> <Button Content="按钮1" Height="61" HorizontalAlignment="Left" Margin="12,12,0,0" Name="btnOK" VerticalAlignment="Top" Width="61" MouseMove="btnOK_MouseMove" MouseLeave="btnOK_MouseLeave" /> <TextBox Height="23" HorizontalAlignment="Left" Margin="371,12,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" /> <Button Content="按钮2" Height="61" HorizontalAlignment="Left" Margin="12,79,0,0" Name="btnCancel" VerticalAlignment="Top" Width="61" MouseMove="button1_MouseMove" MouseLeave="button1_MouseLeave" /> </Grid></Window>
0 0
- 鼠标在一段时间内静止贴出提示标签的效果
- 检索出一段时间内的所有节假日
- winform 判断鼠标在一段时间内是否移动
- wpf 判断鼠标在一段时间内是否移动
- 一段时间内的迷惑
- 在一段时间内的记录加上30分钟
- flex将一段时间内的月份放在集合中
- java算出一段时间内,这段时间内今年所有的周,并且还有每周的起止时间。
- 统计一段时间内的sql_id
- 列举出一段时间内内占用的cpu最多的n个进程
- oracle 查询出一段时间内连续时间间隔的记录集
- 查询:一段时间内;最新的纪录
- 用hibernate查询一段时间内的记录
- mysql查一段时间内的数据
- 统计一段时间内新建的session数
- 如何获取一段时间内的日期列表
- 遍历一段时间内的所有日期
- sparkstreaming统计一段时间内的热搜词
- 第十周项目二:M$pszi$y是什么意思?
- Dockerfile指令
- html2canvas截图英文长字符串效果不一致问题解决
- doubango简介
- UIScrollView & UIPageControl 的创建
- 鼠标在一段时间内静止贴出提示标签的效果
- 宏定义技巧
- SQL Server数据库维护系列之(一)数据库安全
- CGContext的基本认识
- 按花生酱,赞不绝口——敏捷12准则的敏捷解释
- 第十周 项目一:程序填充于阅读(3)
- POJ 2446 Chessboard(二分图匹配)
- poj1472
- 程序运行时的缺页异常是怎么发生和捕获的