Adding a resize anchor to derived CMFCPropertySheet class

310 Views Asked by At

Thanks to the support of Stack Overflow I have been able to create my own CResizingMFCPropertySheet that supports resizing. Now, I went to add a resize anchor and I used this code:

void CResizingMFCPropertySheet::InitialiseResizeIcon()
{
    CRect rcIcon, rcClient;

    m_bmpResize.LoadOEMBitmap(OBM_SIZE);
    m_lblResize.Create(0, WS_CHILD | WS_VISIBLE | SS_BITMAP, 
               CRect(0, 0, 16, 16), this, IDC_STATIC_RESIZE);
    m_lblResize.SetBitmap(m_bmpResize);

    GetClientRect(rcClient);
    m_lblResize.GetClientRect(rcIcon);
    m_lblResize.SetWindowPos(&CWnd::wndTop, rcClient.right - rcIcon.Width(), 
               rcClient.bottom - rcIcon.Height(), 0, 0, SWP_NOSIZE);
}

(Note: The above code is revised and no longer uses dynamic layout - doesn't work).

The method gets called in OnInitDialog. When the sheet is first displayed it looks OK:

Property Sheet

You can see the anchor in the bottom right. Now, when i go to resize the window:

Resizing sheet

As you can see it is not rendering the anchor properly.

Update

I have set WS_CLIPSIBLINGS and it makes no difference.

Update

Just to let everyone know the reason the new themed gripper was not working right was because I did not add the OnNcHitTest handler etc.

2

There are 2 best solutions below

1
On BEST ANSWER

I've never tried that, I did some searching and there appears to be some issues in doing this dynamically. Some said it cannot be done, others seem to propose ways of doing it. Here is are some of the better links I found, hope this helps.

How to add a gripper to a PropertySheet?

https://www.codeproject.com/Tips/214744/How-to-implement-a-resizable-property-sheet-class

https://social.msdn.microsoft.com/Forums/vstudio/en-US/2a85d3a9-3f91-482c-8bc3-02e132035c7f/cannot-resize-a-new-cmfcpropertysheetcmfcpropertypage?forum=vcgeneral

https://www.codeguru.com/cpp/controls/propertysheet/article.php/c543/Resizing-the-Property-Sheet.htm


This one helped in the end:

Making a CMFCPropertySheet resizable with dynamic layouts

The answer there explains how to correctly drawn custom child controls with OnSize.

4
On

Modify the style for CMFCPropertySheet and add WS_CLIPSIBLINGS!

Add WS_CLIPSIBLINGS to the gripper window too.

Add WS_CLIPCHILDREN to the CPropertySheet.