zhu1 发表于 2005-8-17 14:31:00

请教:如何在程序里判断我“按下鼠标右键”?

本帖最后由 作者 于 2005-8-17 15:36:32 编辑

请问,如何在程序里判断我“按下鼠标右键”?通过这样的判断我可以从某个过程中退出来

zhu1 发表于 2005-8-18 16:10:00

<P>难道这是个很难的问题吗?</P>
<P>怎么没有人回答呀</P>

mikewolf2k 发表于 2005-8-18 19:48:00

按下右键会产生一个错误,通过捕获错误号知道。具体这方面的源代码网站上有,你搜索一下。

PS122 发表于 2005-8-19 08:48:00

<P>参考一下:</P>
<P>&nbsp;</P>
<P>Public Function ClickConfirm() As Boolean<BR>&nbsp; Dim objUtil As AcadUtility<BR>&nbsp; Dim varPnt As Variant<BR>&nbsp; Dim strPrmt As String<BR>&nbsp; On Error GoTo Err_Control<BR>&nbsp; ‘strPrmt = "Left click to confirm, right click to cancel"<BR>&nbsp; strPrmt = "鼠标左键确认,右键取消"<BR>&nbsp; Set objUtil = ThisDrawing.Utility<BR>&nbsp; varPnt = objUtil.GetPoint(Prompt:=strPrmt)<BR>&nbsp; 'No error? Then they "left clicked" (or typed a point on<BR>&nbsp; 'The command line. Meh. Users are crazy.<BR>&nbsp; ClickConfirm = True<BR>Exit_Here:<BR>&nbsp; Exit Function<BR>Err_Control:<BR>&nbsp; 'Debug.Print Err.Description; Err.Number<BR>&nbsp; Select Case Err.Number<BR>&nbsp;&nbsp;&nbsp; Case -2145320928<BR>&nbsp;&nbsp;&nbsp; 'Right click with command prompt or "Enter" key<BR>&nbsp;&nbsp;&nbsp; 'User input is a keyword<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Resume Exit_Here<BR>&nbsp;&nbsp;&nbsp; Case -2147352567<BR>&nbsp;&nbsp;&nbsp; 'User pressed escape or clicked a toolbar<BR>&nbsp;&nbsp;&nbsp; 'Method 'GetPoint' of object 'IAcadUtility' failed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Resume Exit_Here<BR>&nbsp;&nbsp;&nbsp; Case Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Err.Clear<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Resume Exit_Here<BR>&nbsp; End Select<BR>End Function&nbsp; <BR>功能&nbsp; <BR>实现鼠标左键确认,右键取消功能&nbsp; <BR>语法&nbsp; <BR>ClickConfirm()&nbsp; <BR>返回值&nbsp; <BR>True为按了左键</P>

zhu1 发表于 2005-8-19 10:15:00

<P>谢谢你们,我马上去搞一下。</P>
页: [1]
查看完整版本: 请教:如何在程序里判断我“按下鼠标右键”?