The local C ++ and MFC applications call the. Net Control for the display layer.

Source: Internet
Author: User

First of all, I am familiar with C ++, and I am not familiar with C # And other. NET environment languages. It took a lot of time over the weekend to collect a lot of relevant information and make some attempts. We found that this is feasible and has some practical value.

 

 

Source of the problem, I found that it is too painful to create an interface in C ++. I often analyzed the problem clearly and wrote the underlying data structure and logic quite smoothly. However, when it comes to interfaces, the progress is often not well controlled. As a result, the. NET Framework is easy to create interfaces, and I would like to try to solve my problems by calling the Interface part of the. Net Design in the local C ++ program.

 

 

Solution: The C ++/mfc interface can be very thin and simple. It needs to be called when the beautiful interface is used. net form or control (including. net write ActiveX and WPF controls), in. the messages operated on the net form or control can be sent back to C ++ to form a good development loop.

 

 

Solution: to ensure the consistency of development, the main program still uses unmanaged MFC/Win32, because once the main program uses CLR compilation, many unexpected problems will occur, it also brings a lot of confusion to other colleagues in the project team. After all, not every comrade has the energy to study and maintain two sets of code. So how does the main program solve this problem without changing it? I am. net Control ,. net forms, WPF controls, and ActiveX controls form an intermediate layer, which uses MFC to expand the dynamic link library, the export function is a function compatible with the local MFC program. in this way, the user does not need to care about how the intermediate layer is completed. As long as the interface function is known, the user can open or embed the form exported in the DLL.

 

 

Solution: 1. net form, 2. net Control, 3. WPF control, 4. activeX (this is not a problem. It is used here. activeX written by the Net Framework, which is estimated to be required during runtime.. NET Framework ).

 

 

Problems left over: 1. As I have almost no idea about. net, we need to continue to explore message communication and data conversion in future practices. Here I found that C # uses a delegate (proxy? I'm not sure about the term). when responding to a message in managed C ++, I found the/VC/include/msclr folder event. the delegated macro definition in H cannot solve the problem of single (multiple) parameters. The delegate here is two parameters by default, because some users need to use non-two parameters to delegate controls, I suggest that you try to expand the macro definition (expand the event. h macro), do not be bound by it (I did not dare to change it, I want to do it through other methods, and later found that expansion macro is the most convenient, ); 2. because I am exploring the Dynamic Link Library Extension Based on MFC, I 'd like to add a form above to try it out, I found that in this mode, I was not allowed to use the Form Designer (which is probably a problem in M $ design), but this was bypassed by me and I made a pure one.. Net managed C ++ project. After designing the required winform, copy the ref myform class to the original project.

 

 

 

Logical difficulties: 1. last night I went back and thought about it after finishing technical research and programming attempts. I found it was very convenient on the surface and the interface was very beautiful, but what is important is how the main program can be logically seamless, that is to say, what is the availability of the objects passed in the C ++ program? For example, if I define a class object in the main program, Can I pass the object to this interface for calling? It seems yes, but I am not sure that. NET is used after all. That is to say, I have to sum up the application situation. If I try this development mode, it should be feasible if the modules are relatively independent. 2. Some colleagues who are very familiar with. Net told me that the. NET Framework and the C ++ module should be used as an aid. Unfortunately, I am not familiar with. net. This may be ugly. If so, it is for your reference only.

 

 

If you want to reply to a friend, you may have a better solution to these problems.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.