下面的代码是国外找的, 可以在标题栏中实现倒计时, 并且鼠标进入对话框后倒计时停止, 还能自定义对话框的位置
但是标题栏中只显示倒计时, 我需要:
1.在前面加个几个字, 例如: 倒计时:
2.对话框的位置是绝对的, 在不同分辨率下显示的地方不一样, 我想让对话框, 始终, 水平是居中, 竖直方向上, 对话框的下边离桌面的最下面50像素
找了一篇相关的文章, 但是看不太懂:
https://blog.csdn.net/wmqdn/article/details/8839753- Add-Type -Ass System.Windows.Forms
- $form1 = New-Object Windows.Forms.Form
- $timer1 = New-Object Windows.Forms.Timer
- $timer1_Tick = {
- $form1.Text = $form1.Text - 1
- if ($form1.Text -eq -1)
- {
- $form1.Close()
- }
- }
- $form1_MouseEnter = {
- $timer1.Stop()
- }
- $form1.Controls.Add($label1)
- $form1.ClientSize = '239, 80'
- $form1.Text = '10'
- $form1.StartPosition = 'Manual' #对话框的位置
- $form1.Left = 880
- $form1.Top = 780
- $form1.add_Load($form1_Load)
- $form1.add_MouseEnter($form1_MouseEnter)
- # timer1
- $timer1.Enabled = $True
- $timer1.Interval = 1000
- $timer1.add_Tick($timer1_Tick)
- $form1.ShowDialog()
复制代码 |