谢谢英雄无敌!用me.hide&me.show行不通,我试过,VB窗体获得焦点以后只是在任务栏里闪烁三下,键盘输入仍然在CAD的command栏里。我需要选择的时候CAD激活,选择完后输入的内容进入VB窗体的textbox1中,但是用APPactivate激活CAD容易,但从CAD返回VB窗体怎么弄都只是该窗体闪烁三次后失去焦点。也不知道是不是我自己设置的问题。 Private Sub Form_Load() On Error Resume Next 'Dim myval As Long 'myval = SetWindowPos(Form1.hwnd, -1, 0, 0, 0, 0, 3) Set acadapp = GetObject(, "AutoCAD.Application") acadapp.Visible = True Set acaddoc = acadapp.ActiveDocument Set acadms = acaddoc.ModelSpace Dim objsset As AcadSelectionSet Set objsset = acaddoc.SelectionSets.Item("beam") objsset.Delete 'If Err Then ' Err.Clear Set objsset = acaddoc.SelectionSets.Add("beam") 'End If
Dim filtertype(7) As Integer Dim filterdata(7) As Variant filtertype(0) = -4 filterdata(0) = "<or" filtertype(1) = 8 '图层名 filterdata(1) = "!水平标注" filtertype(2) = 8 '图层名 filterdata(2) = "!垂直标注" filtertype(3) = -4 filterdata(3) = "or>" filtertype(4) = -4 filterdata(4) = "<or" filtertype(5) = 0 '对象类型 filterdata(5) = "Text" filtertype(6) = 0 '对象类型 filterdata(6) = "MText" filtertype(7) = -4 filterdata(7) = "or>" Me.Hide objsset.SelectOnScreen filtertype, filterdata
Me.Show End Sub |