模拟 Winforms 按钮点击动画 [英] Simulate Winforms Button Click Animation

查看:27
本文介绍了模拟 Winforms 按钮点击动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,在我的按钮内有一个图像控件.当用户单击图像时,我想为按钮设置动画,以便看起来按钮被按下.我真的不在乎实际的按钮按下事件是否触发——这是我想看到的按下按钮的错觉.

I have a button and inside my button I have an image control. When the users click on the image I'd like to animate the button so it appears the button was pressed. I don't really care whether the actual button press event fires or not--it's the illusion of a button press I want to see.

注意:我在网络上看到的唯一选项涉及直接写入 Windows API——我真的不想涉及这种复杂性和不可升级性.

Note: the only options I see on the web involve writing directly to the Windows API--a level of complexity and non-upgradability I really don't want to get into.

推荐答案

我最终让我的 picturbox 看起来像一个按钮,给它一个凸起的边框样式.然后在 mouseclick 事件中,我通过将边框样式更改数百毫秒来模拟按下按钮的外观.

I ended up making my picturbox look like a button by giving it a raised border style. Then on the mouseclick event I simulate the look of a button press by changing the border style for a few hundred miliseconds.

Private Sub simulateButtonPress(ByRef pictureBox As Infragistics.Win.UltraWinEditors.UltraPictureBox)
    pictureBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Inset
    Application.DoEvents()
    System.Threading.Thread.Sleep(400)
    pictureBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Raised
    Application.DoEvents()
End Sub

这篇关于模拟 Winforms 按钮点击动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆