【发布时间】:2021-05-11 11:28:25
【问题描述】:
如何使按钮具有下推效果?我不是在谈论FlatStyle popup。它必须“向下”,可以这么说,在它被点击的那一秒内,当鼠标点击结束时“向上”。
这是迄今为止我尝试过的代码。你有更好的想法吗?
Dim RememberXpos As Integer = Button1.Location.X
Dim RememberYpos As Integer = Button1.Location.Y
Dim ButtonXEnd As Integer = Button1.Location.X + Button1.Size.Width
Dim ButtonYEnd As Integer = Button1.Location.Y + Button1.Size.Height
Dim oldSize As Size = Button1.Size
' shrink
Button1.Size = New Size(CInt(Button1.Size.Width * 0.9), CInt(Button1.Size.Height * 0.9))
' center the button
Dim ButtonXEndeDiffHalf As Integer = CInt(Math.Round((ButtonXEnd - (Button1.Location.X + Button1.Size.Width)) / 2.0, 0))
Dim ButtonYEndeDiffHalf As Integer = CInt(Math.Round((ButtonYEnd - (Button1.Location.Y + Button1.Size.Height)) / 2.0, 0))
Button1.Location = New Point(Button1.Location.X + ButtonXEndeDiffHalf, Button1.Location.Y + ButtonYEndeDiffHalf)
Button1.Update()
System.Threading.Thread.Sleep(150)
' re-enlarge
Button1.Size = oldSize
Button1.Location = New Point(RememberXpos, RememberYpos)
【问题讨论】:
标签: vb.net button controls mouseclick-event