Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Property Grid Simple Example Collapse All
Subject Author Date
Takis Takoglou Feb 18, 2009 - 7:56 AM

Good Day


I am a novice programmer trying to understand and use MFC’s.

I am currently having problems trying to implement your property grid in one of my test applications.


Unfortunately your samples , including the simple properties, are too complicated for me :(


Thus i would like to make a very simple application which shows statically the properties of an object.


In my application i have a mainframe with 2 resizeable bars, one of them containing the ExtPropertyGrid.(Created in the CMainFrame::OnCreate)


When i run the application the Property grid is displayed in the resizeable bar but i am unable to populate it even with a single property.


For example i would like to list the properties of an OK button.


Can u give me an example of how to accomplish such a simple task?


 


Thanx in advance


Stakon.


 


 


 


 


 


 


 

Technical Support Feb 23, 2009 - 7:28 AM

Please note the following: the CExtPropertyGridCtrl does not manage the property store trees. If you assigned some property store to this control, then you should not delete the tree until it’s displayed in control. For instance, the four buttons in the PropertyGrid sample application have their own CExtPropertyStore trees.

The simplified sample application written for you uses the only one property store. It’s possible to assign several property stores to the property grid control and display them in the combo box at the top side of the property grid. The property store which corresponds to the selected combo box item is displayed in the tree grid part at the center of the property grid control.

Please also note: this simplified sample application uses only one simple property store. We have support for the combined property stores. If you have four property stores like in the PropertyGrid sample application, then it’s possible to create fifth property store which will contain references to property values from the initial four property stores. Such property store with references is called combined property store. The PropertyGrid sample application allows you to select different combo box items inside the property grid control. If you configure the property grid control to display properties of the selected buttons, then it will display content of the combined property store. If user changes property value of combined property store, then all the property values from the initial property stores with the same names will be changed. That is how the property grid control the PropertyGrid sample application edits properties of more than one selected button with rotating star.

Finally, the property grid control also supports compound property values which consist of simple property values and other compound property values. You can see them the CompoundProperties sample application.

We recommend you review all the features of the property grid control in the same sequence which we described here.

Takis Takoglou Feb 24, 2009 - 12:46 AM

I have made some progress using a variety of CExtGridCells after creating some StoreTrees with both Categories and values.


Now i’m trying to bound the properties of o a static box belonging to a dialog resource.


It would be very convenient if this was done by simply writing MyDlg.ID_STATIC.SetTextColor(RGB (12,10,100)); but as i found out it has to be more complicated than that...The problem is how can i refer to that particular object of the resource and manipulate its properties.

Technical Support Feb 24, 2009 - 1:14 PM

Your static control should be subclassed with the CExtLablel variable. If you already have the CStatic property for this static control in your dialog class, then please replace the type of this property to the CExtLablel class. The CExtLabel::SetTextColor() method allows you to specify text colors of the static control. Besides the CExtLablel control supports themed with Prof-UIS background. If you don’t have the CStatic property for this static control, then please invoke the SetAutoSubclassChildControls(); line of code in the constructor of your dialog class. The SetAutoSubclassChildControls() method creates dynamic instances of Prof-UIS classes for subclassing all the dialog controls which are not subclassed explicitly in your code. So, you can use the ( STATIC_DOWNCAST( CExtLabel, GetDlgItem( ID_YOUR_STATIC_CONTROL ) ) )->SetTextColor( . . . ); in the dialog’s OnInitDialog() virtual method.

Takis Takoglou Feb 25, 2009 - 4:28 AM

I find your comments most helpful! Thank you very much for the
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Word.Document" name="ProgId" />
<meta content="Microsoft Word 11" name="Generator" />
<meta content="Microsoft Word 11" name="Originator" />
<link href="file:///C:\DOCUME~1\skontov\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning />
<w:ValidateAgainstSchemas />
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables />
<w:SnapToGridInCell />
<w:WrapTextWithPunct />
<w:UseAsianBreakRules />
<w:DontGrowAutofit />
<w:UseFELayout />
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><style type="text/css"><!--
/* Font Definitions */
@font-face
    {font-family:SimSun;
    panose-1:2 1 6 0 3 1 1 1 1 1;
    mso-font-alt:宋体;
    mso-font-charset:134;
    mso-generic-font-family:auto;
    mso-font-format:other;
    mso-font-pitch:variable;
    mso-font-signature:1 135135232 16 0 262144 0;}
@font-face
    {font-family:"\@SimSun";
    panose-1:0 0 0 0 0 0 0 0 0 0;
    mso-font-charset:134;
    mso-generic-font-family:auto;
    mso-font-format:other;
    mso-font-pitch:variable;
    mso-font-signature:1 135135232 16 0 262144 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
    {mso-style-parent:"";
    margin:0in;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:12.0pt;
    font-family:"Times New Roman";
    mso-fareast-font-family:SimSun;}
@page Section1
    {size:8.5in 11.0in;
    margin:1.0in 1.25in 1.0in 1.25in;
    mso-header-margin:.5in;
    mso-footer-margin:.5in;
    mso-paper-source:0;}
div.Section1
    {page:Section1;}
-->Contuniouc</style>continuous  feedback.


I have crossed yet another problem, trying to link a property grid with an object and managing to change its properties the moment they are changed in the property Grid. The problem lies with the fact that my property grid is not a member of a dialog box, as presented in most of your examples, but i actually created it in my CMainFrame::OnCreate  and appended it on a resizable bar. I think this is more convenient for my project.


The problem is that i cannot find a way to catch events / send messages etc from my property grid so that the properties changed during run-time are reflected instatnly upon the object. I hope there is an easy way to overcome this.  <!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><style type="text/css">
<!--
/* Font Definitions */
@font-face
    {font-family:SimSun;
    panose-1:2 1 6 0 3 1 1 1 1 1;
    mso-font-alt:宋体;
    mso-font-charset:134;
    mso-generic-font-family:auto;
    mso-font-format:other;
    mso-font-pitch:variable;
    mso-font-signature:1 135135232 16 0 262144 0;}
@font-face
    {font-family:"\@SimSun";
    panose-1:0 0 0 0 0 0 0 0 0 0;
    mso-font-charset:134;
    mso-generic-font-family:auto;
    mso-font-format:other;
    mso-font-pitch:variable;
    mso-font-signature:1 135135232 16 0 262144 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
    {mso-style-parent:"";
    margin:0in;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:12.0pt;
    font-family:"Times New Roman";
    mso-fareast-font-family:SimSun;}
@page Section1
    {size:8.5in 11.0in;
    margin:1.0in 1.25in 1.0in 1.25in;
    mso-header-margin:.5in;
    mso-footer-margin:.5in;
    mso-paper-source:0;}
div.Section1
    {page:Section1;}
--</style>



<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Word.Document" name="ProgId" />
<meta content="Microsoft Word 11" name="Generator" />
<meta content="Microsoft Word 11" name="Originator" /><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning />
<w:ValidateAgainstSchemas />
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables />
<w:SnapToGridInCell />
<w:WrapTextWithPunct />
<w:UseAsianBreakRules />
<w:DontGrowAutofit />
<w:UseFELayout />
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><style type="text/css">
<!--
/* Font Definitions */
@font-face
    {font-family:SimSun;
    panose-1:2 1 6 0 3 1 1 1 1 1;
    mso-font-alt:宋体;
    mso-font-charset:134;
    mso-generic-font-family:auto;
    mso-font-format:other;
    mso-font-pitch:variable;
    mso-font-signature:1 135135232 16 0 262144 0;}
@font-face
    {font-family:"Arial Unicode MS";
    panose-1:2 11 6 4 2 2 2 2 2 4;
    mso-font-charset:128;
    mso-generic-font-family:swiss;
    mso-font-pitch:variable;
    mso-font-signature:-1 -369098753 63 0 4129279 0;}
@font-face
    {font-family:"\@SimSun";
    panose-1:0 0 0 0 0 0 0 0 0 0;
    mso-font-charset:134;
    mso-generic-font-family:auto;
    mso-font-format:other;
    mso-font-pitch:variable;
    mso-font-signature:1 135135232 16 0 262144 0;}
@font-face
    {font-family:"\@Arial Unicode MS";
    panose-1:2 11 6 4 2 2 2 2 2 4;
    mso-font-charset:128;
    mso-generic-font-family:swiss;
    mso-font-pitch:variable;
    mso-font-signature:-1 -369098753 63 0 4129279 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
    {mso-style-parent:"";
    margin:0in;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:12.0pt;
    font-family:"Times New Roman";
    mso-fareast-font-family:SimSun;}
@page Section1
    {size:8.5in 11.0in;
    margin:1.0in 1.25in 1.0in 1.25in;
    mso-header-margin:.5in;
    mso-footer-margin:.5in;
    mso-paper-source:0;}
div.Section1
    {page:Section1;}
-->
</style><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--><o:p></o:p>


 

Takis Takoglou Feb 25, 2009 - 5:51 AM

My previous post includes lots of nonsense not posted by me.


Any idea what happened? Should i repost it?

Technical Support Feb 26, 2009 - 12:05 PM

We suspect you paste the funny HTML text generated by MS Word. You can use the preview button before posting messages to check whether the message text is ok.

You should know whether the property grid is located inside your application. If it’s inside control bar, then you can invoke mainframe’s CFrameWnd::GetControlBar() method which returns control bar by its dialog control identifier. The CExtControlBar windows always have only one child window. So, you can get property grid by invoking control bar’s CWnd::GetWindow(GW_CHILD) method.

Takis Takoglou Mar 3, 2009 - 4:25 AM

Once again i found your advice very useful.


I have reached the point that i have my PropertyGrid displaying the properties i want.


 Now i would like to find a way to properly change the values of my bound object once a value on the property grid is changed.


I tried to do that but failed...


When something in the PropertyGrid changes is there any message sent to the MainFrame so that i can catch it and use it to call a function?


I would also like to know the difference between a PropertyGridControl created directly in the MainFrame using m_gridCtrl.Create


and the one used in your examples ie. inside a Dialog as a Custom Control.


How can i catch the messages sent in the one or the other configuration?


 


Thanx in advance,


Stakon.

Technical Support Mar 3, 2009 - 12:05 PM

The directly created property grid control works exactly the same as the property grid control created as a dialog resource. You can see the directly created property grid control in the ProfStudio sample project.

You should override the CExtPropertyGridCtrl::OnPgcInputComplete() and CExtPropertyGridCtrl::OnPgcResetValue() virtual methods in your CExtPropertyGridCtrl-derived class to catch the editing events. The CExtPropertyGridCtrl::OnPgcInputComplete() virtual method is invoked after editing property value using in-place activated grid cell editor. The CExtPropertyGridCtrl::OnPgcResetValue() virtual method is invoked after executing the Reset command from the context menu displayed over a property value. Both your overridden methods should invoke parent class method first, and then get the active grid cell from the specified in parameters property item.

Takis Takoglou Mar 6, 2009 - 4:11 AM

Thanx again for your immediate and helpful response !


I have reached a higher level in MFC programming with your advice.


Then again i always encounter new challenges/problems to overcome.This time i am unable to set the focus on a specific cell in my propertygrid control.


I can set the focus on the propertyGrid itself by :


MyGridCtrl.SetFocus();


but can’t set it for a specific cell within the propertyGrid. Any suggestions?


Stakon.

Technical Support Mar 9, 2009 - 11:44 AM

First of all, what we have is a property grid control and a property value which we need to focus in it:

CExtPropertyGridCtrl * pPGC = . . .
CExtPropertyValue * pPV = . . .

We need to get the active tree grid inside the property grid control:
CExtPropertyGridWnd * pTreeGrid = pPGC->GetActiveGrid();
            if( pTreeGrid == NULL )
                        return . . . // property grid is not initialized yet or even not yet created

We need to get the tree item handle which corresponds to the property value and set focus to it:
HTREEITEM hTreeItem = pTreeGrid->PropertyItemToTreeItem( pPV );
            if( hTreeItem == NULL )
                        return . . . // property value is not present in the property grid
            pTreeGrid->ItemFocusSet( hTreeItem );

Takis Takoglou Feb 20, 2009 - 6:10 AM

I tried to understand your example but as i said above it was too complicated for me.


What i am asking for is a very simple example just a couple of lines of code showing how i can populate a Property grid with one property.


 


You suggest that i create a property store tree; how is this accomplished? I am still very confused  :(


 


Stakon.


 

Technical Support Feb 21, 2009 - 8:38 AM
Takis Takoglou Feb 23, 2009 - 12:40 AM

Thank you very much for your effort to explain me such basic things!


I am beggining to understand the structure and implementation of the property grid now.


I will try to experiment with more complex grids and hopefully understand  your "simple properties" example.


 


Stakon.

Technical Support Feb 19, 2009 - 4:03 AM

The following ZIP file contains the simplest possible sample applications demonstrating how to use the CExtPropertyGridCtrl control:

http://www.prof-uis.com/download/forums/tmp/SimpleProperties.zip

To display properties in the property grid you should do the following:

1) Create property store tree. This is the tree like data structure which contains the CExtPropertyStore object in root node and CExtPropertyCategory and CExtPropertyValue nodes in tree brunches. Each CExtPropertyValue object should have two grid cells representing data of the property value. These cells are called active and default. The active grid cell is used for displaying in property grid control. The default grid cell is used for resetting the property value.

2) You should assign the property store tree to the property grid control. This can be done using the CExtPropertyGridCtrl::PropertyStoreSet() method. Please note, the property grid control does not keep the property store tree. You should not delete the property store assigned to the property grid control.