Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - Is there a SizeToContent function?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Is there a SizeToContent function?

 Post Reply Post Reply
Author
Message
Jadduni View Drop Down
Newbie
Newbie


Joined: 12 October 2020
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jadduni Quote  Post ReplyReply Direct Link To This Post Topic: Is there a SizeToContent function?
    Posted: 12 October 2020 at 7:29am
hello,
perhaps I oversee something here. I'm new to the toolkit, playing with the markup enabled buttons.
Is there any FitToContent function, that will resize the button to 100% of the markup content?

I can see the scaling function on the markup content, but how can I scale the button to fit the markup at 100%.

Thanks
Didi
Back to Top
dbrookes View Drop Down
Groupie
Groupie


Joined: 30 August 2019
Location: Australia
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote dbrookes Quote  Post ReplyReply Direct Link To This Post Posted: 29 October 2020 at 11:32pm
You could probably write your own, something like this:

void FitToContent(CXTPButton *pwndButton, CSize szMax)
  {
  if (pwndButton->GetSafeHwnd())
    {
    CXTPMarkupUIElement *pUIElement = pwndButton->GetMarkupUIElement();
    if (pUIElement)
      {
      // Measure markup UI elementw ith max size limits and get the measured desired size.
      CSize sz = XTPMarkupMeasureElement(pUIElement, szMax.cx, szMax.cy);

      // Resize the button window.
      pwndButton->SetWindowPos(NULL, 0, 0, sz.cx, sz.cy, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
      }
    else
      {
      // Not a markup enabled button...
      }
    }
  }

I've done similar things to resize a markup list box window if the item text is too long due to the language changing. With a button though there may be borders to deal with as well?

Regards,
Daniel.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.