如何判断鼠标在指定窗体里按下鼠标左键?在线等!!(100分)

  • 主题发起人 夫罗多
  • 开始时间
这段代码可以得到在该窗口是否按下了左键
 
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;<br> &nbsp;Shift: TShiftState; X, Y: Integer);<br>begin<br> &nbsp;if Button=left &nbsp;begin<br> &nbsp; &nbsp;ShowMessage('left btn press');<br> &nbsp;end;<br>end;
 
rRect := Form.Rect;<br> &nbsp;if (X &gt; rRect.Left) and (X &lt; rRect.Right)<br> &nbsp; &nbsp;and (Y &gt; rRect.Top) and ( Y &lt; rRect.Bottom) then<br> &nbsp;begin<br> &nbsp; &nbsp;ShowMessage('Ok');<br> &nbsp;end;
 
那还不简单:<br> &nbsp;if Msg.message = WM_LBUTTONDOWN then<br> &nbsp;if (X &gt; rRect.Left) and (X &lt; rRect.Right)<br> &nbsp; &nbsp;and (Y &gt; rRect.Top) and ( Y &lt; rRect.Bottom) then<br> &nbsp;begin<br> &nbsp; &nbsp;showmessage('left btn pressed')<br> &nbsp;end;
 
rRect := btn5.Rect;<br> &nbsp;if (X &gt; rRect.Left) and (X &lt; rRect.Right)<br> &nbsp; &nbsp;and (Y &gt; rRect.Top) and ( Y &lt; rRect.Bottom) then<br> &nbsp;begin<br> &nbsp; &nbsp;ShowMessage('Ok');<br> &nbsp;end;
 
rRect := btn5.BoundRect;<br> &nbsp;if (X &gt; rRect.Left) and (X &lt; rRect.Right)<br> &nbsp; &nbsp;and (Y &gt; rRect.Top) and ( Y &lt; rRect.Bottom) then<br> &nbsp;begin<br> &nbsp; &nbsp;ShowMessage('Ok');<br> &nbsp;end;
 
就是这么写的
 
if Button=mbleft &nbsp;then<br>if (X &gt;96) and (X &lt; 128)<br> &nbsp; &nbsp;and (Y &gt; 122) and ( Y &lt; 145) then<br> &nbsp;begin<br> &nbsp; &nbsp;ShowMessage('Ok');<br> &nbsp;end;
 
我哪有什么DPR,我又不做你这个东东,<br>你意思可能没表达清楚
 
你语文成绩一定不及格
 
我是想要一个 &nbsp;完整的 监视鼠标在计算器上&quot;5&quot;的位置按下左键 的程序代码 &nbsp;只要在5的位置按下左键就ShowMessage()<br><br><br>大哥 你这下明白了吗?
 
已经很清楚了吧。<br>if (X &gt;96) and (X &lt; 128)<br> &nbsp; &nbsp;and (Y &gt; 122) and ( Y &lt; 145) then<br>以上来确定有效范围,再<br>if Button = mbLeft then<br> &nbsp; &nbsp;ShowMessage('Left');<br> &nbsp;if Button = mbRight then<br> &nbsp; &nbsp;ShowMessage('Right');<br>判断是左键还是右键
 

Similar threads

回复
0
查看
658
不得闲
S
回复
0
查看
625
SUNSTONE的Delphi笔记
S
S
回复
0
查看
706
SUNSTONE的Delphi笔记
S
S
回复
0
查看
956
SUNSTONE的Delphi笔记
S
顶部