473,796 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VC++6 MFC migration managed C++(windows form )


I want to port my MFC (VC++6) application to manageg VC ++. 7. I want to do
this because some things are much better done with C#. So i could write a C#
class and use in
my VC++ code as Languague interoperabilit y is one of the main features of
the .Net
framework. I know my application would have to obey to the CTS (common type
specification) but my main concerns are the MFC stuff!
I do not really know which options you have with windows forms. Can they do
what MFC
can do? How about functions pointers. How does managed C++ deal with this?
Maybe this is not the right place to post this, but any usefull comment will
be very
appreciated.

Thanks
Jul 21 '05
23 2240
What i want to do:

I was once C++ addict but since i tried C#, i just don't want to use
too much of C++ anymore.
I have this huge MFC application and it needs new features. I then want to
do all
new developement in C# and work my way through like this.

An alternative is a whole rewrite in C# , but it does not seem like our
budget
allow this for now.
So here is what want to do. Did that sound Crazy? ;)


"Niki Estner" <ni*********@cu be.net> skrev i en meddelelse
news:eo******** ******@tk2msftn gp13.phx.gbl...
"Bredal Jensen" <br****@jensen. dk> wrote in
news:O9******** ******@TK2MSFTN GP11.phx.gbl...
Now my program compiles as manages C++ and actually runs.
Is that all i had to do to run as managed C++?
It's not 100% managed code yet, but you can reference managed assemblies

and create managed types. The possibility to have managed and unmanaged code in one assembly is one of the major advantages of managed C++. The price is
that you often have to use keywords like __gc or __value to tell the
compiler which way to go.
Well i must say your informations are very accurate and i'm
really thankfull for all these help.

I still have questions though. I now decided to write one of my user
interface part as a C# "windows control" .

I need to do the equivalent of (Postmessage or SendMessage) plus send data like with (wParam and lParam) . Is there a way of doing this?


You can still P/Invoke SendMessage and PostMessage with the DllImport
attribute, and every control has a protected virtual method "WndProc".
However, it's usually a bad idea to use them if you can avoid it: First of
all, those "wParam/lParam" parameters tend to disturb the GC if they carry
pointers; They are ugly to debug, and error-prone.
Depending on what you want to do, I'd suggest having a deeper look at
events, delegates, interfaces (for loose-coupling), or the Control.Invoke
method (for inter-thread communication).

Niki

Jul 21 '05 #11
"Bredal Jensen" <br****@jensen. dk> wrote in
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
What i want to do:

I was once C++ addict but since i tried C#, i just don't want to use
too much of C++ anymore.
I have this huge MFC application and it needs new features. I then want to
do all
new developement in C# and work my way through like this.

An alternative is a whole rewrite in C# , but it does not seem like our
budget
allow this for now.
So here is what want to do. Did that sound Crazy? ;)


No: thanks to managed C++ you can port an application step-by-step without
pain.
But you should always keep the architecture of your application in mind: If
you have to add a new feature which you would have put into a separate DLL
anyway, fine write it in managed code. However, if you have to add a feature
to an existing class, you should either write it in C++, or port the whole
class (or maybe even bigger chunks of your application) to C#. Otherwise
your application will be a mess quite soon.
Also, you should identify parts of your application that would profit most
from .NET (especially the ones that are bound to change), and port them to
C# when you have the time (you'll be lucky you did when you don't have the
time any more).

I think that's a good way to go, and if you do it right, it should save you
lots of time.

Niki
Jul 21 '05 #12
well , i'm mostly going to build "windows control library" and use "Add
reference" and instantiate the classes.
Actually i though i could also just instantiate a C# class not in a binary
form. shouldn't that in theory be possible?


"Niki Estner" <ni*********@cu be.net> skrev i en meddelelse
news:uZ******** ******@tk2msftn gp13.phx.gbl...
"Bredal Jensen" <br****@jensen. dk> wrote in
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
What i want to do:

I was once C++ addict but since i tried C#, i just don't want to use
too much of C++ anymore.
I have this huge MFC application and it needs new features. I then want to do all
new developement in C# and work my way through like this.

An alternative is a whole rewrite in C# , but it does not seem like our
budget
allow this for now.
So here is what want to do. Did that sound Crazy? ;)
No: thanks to managed C++ you can port an application step-by-step without
pain.
But you should always keep the architecture of your application in mind:

If you have to add a new feature which you would have put into a separate DLL
anyway, fine write it in managed code. However, if you have to add a feature to an existing class, you should either write it in C++, or port the whole
class (or maybe even bigger chunks of your application) to C#. Otherwise
your application will be a mess quite soon.
Also, you should identify parts of your application that would profit most
from .NET (especially the ones that are bound to change), and port them to
C# when you have the time (you'll be lucky you did when you don't have the
time any more).

I think that's a good way to go, and if you do it right, it should save you lots of time.

Niki

Jul 21 '05 #13
"Bredal Jensen" <br****@jensen. dk> wrote in
news:ux******** ******@tk2msftn gp13.phx.gbl...
well , i'm mostly going to build "windows control library" and use "Add
reference" and instantiate the classes.
use the "new" operator to instantiate classes. adding a reference only makes
the classes in an assembly visible, it doesn't instantiate them yet.
Actually i though i could also just instantiate a C# class not in a binary
form. shouldn't that in theory be possible?


The C# class would have to be compiled, so it has to be in a binary form;
You can compile it at runtime, but I'm not sure if that's what you mean.

Niki
Jul 21 '05 #14
What i mean is :

making my C# class available to a c++ class with:
"using Mynaspace.Mycla sss "

and Myclass mc = new Myclass(....


"Niki Estner" <ni*********@cu be.net> wrote in message
news:un******** ******@TK2MSFTN GP14.phx.gbl...
"Bredal Jensen" <br****@jensen. dk> wrote in
news:ux******** ******@tk2msftn gp13.phx.gbl...
well , i'm mostly going to build "windows control library" and use "Add
reference" and instantiate the classes.
use the "new" operator to instantiate classes. adding a reference only

makes the classes in an assembly visible, it doesn't instantiate them yet.
Actually i though i could also just instantiate a C# class not in a binary form. shouldn't that in theory be possible?


The C# class would have to be compiled, so it has to be in a binary form;
You can compile it at runtime, but I'm not sure if that's what you mean.

Niki

Jul 21 '05 #15
An other issue.
Now that my code is Dot net "ready"
i though i could just use fx: using System.Net . in my C++ file.
But that does not seem to work. I recall you saying my code
was not 100% manged . is that why i can not do this?


"Bredal Jensen" <Br***********@ mimosa.com> skrev i en meddelelse
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
What i mean is :

making my C# class available to a c++ class with:
"using Mynaspace.Mycla sss "

and Myclass mc = new Myclass(....


"Niki Estner" <ni*********@cu be.net> wrote in message
news:un******** ******@TK2MSFTN GP14.phx.gbl...
"Bredal Jensen" <br****@jensen. dk> wrote in
news:ux******** ******@tk2msftn gp13.phx.gbl...
well , i'm mostly going to build "windows control library" and use "Add reference" and instantiate the classes.


use the "new" operator to instantiate classes. adding a reference only

makes
the classes in an assembly visible, it doesn't instantiate them yet.
Actually i though i could also just instantiate a C# class not in a binary form. shouldn't that in theory be possible?


The C# class would have to be compiled, so it has to be in a binary form; You can compile it at runtime, but I'm not sure if that's what you mean.

Niki


Jul 21 '05 #16
"Bredal Jensen" <br****@jensen. dk> wrote in
news:eF******** ******@TK2MSFTN GP12.phx.gbl...
An other issue.
Now that my code is Dot net "ready"
i though i could just use fx: using System.Net . in my C++ file.
Did you reference the right assemblies? I think this namespace is
implemented in System.dll - you'll have to add a reference to it.
But that does not seem to work. I recall you saying my code
was not 100% manged . is that why i can not do this?


You should be able to do this; However it is possible that you will not be
able to use managed code in some of your functions because they already
contain native code; simply create a new empty function then, put the
managed code in it , and call it from your unmanaged function.

Niki
Jul 21 '05 #17
I think i have a problem my visusal studio installation. i need to do a
reinstall.
I can not even see the add reference option .

But you are right i have not added a reference to "System.dll ".

I 'll try again later when i ahve a reliable visual studion installation.

"Niki Estner" <ni*********@cu be.net> skrev i en meddelelse
news:u4******** ******@TK2MSFTN GP15.phx.gbl...
"Bredal Jensen" <br****@jensen. dk> wrote in
news:eF******** ******@TK2MSFTN GP12.phx.gbl...
An other issue.
Now that my code is Dot net "ready"
i though i could just use fx: using System.Net . in my C++ file.


Did you reference the right assemblies? I think this namespace is
implemented in System.dll - you'll have to add a reference to it.
But that does not seem to work. I recall you saying my code
was not 100% manged . is that why i can not do this?


You should be able to do this; However it is possible that you will not be
able to use managed code in some of your functions because they already
contain native code; simply create a new empty function then, put the
managed code in it , and call it from your unmanaged function.

Niki

Jul 21 '05 #18
"Bredal Jensen" <br****@jensen. dk> wrote in
news:uO******** ********@TK2MSF TNGP11.phx.gbl. ..
I think i have a problem my visusal studio installation. i need to do a
reinstall.
I can not even see the add reference option .


Really? Select your project in the solution explorer and choose "Add
Reference" from the project menu.

You can also do the same from the source code with the "#using" preprocessor
directive.

Niki
Jul 21 '05 #19
I can not see it in the project menu .
The IDE "Itself" also prompted me to reinstall .

But before i do , could you show code snippet of how to use "#using " thing.
Assum i want to get the list of my local ip/ips . I know
this can be done with Ip helper but i guess it must be much
more straight forward using .Net.

"Niki Estner" <ni*********@cu be.net> skrev i en meddelelse
news:u%******** *******@TK2MSFT NGP15.phx.gbl.. .
"Bredal Jensen" <br****@jensen. dk> wrote in
news:uO******** ********@TK2MSF TNGP11.phx.gbl. ..
I think i have a problem my visusal studio installation. i need to do a
reinstall.
I can not even see the add reference option .
Really? Select your project in the solution explorer and choose "Add
Reference" from the project menu.

You can also do the same from the source code with the "#using"

preprocessor directive.

Niki

Jul 21 '05 #20

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

Similar topics

1
2595
by: Bob | last post by:
I would appreciate any suggestions on handling the following... I currently have a VC++ MDI Application. The core pieces/products are all handled in separate dll's. Our shop has slowly been rewriting other applications over to VB.net. My application has now been targeted with coming over, but management does not want to incur a rewrite timeline. Since we have a standard vb.net framework in place, their thoughts are to try and take the...
6
2789
by: Ben Terry | last post by:
Hello, I have a VS 2003.NET solution which consists of four c++ unmanaged legacy projects. I am adding a new project to the solution which will be in c#. What do I need to do to my c++ projects in order to call my c# modules from within c++? From what I understand, I need to convert my c++ code from unmanaged to managed using the /clr switch (IJW). Is this correct? Are there any other considerations I need to be aware of? Ben
23
427
by: Bredal Jensen | last post by:
I want to port my MFC (VC++6) application to manageg VC ++. 7. I want to do this because some things are much better done with C#. So i could write a C# class and use in my VC++ code as Languague interoperability is one of the main features of the .Net framework. I know my application would have to obey to the CTS (common type specification) but my main concerns are the MFC stuff! I do not really know which options you have with windows...
0
9683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9529
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10231
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9054
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5443
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.