进度条点击=>更改当前曲目播放位置
我正在winforms 中制作一个音乐播放器。我有一个进度条,当我单击进度条上的某个位置时,我想获取该位置的整数(从 1 到 100,即当我想要到达歌曲中的某个点时)。我怎样才能做到这一点?
问候, 亚历山德鲁·巴德斯库
i am making a music player in winforms. i have a progress bar and when i click on a position along the progress bar, i want to get the int for that position ( from 1 to 100 , i.e. for when i want to get to a certain point in my song ) . How can i do that ?
Regards,
Alexandru Badescu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用 TrackBar 控件,以及 这可能是一篇高级文章,希望对您有所帮助。
祝你好运。
Use TrackBar control, and this is may an advance one, I hope it helps you.
Good luck.
试试这个:
Try this:
您可以使用必须放置在进度条上的控件——例如一个小子弹。
现在,如果您使用代码,
请将控件的名称放置在控件 x/y 决定坐标的位置。
请注意,您必须移动进度条上的控件以进行简化使用图片框并使用 keydown 事件将其并排移动
you can use a control that have to be placed on the progress bar --like a small bullet .
now if you use the code
place the name of the control at the position of control x/y decides the coordinates.
make a note that you have to move the control on the progress bar for simplifications use a picture box and use the keydown event to move it side by side
该值会显示一个与进度条上单击位置相关的值。这里的取值范围是从0到100%计算的。它还与进度条的宽度有关,因此范围将保持固定为百分比逻辑。
我知道这个问题很久以前就被问过,但它没有正确的解决方案。现在就是这样。
This one brings up a value in relation to the position where the click was done on the progressbar. The value range here is calculated from 0 to 100%. Its also in relation to the width of the progressbar so the range will stay fixed to percentage logic.
I know this question was asked a long time ago, but it was out of the right solution. Here it is now.
好吧,您可以使用图片框来模拟进度条...有一种方法可以根据当前进度部分填充它,并连接 MouseDown 事件(这将为您提供鼠标位置,然后您可以相应地缩放)。
Well you could use a picturebox to simulate a progress bar ... have a method to partially fill it based on current progress, and wire up the MouseDown event (this will provide you with the mouse position which you can then scale accordingly).