CMFCPropertyGridProperty

This is a discussion on CMFCPropertyGridProperty within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I'm an Italian new C++ programmer and I need help to solve a problem that I think wuold be ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    3

    CMFCPropertyGridProperty

    Hello,

    I'm an Italian new C++ programmer and I need help to solve a problem that I think wuold be very easy for normal or well skilled C++ programmer.
    I have installed MFC Feature pack and I'm trying to retrieve a value from a CMFCPropertyGridProperty object. I want to retrieve a color value. I have two major problems. The first in what way I can call the various subitem in my grid object? The next Problem is in what way I can retrieve the color value from the palette (If I do this where the palette is defined I can use the GetColor() method but i can't use this method if I try to do this in any other part of the application). I'm triyng to use the color palette in order to make a drawcli like application
    Thank you for the help.

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    I am not really familiar with these kind of objects. But post your code so we can find the problem. Post part of your code that seems to have the problem if you prefer

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    3
    Thank you for your disponibility...so that's the code

    Code:
    void CPropertiesWnd::InitPropList()
    {
    ...
    	CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T
    ("Colore della finestra"), RGB(210, 192, 254), NULL, _T("Specifica il colore predefinito della finestra."));
    	pColorProp->EnableOtherButton(_T("Altro..."));
    	pColorProp->EnableAutomaticButton(_T("Predefinito"), ::GetSysColor(COLOR_3DFACE));
    	pGroup3->AddSubItem(pColorProp);
    
    ...
    }
    I'm trying to retrieve the value this item gives anytime that it change...

    Thank you for your help
    Last edited by Laan; 10-02-2008 at 05:58 AM.

  4. #4
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Well, I would need to see all the code to say 100%
    But what you are doing is declaring a pointer pColorProp inside a function. So it has LOCAL scope. That means that when the function returns the pointer is gone. And you cannot access the memory pointed by it which was allocated with new. So you will also have a memory leak.

    What you want to do is have the pointer declared somewhere else. For example if you want the access the object in a global scope (or other scope depending where this code is) you can do this:
    Code:
    CMFCPropertyGridColorProperty* pColorProp;
    void CPropertiesWnd::InitPropList()
    {
    ...
    pColorProp = new CMFCPropertyGridColorProperty(_T...
    ...
    }
    There are other ways, but I think this is what you want

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    3
    Excuse me but the problem is a little more difficult. Prior to this discussion I have proved to declar a COLORREF variable to save the value retrieved by the menu palette in a global way but my problem is that there isn't a listener that update the value of my variable any time that it change. I'm finding the way to do something similiar at the ON_OK command in dialog control. So I can change the color of the draw I make...If it can help I will publish all the class CPropertiesWnd, but I think it is a bit longer since I can post it here. I hope that I have explained my problema better. Thank you another time
    Last edited by Laan; 10-02-2008 at 06:57 AM.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21