Andre Kaufmann wrote:
Amu wrote:
Hi i am stuck up in a part of project where i have to inherit the VC++
template classes into C#.net. Please provide me the solution for this .
Hi,
best solution IMHO would be to use VC++ 2005 and write some wrapper
classes in C++/CLI. Which then can be directly used from C#.
You can use generics and map them to the associated template class.
Though generics are more restricted than templates, so you possibly
can't directly wrap the template classes by using generics.
Another solution would be wrapping the template classes in COM
interfaces or by using flat functions. Surely with this method you can't
use template / generic parameters.
VC++ 2005 Express Edition, can be downloaded from Microsoft.
Hope that helps,
Andre
The C++ classes which I mentioned are classes which are derived from
MFC standard classes like CPropertyPage and CPropertySheet.
These template classes are simple MFC classes which are packaged as a
DLL. Since the Implementation part of this DLL is huge, I can't think
of rewriting the whole code in C#.
I have attached the the class template code snippet for your reference.
I need to inherit from this class, DTMPOPropertyPa ge in C#.
How can I achieve this?
class AFX_EXT_CLASS DTMPOPropertyPa ge : public CPropertyPage
{
// Construction
public:
//DECLARE_DYNAMIC (DTMPOPropertyP age)
DTMPOPropertyPa ge(FDTXmtrDoc *doc, UINT nIDTemplate = 0,
UINT nCaption = 0);
~DTMPOPropertyP age();
//{{AFX_DATA(CXmt rPropertyPage)
// NOTE - ClassWizard will add data members
here.
// DO NOT EDIT what you see in these blocks
of generated code !
//}}AFX_DATA
// Attributes
public:
// Access to determine if performing CANCEL processing.
// Pages use this to avoid validation
//BOOL InCancelProcess ing ();
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(C XmtrPropertyPag e)
// Define a generic OnKillFocus handler for use by all
pages
//afx_msg void OnKillFocus();
virtual void DoDataExchange( CDataExchange* pDX); //
DDX/DDV support
//}}AFX_VIRTUAL
virtual BOOL OnInitDialog() { return
CPropertyPage:: OnInitDialog(); }
virtual BOOL OnSetActive() { UpdateData(FALS E); return
CPropertyPage:: OnSetActive(); }
//virtual BOOL OnKillActive();
// access to BO parameters
virtual void SetValues() = 0;
virtual void UpdateDocument( ) = 0;
// access to AppInfo
FDTAppInfo *GetAppInfo();
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CXmtr PropertyPage)
// NOTE: the ClassWizard will add member
functions here
//}}AFX_MSG
//afx_msg LRESULT OnCommandHelp(W PARAM, LPARAM lParam);
//afx_msg LRESULT OnShiftF1Help(W PARAM, LPARAM lParam);
//afx_msg void OnHelp( );
afx_msg BOOL OnHelpInfo( HELPINFO* lpHelpInfo );
//_DLLPROC DECLARE_MESSAGE _MAP()
DTMPOPropertySh eet *GetSheet();
// pointer to document
FDTXmtrDoc *mDoc;
private:
void SetSheet( DTMPOPropertySh eet *ps );
friend class DTMPOPropertySh eet;
mDTMPOPropertyP age *m;
};