How do I embed (and use) a button in a CMFCPropertyGridProperty?

78 Views Asked by At

I notice this API call: CMFCPropertyGridProperty::AdjustButtonRect. But how do I add a button to a CMFCPropertyGridProperty? I would like to show a custom button on the right and manage clicking the button.

Related question:

Drawing my own embedded button with CMFCPropertyGridProperty and detecting the button state

1

There are 1 best solutions below

0
Andrew Truckle On BEST ANSWER

After further research I found another conversation on CodeProject saying to use HasButton(). If I add this override to my class:

BOOL HasButton() const
{
    return TRUE;
}

Then it will show ... on the right, which is at-least a step forward!

Then, I used the code search feature in Visual Studio 2022 and noticed an undocumented method (OnClickButton)! If I override it:

virtual void OnClickButton(CPoint point)
{
    AfxMessageBox(L"Button clicked!");

}