[求助]在多窗体中怎么实现把cad的窗体做为一个子窗体显示
<p>在多窗体中怎么实现把cad的窗体做为一个子窗体显示</p><p>求大哥大姐为小弟解答</p><p>用代码怎么实现??</p> 我也想知道这个问题,求好心人回答! 本帖最后由 作者 于 2008-8-14 15:02:13 编辑 <br /><br /> <p><font color="#0000ff">Private</font> Declare <font color="#0000ff">Function</font> SetParent Lib <font color="#880000">"user32"</font><font color="#ff0000">(</font>ByVal hWndChild <font color="#0000ff">As</font> Long, ByVal hWndNewParent <font color="#0000ff">As</font> Long<font color="#ff0000">)</font>
<font color="#0000ff">As</font> Long<br/><font color="#0000ff">Private</font> Declare <font color="#0000ff">Function</font> GetParent Lib <font color="#880000">"user32"</font>
<font color="#ff0000">(</font>ByVal <font color="#0000ff">hwnd</font>
<font color="#0000ff">As</font> Long<font color="#ff0000">)</font>
<font color="#0000ff">As</font> Long<br/><font color="#0000ff">Private</font> Declare <font color="#0000ff">Function</font> GetWindowRect Lib <font color="#880000">"user32"</font>
<font color="#ff0000">(</font>ByVal <font color="#0000ff">hwnd</font>
<font color="#0000ff">As</font> Long, lpRect <font color="#0000ff">As</font> RECT<font color="#ff0000">)</font>
<font color="#0000ff">As</font> Long<br/><font color="#0000ff">Private</font> Declare <font color="#0000ff">Function</font> SetWindowPos Lib <font color="#880000">"user32"</font>
<font color="#ff0000">(</font>ByVal <font color="#0000ff">hwnd</font>
<font color="#0000ff">As</font> Long, ByVal hWndInsertAfter <font color="#0000ff">As</font> Long, ByVal x <font color="#0000ff">As</font> Long, ByVal y <font color="#0000ff">As</font> Long, ByVal cx <font color="#0000ff">As</font> Long, ByVal cy <font color="#0000ff">As</font> Long, ByVal wFlags <font color="#0000ff">As</font> Long<font color="#ff0000">)</font>
<font color="#0000ff">As</font> Long<br/><br/><font color="#0000ff">Private</font>
<font color="#0000ff">Type</font> RECT<br/> <font color="#0000ff">Left</font>
<font color="#0000ff">As</font> Long<br/> <font color="#0000ff">Top</font>
<font color="#0000ff">As</font> Long<br/> <font color="#0000ff">Right</font>
<font color="#0000ff">As</font> Long<br/> Bottom <font color="#0000ff">As</font> Long<br/><font color="#0000ff">End</font>
<font color="#0000ff">Type</font><br/><br/><font color="#0000ff">Private</font> acadApp <font color="#0000ff">As</font> Object <br/><font color="#0000ff">Private</font> lHwnd <font color="#0000ff">As</font> Long <font color="#008000">'保存ACAD应用程序的窗口句柄</font><br/><font color="#0000ff">Private</font> lState <font color="#0000ff">As</font> Long <font color="#008000">'保存ACAD的初始窗口状态</font><br/><font color="#0000ff">Private</font> r <font color="#0000ff">As</font> RECT <font color="#008000">'保存ACAD的初始窗口位置</font><br/><br/><font color="#0000ff">Private</font>
<font color="#0000ff">Sub</font> Form_Load<font color="#ff0000">(</font><font color="#ff0000">)</font><br/><br/> <br/> <font color="#0000ff">On</font>
<font color="#0000ff">Error</font>
<font color="#0000ff">GoTo</font> ErrTrap<br/> <font color="#0000ff">Set</font> acadApp <font color="#0000ff">=</font>
<font color="#0000ff">GetObject</font><font color="#ff0000">(</font>, <font color="#880000">"AutoCAD.<font color="#0000ff">Application</font>"</font><font color="#ff0000">)</font><br/> acadApp.<font color="#0000ff">Visible</font>
<font color="#0000ff">=</font> True<br/> lHwnd <font color="#0000ff">=</font> GetParent<font color="#ff0000">(</font>GetParent<font color="#ff0000">(</font>acadApp.<font color="#0000ff">Activedocument</font>.hwnd<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#0000ff">If</font> lHwnd <font color="#0000ff">=</font> 0 <font color="#0000ff">Then</font>
<font color="#0000ff">Exit</font>
<font color="#0000ff">Sub</font><br/> lState <font color="#0000ff">=</font> acadApp.<font color="#0000ff">WindowState</font><br/> acadApp.<font color="#0000ff">WindowState</font>
<font color="#0000ff">=</font> 1 <font color="#008000">'设置ACAD的窗口状态为默认,用于保存窗口位置。</font><br/> GetWindowRect lHwnd, r<br/> SetParent lHwnd, Form1.<font color="#0000ff">hwnd</font><br/> Form1.ScaleMode <font color="#0000ff">=</font> vbPixels <font color="#008000">'将VB窗体默认的缇单位改为以像素为单位。</font><br/> SetWindowPos lHwnd, 0, Form1.ScaleLeft, Form1.ScaleTop, Form1.<font color="#0000ff">ScaleWidth</font>, Form1.<font color="#0000ff">ScaleHeight</font>, 0<br/> <font color="#0000ff">Exit</font>
<font color="#0000ff">Sub</font><br/><br/> <br/>ErrTrap:<br/> <font color="#0000ff">On</font>
<font color="#0000ff">Error</font>
<font color="#0000ff">GoTo</font> 0<br/><font color="#0000ff">End Sub</font><br/><br/><font color="#0000ff">Private</font>
<font color="#0000ff">Sub</font> Form_Resize<font color="#ff0000">(</font><font color="#ff0000">)</font><br/> SetWindowPos lHwnd, 0, Form1.ScaleLeft, Form1.ScaleTop, Form1.<font color="#0000ff">ScaleWidth</font>, Form1.<font color="#0000ff">ScaleHeight</font>, 0<br/><font color="#0000ff">End Sub</font><br/><br/><font color="#0000ff">Private</font>
<font color="#0000ff">Sub</font> Form_Unload<font color="#ff0000">(</font>Cancel <font color="#0000ff">As</font> Integer<font color="#ff0000">)</font><br/> <font color="#0000ff">If</font> lHwnd <font color="#0000ff">=</font> 0 <font color="#0000ff">Then</font>
<font color="#0000ff">Exit</font>
<font color="#0000ff">Sub</font><br/> SetParent lHwnd, 0<br/> SetWindowPos lHwnd, 0, r.<font color="#0000ff">Left</font>, r.<font color="#0000ff">Top</font>, r.Right <font color="#0000ff">-</font> r.<font color="#0000ff">Left</font>, r.Bottom <font color="#0000ff">-</font> r.<font color="#0000ff">Top</font>, 0<br/> acadApp.<font color="#0000ff">WindowState</font>
<font color="#0000ff">=</font> lState<br/> <font color="#0000ff">Set</font> acadApp <font color="#0000ff">=</font> Nothing<br/><font color="#0000ff">End Sub</font><br/><a href="http://www.mjtd.com/bbs/Archive_view.asp?boardID=4&ID=10991"></a></p><p>参考页面: <a href="http://www.mjtd.com/bbs/Archive_view.asp?boardID=4&ID=10991">http://www.mjtd.com/bbs/Archive_view.asp?boardID=4&ID=10991</a></p>
页:
[1]