473,773 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.PropertyG rid 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 6905
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.ht o 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:
CWinFormsContro l<System::Windo ws::Forms::Prop ertyGridControl m_props;
5. In your dialog's DoDataExchange( ) method, add:
DDX_ManagedCont rol(pDX,IDC_PRO PS,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.noemail wrote in message
news:eb******** ******@TK2MSFTN GP03.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.PropertyG rid 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.hf rom 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 (CWinFormsContr ol) 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.noemail wrote in message
news:%2******** ********@TK2MSF TNGP03.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.ht o 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:
CWinFormsContro l<System::Windo ws::Forms::Prop ertyGridControl m_props;
5. In your dialog's DoDataExchange( ) method, add:
DDX_ManagedCont rol(pDX,IDC_PRO PS,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.noemail wrote in message
news:eb******** ******@TK2MSFTN GP03.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.PropertyG rid 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.m icrosoft.comwro te in message
news:yo******** ******@TK2MSFTN GXA01.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
8384
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 display the contents of a TIFF image file. According to the very limited documentation that I have been able to locate so far, all I should need to do is to drop the Image Edit Control onto the form in design mode, set the control's Image property to...
6
1546
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 badly need that capability now but can't find it. Is it available in VB.NET? Anyone know how to do this ?? What I need is something that would create the code in my user control for all the properties contained in a control contained in my user...
7
9731
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
5569
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 is used to view the state of the running jobs and schedule new jobs. The control also runs in the context of Internet Explorer (we do this so the administrators of the jobs can always receive the latest control). The property grid is used to...
2
4896
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 tooltip text on the selected control. I'm currently writing my own component, and I want to add the same functionality to the component, so that the other controls on the form display a property in the property grid called "ControlText on...
2
2695
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 property to 'Design' and that does not do it. I tried adding the 'DesignOnly' attribute and that does not do it.
4
2804
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 property (which also contains its own ""Width" and "Height" members), will someone running my app on a German version of Windows for instance still see "Size", "Width" and "Height" in the property window. Or does it get translated into German...
1
2091
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 memory usage or leak. The following code is only a change color property update, but it is easy to adapt it to other properties.
8
11520
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 file. each control has a border with another style, and each border has a unique path inside of it. I need to dynamically add these content controls using c# at runtime and am having trouble referencing the styles and adding the path into the...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.