The prior message covers flipping the /clr flag for the entire project. The
other option is to just flip the /clr flag for the source file which uses
the . NET control. Some info for doing this is shown below as well.
[ enable /clr for just the source file using the controls ]
- similar to doing it for the whole project, but with the following
differences
- move the #include <afxwinforms.hfrom stdafx.h into the source file
where the control is being used
- leave /clr off for the project, but turn it on for the source file
- set exception handling to /EHa for the source file
- disable use of pre-compiled headers for the source file (since the
non-clr precompiled header won't be compatible with the clr source file)
- create a forward-declared inner class in the dialog class using the
control; this class is the control holder
- declare the control holder class in the source file, having it contain
the template instantiation (CWinFormsControl) class
- to use the control just refer to m_controlHolder.m_myControl
The holder class is necessary because you don't want to include the
afxwinforms header in the dialog's header or you'll pollute the rest of the
project.
Dave
"Dave Calkins" <da***********@noemail.noemailwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I found a couple articles on the Code Project web site
(www.codeproject.com) which address the below and have included my notes
taken from those articles below.
====
The basics for using a .NET Windows Forms control in a native MFC app are
as follows:
1. Enable /clr for the project
2. Add #include <afxwinforms.hto your stdafx.h
3. Add a static control to your dialog, positioned where you want the
control
4. Declare a control variable in the dialog class:
CWinFormsControl<System::Windows::Forms::PropertyG ridControlm_props;
5. In your dialog's DoDataExchange() method, add:
DDX_ManagedControl(pDX,IDC_PROPS,m_props);
6. now you can use the control variable just as any other native control
7. there are other steps for handling events, etc.
Details are in the below Code Project articles
http://www.codeproject.com/managedcp...ogwinforms.asp
http://www.codeproject.com/managedcp...inFormsOff.asp
====
Dave
"Dave Calkins" <da***********@noemail.noemailwrote in message
news:eb**************@TK2MSFTNGP03.phx.gbl...
>>I have a native Win32 C++ app built with Visual Studio 2005. I'd like to
make use of a property grid control in this app. For an example of this,
in Visual Studio, see the properties control (select something in a dialog
from the dialog editor or a class from the class list and hit F4).
I used Spy++, which revealed that the window class of the property grid
control used by Visual Studio is "WindowsForms10.Window.8.app.0.378734a".
So, I'm assuming this is a .NET control.
I found the System.Windows.Forms.PropertyGrid class
(http://msdn.microsoft.com/library/de...classtopic.asp)
in the MSDN library, which seems to be the correct control to do the job.
Whats the easiest way to go about using this .NET control in my native
C++ app? I'm assuming I can do this using mixed-mode, etc., but was
hoping for a pointer in the right direction wrt how to go about doing
this.
I understand that this will force a dependency on having the .NET runtime
installed and I'm ok with that.
Thanks,
Dave