Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Validating Properties in CMFCPropertyGridCtrl

311 views
Skip to first unread message

in...@rescuerigger.com

unread,
May 1, 2009, 5:50:49 PM5/1/09
to
I’m trying to figure out how to validate data in a property page using
a CMFCPropertyGridCtrl. I overloaded ValidateItemData() and my
function is called when the user leaves the edit control. However, a
call to pProp->GetValue() returns the value before the user made the
changes. It seems like ValidateItemData() is called before the data
has been updated. The code looks something like this:

BOOL CMyPropertyGridCtrl::ValidateItemData( CMFCPropertyGridProperty*
pProp )
{
CString sValue = pProp->GetValue();
// sValue has the original value, e.g., “100”, rather than the
“999” I just typed.
int iValue = _tstoi( sValue );
if( iValue > 100 )
pProp->SetValue( _T(“100”) );
...

Any help would be greatly appreciated… There just isn’t much on the
web regarding these newer MFC classes.

Thanks!

Steve

in...@rescuerigger.com

unread,
May 1, 2009, 6:59:18 PM5/1/09
to
Sure enough. As soon as I post the question (after a day of trying to
solve this), I discover pProp->OnUpdateValue(). That does update the
value.

Steve

Scot T Brennecke

unread,
May 3, 2009, 2:44:52 AM5/3/09
to
As any psychologist will tell you, sometimes it helps to just talk it out. :)

<in...@RescueRigger.com> wrote in message
news:f0bf3352-29d2-47fc...@w35g2000prg.googlegroups.com...

0 new messages