左键按下灵敏度 [英] Left Button Down Sensitivity

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

问题描述

我有一个OnRButtonDown函数..如果该点与数组中我的节点(DOUBLE中的X,Y)相符,它将显示一个对话框...

 如果(((post.x> = nodeX [j]- 5  || post.x< = nodeX [j] +5)&&(post.y> = nodeY [j]- 5  || post.y< = nodeY [j] +5))



该代码无效,我单击的所有区域均为TRUE ...
我想要当我在节点附近按下左键时也会显示对话框...

 如果(post.x == nodeX [j]&& post.y == nodeY [j]) 

上面的代码让我厌倦了精确的指针..
有没有简单的解决方案?或MFC为此提供特定的代码?
谢谢

解决方案

必须为:
if(post.x> = nodeX [j] -5 && post.x< = nodeX [j] +5 && post.y> = nodeY [j] -5 && post.y< = nodeY [j ] +5)


为什么使用nodeX和nodeY-使用POINT node []或结构
使用PtInRect函数
http://msdn.microsoft.com/zh-cn/library/dd162882(v = vs.85).aspx


尝试一下并考虑一下逻辑运算符:

if(post.x>=nodeX[j]-5 && post.x<=nodeX[j]+5 && post.y>=nodeY[j]-5 && post.y<=nodeY[j]+5)


如果要使用int变量,则还可以为敏感区域创建一个CRect并使用CRect::PtInRect().


I have a OnRButtonDown function..and it will show a dialog box if the point fit with my nodes (X,Y in DOUBLE) in an Array...

if((post.x>=nodeX[j]-5 || post.x<=nodeX[j]+5) && (post.y>=nodeY[j]-5 || post.y<=nodeY[j]+5))



that code doesn''t works, all area i click is TRUE for it...
I want when i press left button nearby the node it''ll show the dialog as well...

if(post.x==nodeX[j] && post.y==nodeY[j])



Code above makes me tired to precise the pointer..
Is there any simple solution? or MFC provide a specific code for it?
Thank You

解决方案

Must be:
if( post.x >= nodeX[j]-5 && post.x <= nodeX[j]+5 && post.y >= nodeY[j]-5 && post.y <= nodeY[j]+5)


Why nodeX and nodeY - use POINT node[] or structure
Use PtInRect function
http://msdn.microsoft.com/en-us/library/dd162882(v=vs.85).aspx


Try this and think about the logical operators:

if(post.x>=nodeX[j]-5 && post.x<=nodeX[j]+5 && post.y>=nodeY[j]-5 && post.y<=nodeY[j]+5)


If you would use int vars, you may also create a CRect for your sensitive area and use CRect::PtInRect().


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

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