Pankaj
Pankaj

Reputation: 2744

Resize Controls Dynamically Based on Text

Using C++ and Windows, I want to resize a Button Width based on the Content.

For example if button text is "OK", then the width of button becomes let say 10 and if the content is "Cancel", then the width becomes 20. I know how to resize the control but I am not able to calculate how much we need to resize.

Any idea, How can we do that ?

Thanks

-Pankaj

Upvotes: 0

Views: 509

Answers (1)

jsist
jsist

Reputation: 5253

USe GetTextExtentPoint32 to get dimensions of the text and then use SetWindowPos to resize the control.

Hope this will help and solves your problem...

Upvotes: 2

Related Questions