I want to have a text that expands himself until reaches 80% of window with or 10% of windows height (with canvas dimensions adapting the the text size)
I put the following code insite the canvas paint event
[code]
dim i as integer
do
i=i+1
g.TextSize = i
g.DrawString(win.textfield1.text, 0, 15)
me.width =g.StringWidth (win.TextField1.Text)
me.height = g.StringHeight(win.TextField1.Text, me.width)+15
loop until me.width>=win.width80/100 or me.height>=win.height10/100[/code]
it was working fine until i decided to add the do-loop circuit to create the “auto-expand” system but now it’s horrible
it flickers and it just wont work anymore.
How can I fix it ?
thanks
Windows 7. Why? does it work on yr computer ? here it’s a mess.
I suspect there must be something also about the order of wich events are called that I still have difficulties to master and understand
(paint within canvas etc etc)
But what is the Loop good for then?
Why not just resize the Text and the Canvas if the Window resizes or has been resized?
Couldn’t you just invalidate the Canvas when the resizing and/or resized event of the Window fires and do the Paint then?
Because I can’t know at what size the canvas and text will need to be resized.
The text string given changes at runtime so there is no way I can predict at design time the needed dimensions
[quote=122131:@Julen Ibarretxe Uriguen]Wouldn’t the “me.width=…” line call a refresh, which will trigger a new paint event, in which you set me.width again…? Just a guess.
[/quote]
yes I’m afraid something similar is happening. this would explain all the flickering and freezings…
jesus christ I love Xojo but I miss so much auto-sizing properties from VB6…
dim s as string
s="autosize this !"
g.Bold=true
g.TextUnit = FontUnits.Pixel
g.TextSize =win.canvas.height
g.DrawString(s,me.width/2- g.stringwidth(s)/2, g.textsize-10 )