请救救小弟吧。(100分)

  • 主题发起人 andykwok
  • 开始时间
A

andykwok

Unregistered / Unconfirmed
GUEST, unregistred user!
======================================<br>前言<br>======================================<br>小弟在搞Solidworks的二次开发,但由于VC++对数据库方面的支持不及DELPHI,所以<br>我把Solidworks的API封装成Delphi的XXX_TLB.PAS,一切都好象和C++一样的能实现对<br>Solidworks的二次开发,但小弟还有一个技术没有掌握。<br>如果谁帮小弟解决这以下的问题,我将会把我对Solidworks封装的源码公开:)这应该能<br>给Solidworks二次开发人员一些帮助吧。:)<br>======================================<br>问题:<br>======================================<br>在Solidworks的API中有一个函数FeatMgrView::GetFeatMgrViewWnd,它能近回一个CWND HANDLE。<br>请问我如何才能把Delphi开发的FORM放置到它(CWND HANDLE)上呢。<br>======================================<br>函数的说明(英文)<br>======================================<br>Description<br>This method will get the FeatureManager design tree window handle as a CWnd object. You may use this CWnd in combination with standard MFC calls to draw into this view as desired.<br>Syntax (OLE Automation)<br>retval = FeatMgrView.GetFeatMgrViewWnd ()<br>Return:<br>&nbsp;(long) retval<br>&nbsp;The CWnd handle of the FeatureManager design tree view<br>Syntax (COM)<br>status = FeatMgrView-&gt;GetFeatMgrViewWnd ( &amp;retval )<br>Output:<br>&nbsp;(long) retval<br>&nbsp;The CWnd handle of the FeatureManager design tree view<br>Return:<br>&nbsp;(HRESULT)status<br>&nbsp;S_OK if successful<br>Remarks<br>You should make this call when the FeatureManager design tree view is created with ModelDoc::CreateFeatureMgrView. This method is not needed with ModelDoc::AddFeatureMgrView since you created the view and would, therefore, already have its handle.<br><br><br>
 
CWnd::FromHandle(Form1.handle);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//--- dlephi 的Form <br><br><br>CWnd::FromHandle &nbsp;<br>static CWnd* PASCAL FromHandle( HWND hWnd );<br><br>Return Value<br><br>Returns a pointer to a CWnd object when given a handle to a window. If a CWnd object is not attached to the handle, a temporary CWnd object is created and attached. <br><br>The pointer may be temporary and should not be stored for later use.<br><br>Parameters<br><br>hWnd<br><br>An HWND of a Windows window.<br><br>CWnd Overview | &nbsp;Class Members | &nbsp;Hierarchy Chart<br><br>See Also &nbsp; CWnd::DeleteTempMap<br>
 
TO jsxjd:<br>&nbsp; &nbsp;谢谢你的回复,但这是用关于VC++如何使用Delphi的Form的,你能给出关于DELPHI如<br>何在Solidworks上显示一个窗体的代码吗?<br>&nbsp; &nbsp;注,Solidworks中提供一个返回一个窗口Handle的函数:GetFeatureMrgWND。<br>&nbsp; &nbsp;如果您是用VC++的话,你能详细一点吗?谢谢。
 
这是有关Solidworks SDK中实现把的个窗体显示到FeatureManager设计树的代码:<br>BOOL CFMView::Create()<br>{<br> LPMODELDOC2 pModelDoc;<br> LPFEATMGRVIEW pFeatMgr;<br> CRect rect;<br><br> // Get the active doc and create a feature manager view in it<br> if (TheApplication-&gt;GetSWApp()-&gt;get_IActiveDoc2( &amp;pModelDoc ) == S_OK)<br> {<br> TheApplication-&gt;SetResources(); // Ensure we are using our resources<br> //m_Bitmap.LoadMappedBitmap(IDB_BITMAP1);<br> m_Bitmap.LoadMappedBitmap(IDB_BITMAP1, 0, NULL); <br> TheApplication-&gt;ResetResources(); // Reset to SolidWorks resources<br> &nbsp; if (pModelDoc-&gt;ICreateFeatureMgrView3 ((long *)&amp;m_Bitmap, auT("自定义FeatureManager"), swFeatMgrPaneBottom, &amp;pFeatMgr) == S_OK)<br> &nbsp; {<br> &nbsp; if ( pFeatMgr == NULL )<br> &nbsp; {<br> &nbsp; AfxMessageBox(_T("ICreateFeatureMgrView returned S_OK and NULL pointer"));<br> &nbsp; }<br> &nbsp; else<br> &nbsp; {<br> &nbsp; // Create a control item to handle events for the PartDoc<br> &nbsp; m_pEventHandler = new FMFeatureManagerEvents;<br> &nbsp; m_pEventHandler-&gt;OnCreate(pFeatMgr);<br> &nbsp; m_pEventHandler-&gt;m_pFMView = this;<br> &nbsp; <br> &nbsp; // Create a window in the Feature Manager window<br> &nbsp; pFeatMgr-&gt;GetFeatMgrViewWnd((long*)&amp;m_pParent);<br> &nbsp; m_pParent-&gt;GetClientRect (&amp;rect);<br><br> &nbsp; CWnd::Create (NULL, TEXT(""), WS_CHILD | WS_VISIBLE, rect, m_pParent, 1);<br><br> &nbsp; // Create the Tree Control in our new window<br> &nbsp; m_TreeCtrl.Create (TVS_HASLINES | TVS_HASBUTTONS | TVS_EDITLABELS, rect, this, 1);<br> &nbsp; // Display the windows <br> &nbsp; ShowWindow (SW_SHOW);<br> &nbsp; MoveWindow (&amp;rect);<br> &nbsp; m_TreeCtrl.ShowWindow (SW_SHOW);<br> &nbsp; m_TreeCtrl.MoveWindow (&amp;rect);<br> &nbsp; pFeatMgr-&gt;Release();<br> &nbsp; }<br> &nbsp; }<br> &nbsp; pModelDoc-&gt;Release();<br> }<br> <br> return true;<br>}<br>
 
这是CFMVIEW的头文件:<br>class CFMView : public CWnd<br>{<br>public:<br> BOOL Create();<br>private:<br> BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);<br>protected:<br> BOOL OnDestroyNotify(bool bDeleteNotificationObject);<br>// Data<br>public:<br> CFMTreeCtrl m_TreeCtrl; // The actual Tree control<br>private:<br> CWnd *m_pParent; // Parent View of our window<br> CBitmap m_Bitmap; // Holds the image in the SolidWorks Tab<br> FMFeatureManagerEvents* m_pEventHandler;// Receives notifications from SolidWorks<br> friend class FMFeatureManagerEvents;<br> afx_msg void OnPaint();<br> DECLARE_MESSAGE_MAP()<br>};<br>
 
顶部