Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetCMFCPropertyGrid

  • Mittwoch, 4. November 2009 02:21PechFromTj TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    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..

Antworten

  • Mittwoch, 4. November 2009 16:11hgn TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet

    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.

    • Als Antwort markiertPechFromTj Mittwoch, 4. November 2009 19:41
    •  

Alle Antworten

  • Mittwoch, 4. November 2009 03:07«_Superman_»MVPTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    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++)
  • Mittwoch, 4. November 2009 06:15PechFromTj TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Yeah, I kind of understand that part, but the thing is, how do I change the value of a variable using the CMFCPropertyGrid.

  • Mittwoch, 4. November 2009 16:11hgn TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet

    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.

    • Als Antwort markiertPechFromTj Mittwoch, 4. November 2009 19:41
    •  
  • Mittwoch, 4. November 2009 19:42PechFromTj TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    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!