连续处理按键 [英] handle key down continuosly

查看:101
本文介绍了连续处理按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


用户只要按住鼠标左键,我就想连续绘画,除非他释放它.

有任何建议.

解决方案

您可以处理WM_MBUTTONDOWN和WM_MBUTTONUP事件.

发生按钮按下事件时调用SetCapture,以便即使他将光标移出窗口也可以得到按钮按下事件.

我不确定连续"绘制的含义-但是在按下按钮和向上消息之间,您将要连续"使绘制区域无效(如cPallini的建议).

根据您连续"的含义,使用计时器来定期使它无效,或者在鼠标移动消息上使它无效,或者根据您要绘画的基础事物的变化在实际需要重绘时使它无效. /blockquote>

您可以定期通过对鼠标输入进行采样GetAsyncKeyState [ ^ ]并相应地使绘制区域无效.


Hi ,
As soon as the user holds down the left mouse button, i want to paint continuously unless he releases it.

Any suggestions.

解决方案

You could handle the WM_MBUTTONDOWN and WM_MBUTTONUP events.

Call SetCapture when you get the button down event so that you get the button up event even if he moves the cursor off the window.

I''m not sure what you mean by paint "continuously" -- but between the button down and up messages you will want to invalidate the paint region (as suggested by cPallini) "continuously".

Depending on what you mean by "continuously", use a timer to periodically invalidate it, or invalidate it on mouse move messages, or invalidate it when whatever you actually need to repaint it based on a change in the underlying thing you are painting.


You may periodically sample mouse input via GetAsyncKeyState[^] and invalidate the paint region accordingly.


这篇关于连续处理按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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