Archive: Button size depending on text amount


Button size depending on text amount
I have a custom page where button texts can be set externally (localization purposes). I'm considering to use the code that would automatically resize the buttons according to text amount. For that, it needs to determine the string size in dialog units. So far I've come up with this:

StrCpy $1 "a string"
StrLen $2 $1
System::Call 'user32::GetDC(i $HWNDPARENT) i. R1'
System::Call '*(&i4, &i4) i .R2'
System::Call 'gdi32::GetTextExtentPoint32(i R1, t r1, i r2, i R2) i.'
System::Call '*$R2(&i4,&i4)i(.r3,.r4)'
System::Free $R2
# $3 = Width, $4 = Height

This returns the string dimensions in logical units. So now I'm trying to figure out the proper way to convert that to dialog units.

Did you see this article:
http://support.microsoft.com/kb/125681

Stu


Now I did. :o Thanks!