Ask a questionAsk a question
 

AnswerCMFCPropertyGrid

  • Wednesday, November 04, 2009 2:21 AMPechFromTj Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello, 

    Noob question, how can I link a CMFCPropertyGridProperty to a variable in my program? 
    I want a double var to be updated using the Properties Window.
    I've struggled understanding the DWORD_PTR value. I don't care about validation... I just want to change the value in the window and be it reflected in RAM.
    This is what I've done so far:
    1. Made a menu that will display a MessageBox with the value of the variable
    2. Added the Property to the PropertyGrid 

    I'm able to update it (supposedly) but when I display the value it stays the same.
    Thank you for your help..

Answers

  • Wednesday, November 04, 2009 4:11 PMhgn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Try to locate "MDITabsDemo" among the samples for VC2008SP1. In this sample CMFCPropertyGridProperty is used to update attributes in the application class.

    The parameter DWORD_PTR dwData is not the actual value to be edited but a ID-value you can pick up later with CMFCPropertyGridProperty::GetData(), for example in your handler of the message AFX_WM_PROPERTY_CHANGED in order to know what attribute has been changed.

    • Marked As Answer byPechFromTj Wednesday, November 04, 2009 7:41 PM
    •  

All Replies

  • Wednesday, November 04, 2009 3:07 AM«_Superman_»MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I've struggled understanding the DWORD_PTR value.

    DWORD_PTR becomes a 32-bit unsigned value in a 32-bit build and a 64-bit unsigned value in a 64-bit build without changing any code.

    «_Superman_»
    Microsoft MVP (Visual C++)
  • Wednesday, November 04, 2009 6:15 AMPechFromTj Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yeah, I kind of understand that part, but the thing is, how do I change the value of a variable using the CMFCPropertyGrid.

  • Wednesday, November 04, 2009 4:11 PMhgn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Try to locate "MDITabsDemo" among the samples for VC2008SP1. In this sample CMFCPropertyGridProperty is used to update attributes in the application class.

    The parameter DWORD_PTR dwData is not the actual value to be edited but a ID-value you can pick up later with CMFCPropertyGridProperty::GetData(), for example in your handler of the message AFX_WM_PROPERTY_CHANGED in order to know what attribute has been changed.

    • Marked As Answer byPechFromTj Wednesday, November 04, 2009 7:41 PM
    •  
  • Wednesday, November 04, 2009 7:42 PMPechFromTj Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Try to locate "MDITabsDemo" among the samples for VC2008SP1. In this sample CMFCPropertyGridProperty is used to update attributes in the application class.

    The parameter DWORD_PTR dwData is not the actual value to be edited but a ID-value you can pick up later with CMFCPropertyGridProperty::GetData(), for example in your handler of the message AFX_WM_PROPERTY_CHANGED in order to know what attribute has been changed.

    Thank you very much.... at least I have some code to analyze and try to understand! The wizard just gives you some code but that it's not linked to actual variables , but with the sample, I'm sure I'll figure out how it works.
    Thank you!

    I did a workaround, deriving my own PropertyGridCtrl and PropertyGridProperty, overriding the OnPropertyChanged adding some methods (overloaded) using pointers to the variables, it works ok, but I want to know how I'm supposed to do it using MFC methods. Once again, thank you!