Print Page | Close Window

Is there a SizeToContent function?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=24079
Printed Date: 21 November 2024 at 11:41am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Is there a SizeToContent function?
Posted By: Jadduni
Subject: Is there a SizeToContent function?
Date 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



Replies:
Posted By: dbrookes
Date 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.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net