473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

using the property grid control from a native app

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
Sep 6 '06 #1
4 6883
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


Sep 7 '06 #2
Hi David,

Thanks for your valuable summary and suggested articles!

I also found some good articles on this topic, I think you may have
interests on them:

Integrate Windows Forms Into Your MFC Applications Through C++ Interop
http://www.msdn.net/netframework/win...l=/msdnmag/iss
ues/06/05/mixandmatch/default.aspx

MFC 8.0 and Windows Forms Integration, Part I
http://www.codeguru.com/cpp/cpp/cpp_...le.php/c10883/

MFC 8.0 and Windows Forms Integration, Part II
http://www.codeguru.com/cpp/cpp/cpp_...le.php/c11083/

Have a nice weekend!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Sep 8 '06 #3
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



Sep 8 '06 #4
Gary,

Those look like excellent articles. Thanks and have a good weekend yourself
:-)

Dave

""Gary Chang[MSFT]"" <v-******@online.microsoft.comwrote in message
news:yo**************@TK2MSFTNGXA01.phx.gbl...
Hi David,

Thanks for your valuable summary and suggested articles!

I also found some good articles on this topic, I think you may have
interests on them:

Integrate Windows Forms Into Your MFC Applications Through C++ Interop
http://www.msdn.net/netframework/win...l=/msdnmag/iss
ues/06/05/mixandmatch/default.aspx

MFC 8.0 and Windows Forms Integration, Part I
http://www.codeguru.com/cpp/cpp/cpp_...le.php/c10883/

MFC 8.0 and Windows Forms Integration, Part II
http://www.codeguru.com/cpp/cpp/cpp_...le.php/c11083/

Have a nice weekend!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.


Sep 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kevin Myers | last post by:
Hello, Please forgive my reposting of this note with hopefully a more relevant subject line. On an Access 2000 form under Windows 2000 I would like to use a Kodak Image Edit Control to...
6
by: active | last post by:
In VB6 I could invoke a tool ( don't remember how right now) that would enable me to create properties in my user control that passed through properties of components on the user control. I...
7
by: siddhiash | last post by:
Hi Friends I want to add PasswordChar Property which shows ****** for string which I type in PropertyGrid Control. Regards, Siddharth
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
2
by: Mark Collard | last post by:
I've noticed that when you add a ToolTip component to a Form (or UserControl) the other controls on the form display a property in the property grid called "ToolTip on toolTip1", so you can set the...
2
by: Ray Cassick | last post by:
I am looking for a way to hide a property I created on a user control from a property grid at runtime but allow it to be seen at design time. Any ideas? I tried setting the category of the...
4
by: John Allen | last post by:
Hi there, Does anyone know if the standard "PropertyGrid" control is (foreign) language sensitive. If I display an object in the control, and my object has the native .NET "Size" struct as a...
1
by: --== Alain ==-- | last post by:
Hi, I finally found how to update the render of my custom control when one of its property value changed. However, i would like to know if there is not another way, because i'm afraid about...
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.