1

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.

Community
  • 1
  • 1
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • I bet you are using the resize-dialog method which I suggested in a different topic. That method moves the buttons and resizes the child controls. It sees this static control and tries to resize it. This is not a true gripper even if you solve the background issue. It's just drawing something where the gripper is supposed to be. – Barmak Shemirani Jun 21 '18 at 15:26
  • @BarmakShemirani Yes, I am using your defer resizing. Now, even if I use your gripper rendering, whilst it looks OK I can get it to not render correctly. – Andrew Truckle Jun 21 '18 at 15:31
  • I have never had problems with [this gripper method](https://stackoverflow.com/questions/36871397) You seem to be using Windows Blind, maybe it's causing a specific error. Can you show the problem with the gripper method from the link? – Barmak Shemirani Jun 22 '18 at 01:55
  • @BarmakShemirani I am using WindowsBlind. Don’t worry as I needed OEM_SIZE for consistency. – Andrew Truckle Jun 22 '18 at 03:53

2 Answers2

1

Modify the style for CMFCPropertySheet and add WS_CLIPSIBLINGS!

Add WS_CLIPSIBLINGS to the gripper window too.

Add WS_CLIPCHILDREN to the CPropertySheet.

xMRi
  • 14,982
  • 3
  • 26
  • 59
  • Please see updated question. I have added this style and it makes no difference. – Andrew Truckle Jun 21 '18 at 12:20
  • Just checked my settings and changed the answer. – xMRi Jun 21 '18 at 13:18
  • I already had `WS_CLIPCHILDREN` for the sheet. I added `WS_CLIPSIBLINGS` to the anchors `Create` paramaters and still no joy. – Andrew Truckle Jun 21 '18 at 14:21
  • The updated answer here gives the principles I needed: https://stackoverflow.com/questions/50955709/making-a-cmfcpropertysheet-resizable-with-dynamic-layouts/50956301?noredirect=1#comment88940931_50956301 – Andrew Truckle Jun 21 '18 at 16:12
1

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.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • The updated answer here gives the principles I needed: https://stackoverflow.com/questions/50955709/making-a-cmfcpropertysheet-resizable-with-dynamic-layouts/50956301?noredirect=1#comment88940931_50956301 – Andrew Truckle Jun 21 '18 at 16:12