473,785 Members | 2,325 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 #1
23 2239
"Bredal Jensen" <Br***********@ mimosa.com> wrote in
news:e4******** ******@TK2MSFTN GP15.phx.gbl...

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.
First port it to unmanaged VC++ 7. MFC 6 and MFC 7 do have some differences.
After that, compiling the code as managed code is usually only a compiler
switch.
I know my application would have to obey to the CTS (common type
specification) but my main concerns are the MFC stuff!
You can still do anything in managed C++; You only have to obey CTS rules
for the types you want to expose to other languages (like C#)
I do not really know which options you have with windows forms. Can they
do
what MFC can do?
IMO it would be a good idea to convert your MFC app to WinForms, however
there's no real need to do that.
How about functions pointers. How does managed C++ deal with this?


It's managed, but it's still C++. You have const types, templates, function
pointers, void pointers...

If you can't compile your C++ code as managed code, you could still use COM
interop.

Hope this helps,

Niki
Jul 21 '05 #2
Well thanks for your answer, i have already compiled with Vc++.7 .
So what is this compiler switch i have to add?



"Niki Estner" <ni*********@cu be.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
"Bredal Jensen" <Br***********@ mimosa.com> wrote in
news:e4******** ******@TK2MSFTN GP15.phx.gbl...

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.
First port it to unmanaged VC++ 7. MFC 6 and MFC 7 do have some

differences. After that, compiling the code as managed code is usually only a compiler
switch.
I know my application would have to obey to the CTS (common type
specification) but my main concerns are the MFC stuff!
You can still do anything in managed C++; You only have to obey CTS rules
for the types you want to expose to other languages (like C#)
I do not really know which options you have with windows forms. Can they
do
what MFC can do?


IMO it would be a good idea to convert your MFC app to WinForms, however
there's no real need to do that.
How about functions pointers. How does managed C++ deal with this?


It's managed, but it's still C++. You have const types, templates,

function pointers, void pointers...

If you can't compile your C++ code as managed code, you could still use COM interop.

Hope this helps,

Niki

Jul 21 '05 #3
"Bredal Jensen" <Br***********@ mimosa.com> wrote in
news:ew******** ******@tk2msftn gp13.phx.gbl...
Well thanks for your answer, i have already compiled with Vc++.7 .
So what is this compiler switch i have to add?


Go to the properties of your project - general tab - switch "use managed
extensions" to "yes".
You may have to resolve a few conflicts with other project settings, but
afterwards you should be able to include managed code into your application.

Niki
Jul 21 '05 #4
Many thanks , this sounds so great to me , i never though it would be so
simple.

Well , i did that and now it says :
"Command line error D2016 : '/RTC1' and '/clr' command-line options are
incompatible"


"Niki Estner" <ni*********@cu be.net> wrote in message
news:et******** ******@TK2MSFTN GP12.phx.gbl...
"Bredal Jensen" <Br***********@ mimosa.com> wrote in
news:ew******** ******@tk2msftn gp13.phx.gbl...
Well thanks for your answer, i have already compiled with Vc++.7 .
So what is this compiler switch i have to add?
Go to the properties of your project - general tab - switch "use managed
extensions" to "yes".
You may have to resolve a few conflicts with other project settings, but
afterwards you should be able to include managed code into your

application.
Niki

Jul 21 '05 #5
"Bredal Jensen" <Br***********@ mimosa.com> wrote in
news:e3******** ******@TK2MSFTN GP11.phx.gbl...
Many thanks , this sounds so great to me , i never though it would be so
simple.

Well , i did that and now it says :
"Command line error D2016 : '/RTC1' and '/clr' command-line options are
incompatible"


Yes, I had the same experience with converted VC6 projects. You can either
create a new dummy MFC project in VC7 and "copy" all compiler settings (new
projects are configured so they can be compiled with managed extensions), or
you can adjust the compiler switches one by one with each error;

Have a look at the MSDN article on the "/clr" compiler switch, it should
contain all the information you need.

Niki
Jul 21 '05 #6
I'm having trouble finding where these "compiler settings" can be found.
I'm using visual studio ..Net


"Niki Estner" <ni*********@cu be.net> wrote in message
news:Or******** ******@TK2MSFTN GP11.phx.gbl...
"Bredal Jensen" <Br***********@ mimosa.com> wrote in
news:e3******** ******@TK2MSFTN GP11.phx.gbl...
Many thanks , this sounds so great to me , i never though it would be so
simple.

Well , i did that and now it says :
"Command line error D2016 : '/RTC1' and '/clr' command-line options are
incompatible"
Yes, I had the same experience with converted VC6 projects. You can either
create a new dummy MFC project in VC7 and "copy" all compiler settings

(new projects are configured so they can be compiled with managed extensions), or you can adjust the compiler switches one by one with each error;

Have a look at the MSDN article on the "/clr" compiler switch, it should
contain all the information you need.

Niki

Jul 21 '05 #7
"Bredal Jensen" <Br***********@ mimosa.com> wrote in
news:u1******** ******@TK2MSFTN GP14.phx.gbl...
I'm having trouble finding where these "compiler settings" can be found.
I'm using visual studio ..Net


Really? It's quite easy to find information on them...

Example: /RTC1;
Open up MSDN; Go to the "Index" Tab; Enter "/RTC1"; Read the article,
especially this paragraph:
"To set this compiler option in the Visual Studio development environment:
1. Open the project's Property Pages dialog box. For details, see Setting
Visual C++ Project Properties.
2. Click the C/C++ folder.
3. Click the Code Generation property page.
4. Modify one or both of the following properties: Basic Runtime Checks or
Smaller Type Check."

Niki
Jul 21 '05 #8
Now my program compiles as manages C++ and actually runs.
Is that all i had to do to run as managed C++?

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?

Again thank you so much....
"Niki Estner" <ni*********@cu be.net> skrev i en meddelelse
news:uZ******** ******@TK2MSFTN GP14.phx.gbl...
"Bredal Jensen" <Br***********@ mimosa.com> wrote in
news:u1******** ******@TK2MSFTN GP14.phx.gbl...
I'm having trouble finding where these "compiler settings" can be found.
I'm using visual studio ..Net


Really? It's quite easy to find information on them...

Example: /RTC1;
Open up MSDN; Go to the "Index" Tab; Enter "/RTC1"; Read the article,
especially this paragraph:
"To set this compiler option in the Visual Studio development environment:
1. Open the project's Property Pages dialog box. For details, see Setting
Visual C++ Project Properties.
2. Click the C/C++ folder.
3. Click the Code Generation property page.
4. Modify one or both of the following properties: Basic Runtime Checks or
Smaller Type Check."

Niki

Jul 21 '05 #9
"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 #10

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
9481
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
10341
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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
9954
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
8979
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
7502
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
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.