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);
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?