473,320 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

inheriting classes from VC++6 into C#.net

Amu
i have a dll ( template class) ready which is written in
VC++6. But presently i need to inherit its classes into my new C#.net
project.so if there is some better solution with u then please give me
the solution.

Jan 16 '07 #1
2 1890
Amu wrote:
i have a dll ( template class) ready which is written in
VC++6. But presently i need to inherit its classes into my new C#.net
project.so if there is some better solution with u then please give me
the solution.
Strictly speaking, there's no way to "inherit C++ classes into C#" (whatever
that means). There are, however, several possible ways to make use of your
C++ classes in a C# program.

First, if the C++ classes are really COM objects, you can use tlbimp.exe
(.NET framekwork SDK) to generate a .NET wrapper assembly and then use the
classes from that wrapper assembly from your C# project to access your c++
classes.

Second, if the C++ classes are really just C code that exposes a C-friendly
API, you can use PInvoke to call functions in your DLL from C#.

Finally, for most other cases, you'll have to port your VC6 code to VC8,
then use C++/CLI to hard-craft a .NET interface for your C++ classes.

If you can give more details about exactly what the classes are and how you
intend to use them, I or someone else can help you find the right path for
your particular case.

-cd
Jan 16 '07 #2
Amu

Carl Daniel [VC++ MVP] wrote:
Amu wrote:
i have a dll ( template class) ready which is written in
VC++6. But presently i need to inherit its classes into my new C#.net
project.so if there is some better solution with u then please give me
the solution.

Strictly speaking, there's no way to "inherit C++ classes into C#" (whatever
that means). There are, however, several possible ways to make use of your
C++ classes in a C# program.

First, if the C++ classes are really COM objects, you can use tlbimp.exe
(.NET framekwork SDK) to generate a .NET wrapper assembly and then use the
classes from that wrapper assembly from your C# project to access your c++
classes.

Second, if the C++ classes are really just C code that exposes a C-friendly
API, you can use PInvoke to call functions in your DLL from C#.

Finally, for most other cases, you'll have to port your VC6 code to VC8,
then use C++/CLI to hard-craft a .NET interface for your C++ classes.

If you can give more details about exactly what the classes are and how you
intend to use them, I or someone else can help you find the right path for
your particular case.

-cd

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;

};

Jan 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: john diss | last post by:
hello there everyone.. I have created a class called "ProcessLog" inheriting from XmlDocument and two classes ("UploadedItem", "ProcessError") inheriting from XmlElement. I then have two...
2
by: Peter Bates | last post by:
Hi, I'm just getting used to XSDObjectGen and i have the following question. Can i use a class inherited from a class generated by XSDObjectGen with XmlSerialize? Specifically, I have many...
6
by: Russell Mangel | last post by:
Jeffery Richter makes the following statement in two books, the first was written in 2004, the latter in 2002. "You should not define new exception classes derived from ApplicationException; use...
2
by: vemulakiran | last post by:
Hi all, I have doubt regarding .NET. I have a tool which was developed on VC++ 6.0(Win32 Application ). The application communicates with library (API) which was developed on VC++ 6.0 called core...
3
by: Peter Plumber | last post by:
Hi, I am just a (maybe) beginner in .NET having some basic questions about the limits. I suppose easy to answer for someone already using it ... what are the limits of inheritance?
24
by: toton | last post by:
Hi, I want to have a vector like class with some additional functionality (cosmetic one). So can I inherit a vector class to add the addition function like, CorresVector : public...
7
by: Amu | last post by:
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 .
5
by: jc | last post by:
RE: Two Classes with the same Data Structure.. saving code? Inheriting a structure? I have two classes. One in Inherits System.Collections.CollectionBase, the other does not, but they both have...
4
by: AalaarDB | last post by:
struct base { int x, y, z; base() {x = 0; y = 0; z = 0;}; base(int x1, int y1, int z1) {x = x1; y = y1; z = z1;}; }; struct intermediate1 : public virtual base {}; struct intermediate2 :...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.