C ++ one of the methods for using CMFCPropertyGridCtrl (original), cmfcpropertysheet
Digress:
Recently I am writing an important program and want to be more flexible. So I want to use a dialog box,
However, I checked several books in C ++ and MFC from major departments and found a lot of online materials. There are very few introductions in this regard. Fortunately, VS2013 is semi-open source. Haha, the extracted code is invisible, but the function declaration can still be seen. This provides a good way for me to solve the problem, and the online MSDN is also a good way to learn. However, Chinese translation is really not flattering. It is a bad thing and basically cannot be understood, what is he talking about? He can only chew on English.
Therefore, it is not easy to learn things. If you learn things, you must not forget the summary. Otherwise, you will forget it after a while, which is a pity.
Let alone nonsense.
I. About CMFCPropertyGridCtrl and CMFCPropertyGridProperty, they are a good couple. Do not read the error.
CMFCPropertyGridCtrl is a container that contains several CMFCPropertyGridProperty projects. CMFCPropertyGridProperty is the real project content.
The magic of CMFCPropertyGridProperty is that it can be nested and belongs to a set of attributes.
In my example, the black box can be considered as the CMFCPropertyGridCtrl container. In my image, I added five top-level attributes. For example, "Overview" is the first top-level Attribute. You can use the AddProperty () method of CMFCPropertyGridCtrl: The method declaration is as follows:
int AddProperty(CMFCPropertyGridProperty* pProp, BOOL bRedraw = TRUE, BOOL bAdjustLayout = TRUE);
Before adding this attribute, you must construct an attribute. In this attribute, there are several second-level attributes, such as the "title" and "level" under "Overview". These two attributes belong to the "Overview" attribute.
Therefore, after declaring an attribute, we need to add the subattribute to the attribute. The method is also quite simple. The instance method using CMFCPropertyGridProperty is as follows:
BOOL AddSubItem(CMFCPropertyGridProperty* pProp);
You can use this to add other subcategories to the current attribute. How to declare a declaration? You can see the following declaration functions at a glance.
// Group constructor is used to generate the attributes CMFCPropertyGridProperty of Group attributes (const CString & strGroupName, DWORD_PTR dwData = 0, BOOL bIsValueList = FALSE ); // Simple property is used to generate the attributes CMFCPropertyGridProperty (const CString & strName, const COleVariant & varValue, LPCTSTR lpszDescr = NULL, DWORD_PTR dwData = 0, LPCTSTR lpszEditMask = NULL, LPCTSTR lpszEditTemplate = NULL, LPCTSTR lpszValidChars = NULL );
The preceding two constructors are used to construct a new attribute. Here, the two constructors have different functions.
If you declare only one architecture, as shown in the top-level Attribute "Overview" above. This is a title with no attribute values. Declare this attribute without attribute values and use the first constructor. Declare attributes with specific values to use 2nd constructors.
Then a CMFCPropertyGridCtrl may be constructed step by step.
Paste a piece of code. Let's take a look at the process of constructing an attribute.
CMFCPropertyGridCtrl m_wndPropList;
COleVariant var0;var0.intVal = 0;var0.ChangeType(VT_I4);
Fccmpropertygridproperty * pGroup1 = new CMFCPropertyGridProperty (_ T ("Overview"); pGroup1-> AddSubItem (new CMFCPropertyGridProperty (_ T ("title"), (_ variant_t) _ T ("Title 1"), _ T ("title content used to display in view "))); pGroup1-> AddSubItem (new CMFCPropertyGridProperty (_ T ("level "),Var0, _ T ("current display plan level"); m_wndPropList.AddProperty (pGroup1 );
Today, we will briefly introduce the CMFCPropertyGridCtrl control. Let's talk about the details in section 2.