[求助]怎样在cad中获取鼠标右击事件?
<p></p><p>下面是我用关键字的有点问题,请大家帮我看看怎么回事。我想在注记的时候通过鼠标右键来结束程序,该怎么弄呢?</p><p>ption Explicit</p><p><br/>Private Const VK_ESCAPE = &H1B ' 代表Esc键<br/>Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer<br/>Sub ll()<br/>Dim cn As New ADODB.Connection<br/>Dim gdp As New ADODB.Recordset<br/>Dim sqllj As String, jfh As String<br/>Dim maxzdh As Integer, zdh As Integer '最大宗地号、宗地号<br/>Dim zjpoint(0 To 2) As Double '注记点坐标<br/>Dim textobj As AcadText<br/>Dim tc As AcadLayer<br/>Dim msg As String<br/>msg$ = "请输入街坊号:"<br/>i: jfh = Trim(InputBox(msg$, "数据输入", " 320506432002"))<br/>If jfh = "" Then<br/> MsgBox "街坊号输入有误,请重新输入"<br/> GoTo i<br/> End If<br/>sqllj = "provider=sqloledb.1;password= ;persist security info=true;user id=sa;initial catalog=wzdb ;data source=hbxx"<br/>cn.Open sqllj<br/>gdp.Open "select zd=max(description) from gdp where pid in (select lpid from gdlp where isvirtual =0) and eoid in (select eoid from gdeo where description='" & jfh & "')", cn, adOpenDynamic, adLockBatchOptimistic<br/>If Not gdp.EOF Then<br/> maxzdh = gdp.Fields("zd")<br/>End If<br/>gdp.Close<br/>cn.Close<br/>Dim returnPnt As Variant<br/>Dim ptPrevious As Variant<br/>Dim strKeyWords As String<br/> strKeyWords = "W E O"<br/> Dim objPline As AcadLWPolyline<br/>NEXTPOINT:<br/> ' 设置关键字<br/> ThisDrawing.Utility.InitializeUserInput 128, strKeyWords<br/> BeginShortcutMenuDefault<br/> returnPnt = ThisDrawing.Utility.GetPoint(, "请点取宗地号注记位置:<结束(e)>: ")<br/> If Err Then ' 在错误处理中判断用户输入的关键字<br/> If StrComp(Err.Description, "用户输入的是关键字", 1) = 0 Then<br/> Dim strInput As String<br/> strInput = ThisDrawing.Utility.GetInput<br/> Err.Clear</p><p> ' 根据输入的关键字进行相应的处理<br/> If StrComp(strInput, "e", vbTextCompare) = 0 Then<br/> Exit Sub<br/> 'GoTo NEXTPOINT<br/> Else<br/> GoTo NEXTPOINT<br/> End If<br/> 'ElseIf StrComp(Err.Description, "自动化 (Automation) 错误", vbTextCompare) = 0 Then<br/>' ElseIf Err.Number = -2147352567 Then<br/>' Err.Clear<br/>' Exit Sub<br/> Else<br/> Err.Clear<br/> ' 判断用户是否按下了Esc键<br/> If CheckKey(VK_ESCAPE) = True Then<br/> Exit Sub<br/> End If<br/> End If<br/> Else<br/> zjpoint(0) = returnPnt(0)<br/> zjpoint(1) = returnPnt(1)<br/> zjpoint(2) = returnPnt(2)<br/> zdh = maxzdh + 1<br/> Set textobj = ThisDrawing.ModelSpace.AddText(zdh, zjpoint, 2)<br/> textobj.Update<br/> maxzdh = maxzdh + 1<br/> GoTo NEXTPOINT<br/> End If<br/> <br/> ' Return a point using a prompt<br/>'returnPnt = ThisDrawing.Utility.GetPoint(, "请点取宗地号注记位置: ")</p><p><br/> 'Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)<br/> ThisDrawing.Application.ZoomAll<br/> </p><p>End Sub<br/><br/>Private Function CheckKey(lngKey As Long) As Boolean<br/> If GetAsyncKeyState(lngKey) Then<br/> CheckKey = True<br/> Else<br/> CheckKey = False<br/> End If<br/>End Function<br/></p>
页:
[1]