Jump to content

GUI_AutoAdjustStringSize


KaFu
 Share

Recommended Posts

HiHo Forum,

as some of you might have noticed ;), I released SMF v1.3 the day before yesterday. As the devil always does, he stroke me in the back with a tiny annoyance. I use the three fonts "Tahoma", "Arial" and "Lucida Console" in it.

Now I received a feedback saying the font is out of line, labels and controls only partially visible. I was first wondering what the hack is going on, giving it a second thought I remembered that the target system might not have these fonts installed (Chinese OS using SimSun?).

Looking for a quick and dirty solution / work-around I remembered Melba23s StringSize UDF... and Ascend4nts EnumChildWindows UDF, and finally this recent post by Yashied with a GUICtrlGetFont() function.

Throwing it all together I came up with this. It's not meant to heal massive design failures (e.g. fitting a looooooooooooong text into a small control), but to clean up small glitches which might happen if the size of the text in the intended font is slightly smaller then in an unwanted replacement font.

I used a font-size step of -0.25 and a minimum font size of 2. Any opinions on those values? Is a size step of 0.25 valid at all?

In the example I call _GUI_AutoAdjustStringSize($hGUI) 1000ms after GUISetState() for demonstration, normally it should be placed directly in front of it.

For sure needs adjustment & polishing, more a proof of concept until now :).

Regards

GUI_AutoAdjustStringSize.zip

Edited by KaFu
Link to comment
Share on other sites

What would be a possible use of this? When you run the example, it neither wraps the text correctly, nor adjusts the font size to fit in the control and be still readable, nor resizes the control to include the whole text, nor truncates the text at word boundaries, with ellipses or in any other manner.

I am not criticizing your work but IMHO you should provide a better illustration.

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE 

Link to comment
Share on other sites

Is this is how it's supose to be:

Posted Image

?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Not quite :), as mentioned work in progress ;)...

The first one is wrong because the label is larger then the GUI due to autosizing during creation (needs to be considered in the calc).

For the next two the the "optimized" text is too short imho, thats due to fact the math is not optiomal at the moment.

The last one looks quite okay already.

As I said, proof of concept, work in progress... and invitation for you to help me tweak it ;).

In the end it's meant to be a fallback for font related problems, e.g. following condition can be added:

If not FileExists(@WindowsDir & '\Fonts\TAHOMA.ttf') Then _GUI_AutoAdjustStringSize($hGUI)

For performance improvement Melbas StringSize function should be seperated into an initialization, work and shutdown function (to create only one sample GUI and not destroy it on each call).

And finally the retunrs from EnumChildWindows should be skipped if not "Static".

Link to comment
Share on other sites

I think the best way is to adjust the control size, not the font.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...