Is there any way to use C++ MFC code in C# windows forms? - winforms

I am using one windows MFC C++ application but I want to change only UI part in C# windows forms.
Because in Windows Form UI is better than MFC. So, I want to change..
I there is any way to connect C++ as a application and C# as a DLL?...

Related

Is it possible to use Windows Forms controls directly on a VB6 form?

Is it possible to use a .NET Windows Forms control directly in a VB6 form?
The goal here would be to use the more up to date .NET controls in a legacy VB6 application. We already have a mixed .NET / VB6 environment.
I am aware of the Microsoft InteropForms Toolkit but it is described as being used for exporting custom usercontrols to VB6 from .NET. This doesn't seem to provide for preexisting controls (but I could be wrong).
I have tried to simply reference System.Windows.Forms.tlb in a VB6 project as a component library - but it does not allow this to be selected, which seems to imply it has no ActiveX controls inside it.
I'm aware you can easily do the reverse - eg use a VB6 usercontrol on a .NET winforms form. That's not what I need.
You can reference the System.Windows.Forms assembly in a normal way from VB6 - and wind up with a line such as the following in your VBP:
Reference=*\G{215D64D2-031C-33C7-96E3-61794CD1EE61}#2.4#0#C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Windows.Forms.tlb#System_Windows_Forms
but this doesn't provide access to place controls on a form.
I did that before.
I created a control (with the forms control you want use) in .net (exported to tlb using InteropFormsToolkit) and created a vb6 control where I put that .net control.
It was necessary to map all the properties, events and methods that I wanted to use.
In forms vb6 I added this vb6 control, with the .net encapsulated.
It worked!

XAML vs WPF vs Store App vs Phone App vs UWA

I know that XAML is used for designing UI in combination with Blend. I am confused with so many terms, like, how XAML comes into play for WPF, Store App, Phone App or UWA. Morever, what is the difference between WPF, Store App, Phone App and UWA. Does all that means that old Desktop Project will no longer be used and replace by either WPF or Store App or UWA?
When .NET was released in ~2000, you could use WinForms to make desktop applications for Windows. It provides access to 'native' controls (i.e. A Button made in WinForms actually is a Windows Button control from user32.dll) by wrapping the Windows API in managed code. These can run in any version of Windows which has the appropriate .NET framework version installed, including upto Windows 10.
In 2006, WPF was released which is an alternative to WinForms. WPF uses XAML, which is a language based on XML, to declare the user interface elements. In a simple WPF app, the .xaml file describes the GUI and the code-behind file describes the logic. DirectX is used to draw whatever is described in the .xaml into the window.
Like Winforms, programs made using WPF can run in any version of Windows which has the appropriate .NET framework version installed, including upto Windows 10. Note that using XAML is completely optional. Whatever user interface elements you describe using XAML can also be made using your .NET language C# or VisualBasic.NET. But using XAML is usually simpler. See To XAML or not to XAML (MSDN Blogs).
From XAML (Wikipedia) :
As XAML is simply based on XML, developers and designers are able to share and edit content freely amongst themselves without requiring compilation.
From ~2012 along with Windows 8, a new kind of app called metro/modern/windows-8/windows-store-apps can be made. These apps are similar to WPF in that they use XAML for describing the GUI. These apps can run only in Windows 8, 8.1 and Windows 10. Windows 8.1 added some improvements and features but remained mostly the same. The same technology was used to make apps for Windows Phone.
With the release of Windows 10, Microsoft made UWP (Universal Windows Platform) through which you can use the same code base to target differnt kinds of devices (desktop/mobile/xbox/IoT/holographic). These apps made for the UWP are similar to the earlier Windows 8/8.1 apps. Like before, XAML is used to describe the GUI.
Only for the Windows Store apps, there is no backward compatibility. The timeline goes Windows 8 -> Windows 8.1 -> Windows 10/UWP. An app made in UWP can only run in Windows 10 and an app made in Windows 8.1 can not run in Windows 8.
I would highly recommend referring to this discussion thread in stopbyte, it has far more details and explanation of the concepts behind WPF, UWP And WinRT.
As for WinForms, from my experience it's history now. Have been almost replaced by WPF (though it still has mainstream support as mention by #Jazimov).
I'v noticed that Microsoft has stopped improving Windows Forms and probably has stopped maintaining it as well.

Windows and Windows Forms

I need a window to receive/handle messages from a driver. Will creating a Windows Form in visual studio be same as creating window? Will the windows form do the thing I am trying to do?
What is the difference between windows form and window? Or Even WPF, does it suit my purpose or are windows/windows forms and wfp totally different?
I need a window to receive/handle messages from a driver. Will creating a Windows Form in visual studio be same as creating window? Will the windows form do the thing I am trying to do?
Yes, basically it will be the same. I think this article answers your question: http://msdn.microsoft.com/en-us/library/8bxxy49h(v=vs.80).aspx
With Windows Forms you develop smart clients. Smart clients are
graphically rich applications that are easy to deploy and update, can
work when they are connected to or disconnected from the Internet, and
can access resources on the local computer in a more secure manner
than traditional Windows-based applications.
And about the difference between WPF and WinForms you can read in this CodeProject#s article: http://www.codeproject.com/Articles/25795/Creating-the-Same-Program-in-Windows-Forms-and-WPF

WPF - Windows Forms Interoperation

I am abit confused about interoperations between forms. I have an c#.Net application developed using DevExforms. On the other hand I have a XNA application which I want to use it as 3d GUI. But it is diffucult to interact between them. Of course it is not useful, it is ugly too.
So I see a way to develop 3d model viewer app using WPF but WPF controls and windows forms controls needs .Net Framework 4.5 to interact betwwen. But I must use VS2010.
So I am confused. What must I do. How can I easily develop a 3d app with Windows Forms or how can i interact any platform with my app. Actualy if you were me what will you do?
WPF controls and WinForms controls don't need .Net framework 4.5 to work together. the interoperability exists before (4.5). take a look in MSDN

Loading a WPF form into a MFC application without /clr

I am trying to integrate WPF into a legacy MFC application. I am unable to include the /clr switch to mix managed and unmanaged due to the restrictions of other projects in the solution. I need the WPF window open up as a child window in the main MFC application. I have been investigating different ways for the past two weeks but have hit roadblock with every implementation try. If anyone has successfully integrated this type of implementation, I would appreciate some direction. I have been able to integrate with a Win32 app, but could not translate this to an MFC app. Thanks everyone.
I believe that WPF requires .NET, therefore what you need is to create a separate DLL or EXE for the WPF parts. hat new project could be the container for .NET code and your main MFC would launch this separate project.
You can write a WPF front end that launches C++ apps with the desired command like switches, similar to what Visual Studio 2010 is doing to compile your code and show the results in the output pane. In this way you can avoid having to hack message loop code to support both frameworks .
You may show your Dialog using a COM interface

Resources