Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Friends,
I am working on a project for an upcoming event and I am required to design a gesture recognition based project. I am using OpenCV for the former part but for the next step of using that gesture I am required to use .NET framework. I am thinking of merging a win32 console application project of Visual C++ in A Windows Form Application Project File . Is it possible? If yes, then please tell me about doing it. If not, then tell me any other suitable method keeping in view my requirement.
Thank You.
Posted
Updated 14-Jan-12 2:25am
v2
Comments
Sergey Alexandrovich Kryukov 14-Jan-12 13:28pm    
Change your tags: what's the language of .NET application? Add it, add "WinForms". Do you have source code of win32 console application.
--SA

You certainly can. First, let me you assume you have source codes of all both projects, then you can freely merge them. I would advice you not to mess with console. Instead, simulate console with your .NET application using some UI control. I usually use ListBox (one item per text line) which is better than TextBox, but there are many other options; you can also add many useful features (search in output, save it, etc.)

You can turn your Win32 C++ application into C++/CLI class library, which will require only minimal modification. If you really use anything which require extensive use of native environment/libraries, make if a mixed-mode C++/CLI + unmanaged C++ project. Turn main function of your application into a C++/CLI (ref) class. Now, abstract out all methods writing to the console. Make them abstract virtual methods with exact same signature and make this class public and abstract.

This managed or mixed-mode DLL can be referenced by your .NET application as any other .NET assembly. Now, in this .NET application, subclass the class mentioned in the above paragraph and override those output method to write strings into your control mentioned on first paragraph.

This is the simplest and less intrusive method I can think off. You don't need to change any logic of your existing Win32 application but can easily add any features.

Now, in case you don't have the source code of this Win32 application, this is much worse as you are dealing with a separate process and you don't have a way to support the solution. This can be resolved pretty easily by running this application as a child process using System.Diagnostics.Process.Start, http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[^]. You would also need to redirect the console output of the child process, read the redirected stream(s) StandardOutput and StandardError and use the content of these streams in you UI the way you want. You will find the redirection code sample here: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx[^].

Please, pay attention that I had to give you too different variants of the answer because you haven't been comprehensive in formulation of your question. Providing variants is somewhat unpleasant, because I know you would be using only one of them, so it's not very satisfying to do a double job. So please, next time try to make sure you are 100% certain when you formulate a question — thank you.

—SA
 
Share this answer
 
Hi,

You need to create a batch file for calling the win32 application.The u need to run this batch file from
Windows Form Application Project File.

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900