C++ MFC Property Wnd - Get changed property



I'm currently starting to learn MFC, and I'm now in the process of learning the property window.

I can successfully create properties, but when the times come to getting the changed property, I'm stuck, here is what i have:

The creation of a property, the location. ( See the definitions below )

1
2
3
4
5
6
7
8
9
10
CMFCPropertyGridProperty* pPos = new CMFCPropertyGridProperty(_T("Position"), ID_PROPERTY_LOCATION, TRUE);
pProp = new CMFCPropertyGridProperty(_T("X"), (_variant_t) ID_PROPERTY_LOCATION_X, _T("The X Coordinate of the object"));
pProp->EnableSpinControl(TRUE, 50, 300);
pPos->AddSubItem(pProp);
pProp = new CMFCPropertyGridProperty( _T("Y"), (_variant_t) ID_PROPERTY_LOCATION_Y, _T("The Y Coordinate of the object"));
pProp->EnableSpinControl(TRUE, 50, 200);
pPos->AddSubItem(pProp);
pProp = new CMFCPropertyGridProperty( _T("Z"), (_variant_t) ID_PROPERTY_LOCATION_Z, _T("The Z Coordinate of the object"));
pProp->EnableSpinControl(TRUE, 50, 200);
pPos->AddSubItem(pProp);


Definitions:

1
2
3
4
#define ID_PROPERTY_LOCATION            6
#define ID_PROPERTY_LOCATION_X          7
#define ID_PROPERTY_LOCATION_Y          8
#define ID_PROPERTY_LOCATION_Z          9 


To catch the changed property i try this:

1
2
afx_msg LRESULT OnPropertyChanged( __in WPARAM wparam, __in LPARAM lparam );
// This is in the class of CPropertiesWnd 


The actual function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
LRESULT CPropertiesWnd::OnPropertyChanged(
    __in WPARAM wparam,
    __in LPARAM lparam )
{
    // Parameters:
    // [in] wparam: the control ID of the CMFCPropertyGridCtrl that changed.
    // [in] lparam: pointer to the CMFCPropertyGridProperty that changed.

    // Return value:
    // Not used.

    // Cast the lparam to a property.
    CMFCPropertyGridProperty * pProperty = ( CMFCPropertyGridProperty * ) lparam;
    switch( wparam )
    {
    case( ID_PROPERTY_LOCATION ): 

        // Determine which property was changed.
        switch( pProperty->GetData() )
        {
        case( ID_PROPERTY_LOCATION_X ):
            // Get the property's current value.
            COleVariant v = pProperty->GetValue();
            AfxMessageBox("Changed");
            break;
        }
        break;
    }

    // Note: the return value is not used.
    return( 0 ); 
}


Now the function is triggered perfectly, but for some reason the wparam is ALWAYS 2, do you guys have any idea why?
From what I just looked up (MSDN) - the WPARAM holds the ID of the Property List

The LPARAM - A pointer to the property (CMFCPropertyGridProperty) that changed. - You already know that.

( I don't know enough about the CMFCPropertyGridProperty to give to add any more detail)
Topic archived. No new replies allowed.