A
Amu
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 .
template classes into C#.net. Please provide me the solution for this .
I may be wrong, but I really believe that compositionHi 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 .
Mathieu said:Amu a écrit :
I may be wrong, but I really believe that composition
(http://en.wikipedia.org/wiki/Object_composition) is the only way to
achieve what you are trying to.
Mathieu
Amu said: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 .
Andre said: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
Andre said: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, DTMPOPropertyPage in C#.
How can I achieve this?
class AFX_EXT_CLASS DTMPOPropertyPage : public CPropertyPage
{
// Construction
public:
//DECLARE_DYNAMIC(DTMPOPropertyPage)
DTMPOPropertyPage(FDTXmtrDoc *doc, UINT nIDTemplate = 0,
UINT nCaption = 0);
~DTMPOPropertyPage();
//{{AFX_DATA(CXmtrPropertyPage)
// 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 InCancelProcessing ();
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CXmtrPropertyPage)
// 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(FALSE); 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(CXmtrPropertyPage)
// NOTE: the ClassWizard will add member
functions here
//}}AFX_MSG
//afx_msg LRESULT OnCommandHelp(WPARAM, LPARAM lParam);
//afx_msg LRESULT OnShiftF1Help(WPARAM, LPARAM lParam);
//afx_msg void OnHelp( );
afx_msg BOOL OnHelpInfo( HELPINFO* lpHelpInfo );
//_DLLPROC DECLARE_MESSAGE_MAP()
DTMPOPropertySheet *GetSheet();
// pointer to document
FDTXmtrDoc *mDoc;
private:
void SetSheet( DTMPOPropertySheet *ps );
friend class DTMPOPropertySheet;
mDTMPOPropertyPage *m;
};
Amu said:[...]Andre said:Amu wrote:
I have attached the the class template code snippet for your reference.
I need to inherit from this class, DTMPOPropertyPage in C#.
How can I achieve this?
[...]
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.