PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → Autoresize Text in Static
Autoresize Text in Static
Started by Sebastian Arnold, Oct., 13 2014 5:55 PM - 1 reply
Registered member
102 messages
Posted on October, 13 2014 - 5:55 PM
Just imagine a simple and small text static control in Font Size 9.

At the beginning it has the caption "SmallText". It displays nicely.

Then, when the caption changes to "AVeryLongTextThatUsualyDoesntFit" I don't want this ending with 'ellipse' like "..."

Instead I wan't to automatically change the font size till it fits in the initial size of the control.

Any ideas how to do this?

TIA
Sebastian
Registered member
102 messages
Posted on October, 17 2014 - 3:27 PM
I can answer this by myself:

The function is called TextWidth(): http://doc.windev.com/en-US/…

Example of an edit control:

In the 'whenever modified' part of the code, put something like this:

nPix is int = TextWidth(MySelf, MySelf..Value)
IF nPix > MySelf..X THEN
MySelf..FontSize = MySelf..FontSize - 1
END


This example does only work in one direction, though. It can only shrink the font size.

HTH
Sebastian