dfan 发表于 2009-9-3 17:04:00

请问如何将CAD作为VB的子窗口?

请问如何将CAD作为VB的子窗口?将CAD嵌套入VB,作为VB的一个子窗体。

home 发表于 2009-9-3 18:21:00

<p>'/////autocad软件窗口能够出现在VB窗体中<br/>Option Explicit</p><p>Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long<br/>Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long<br/>Private lHwnd As Long</p><p>Private Sub Form_Load()</p><p>&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; On Error GoTo ErrTrap<br/>&nbsp;&nbsp;&nbsp;&nbsp; Dim acadApp As Object<br/>&nbsp;&nbsp;&nbsp;&nbsp; Set acadApp = CreateObject("AutoCAD.Application")<br/>&nbsp;&nbsp;&nbsp;&nbsp; acadApp.Visible = True<br/>&nbsp;&nbsp;&nbsp;&nbsp; lHwnd = GetParent(GetParent(acadApp.Activedocument.hwnd))<br/>&nbsp;&nbsp;&nbsp;&nbsp; If lHwnd = 0 Then Exit Sub<br/>&nbsp;&nbsp;&nbsp;&nbsp; SetParent lHwnd, Form1.hwnd<br/>&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub</p><p>&nbsp;&nbsp;&nbsp;&nbsp; <br/>ErrTrap:<br/>&nbsp;&nbsp;&nbsp;&nbsp; On Error GoTo 0<br/>End Sub</p><p>Private Sub Form_Unload(Cancel As Integer)<br/>&nbsp;&nbsp;&nbsp;&nbsp; If lHwnd = 0 Then Exit Sub<br/>&nbsp;&nbsp;&nbsp;&nbsp; SetParent lHwnd, 0<br/>End Sub</p>

dfan 发表于 2009-9-3 21:58:00

楼上的方案非常好。高手就是高手。谢谢楼上的。再请问下,控制CAD窗口大小用什么命令呢?就是控制CAD窗口在VB界面里的大小,CAD窗口的大小随VB界面大小的改变而改变。

home 发表于 2009-9-4 16:12:00

<p>Declare Function SetWindowPos&amp; Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)</p><p>这个函数应该可以,自己研究吧</p>

dfan 发表于 2009-9-4 23:21:00

谢谢“home”兄!!

烟雨.江南 发表于 2009-9-5 15:34:00

<p>又学习到一招。</p>

天之雨露 发表于 2009-9-8 03:38:00

有这种方法?我没不知道,过来学习一下

chpmould 发表于 2009-9-17 23:49:00

控制CAD窗口大小用什么命令呢?就是控制CAD窗口在VB界面里的大小,CAD窗口的大小随VB界面大小的改变而改变

1983caobing 发表于 2009-12-9 20:01:00

挺不错的,请问如何能够使得cad窗体脱离vb界面呢

陈亚娣 发表于 2014-2-27 16:57:51

高手,要好好学习
页: [1]
查看完整版本: 请问如何将CAD作为VB的子窗口?