Angus Leeming
26th June 2005 23:02 UTC
Vertical layout in .ini files
Is it possible to discover how much vertical space a Text object in a .ini file is really taking up? If I'm inserting translated strings (possibly multi-line), it would be nice to make the vertical layout look good as opposed to my current "leave lots of space just in case".
Angus
Afrow UK
27th June 2005 10:04 UTC
WriteINIStr will put in new lines for new key=value's if no more exist, so you don't need to leave any blank lines.
-Stu
Angus Leeming
27th June 2005 10:18 UTC
I think we misunderstand each other. I have a .ini file containing
widget1
text2
widget3
I was wondering if there was any way to find out how much vertical space text2 actually took up (how many lines) so that I could position widget3 correctly.
Angus
ps WriteINIStr doesn't work for me. I have to use MUI_INSTALLOPTIONS_WRITE.
A.
Afrow UK
28th June 2005 08:50 UTC
Right I see :)
MUI_INSTALLOPTIONS_WRITE is really a macro with WriteINIStr in it. With WriteINIStr you need to specify $PLUGINSDIR in the INI file path.
I'll have to write a Function to do this check (will use FileOpen and FileRead).
I'm wondering though that if you have an = sign on one of the other lines, it will stop there thinking that's another key=value... Will that cause any problems in your case?
-Stu
Afrow UK
29th June 2005 12:22 UTC
I just got round to writing the function. Now I'm going to submit it on the Wiki but I'm a bit lost at the system there.
-Stu
Angus Leeming
29th June 2005 23:07 UTC
Please tell us where to find it when you eventually succeed.
Angus
Afrow UK
30th June 2005 13:46 UTC
Oh sorry, it's at http://nsis.sourceforge.net/wiki/Get...INI_file_value
-Stu
Angus Leeming
30th June 2005 16:02 UTC
Thanks, Stu. I've tried it but it doesn't do what I'm looking for.
StrCpy $0 "a really long line that wraps over several lines a really long line that wraps over several lines a really long line that wraps over several lines a really long line that wraps over several lines"
!insertmacro MUI_INSTALLOPTIONS_WRITE "myfile.ini" "Field 1" "Text" "$0"
${GetValueVertSpace} $1 "myfile.ini" "Field 1" "Text"
MessageBox MB_OK "Number of lines: $1"
This returns "1" rather than the "3" or "4" I was hoping for.
In turn, that's not surprising. The number of lines is a function of how the the string is displayed in the dialog, not how it's stored in the .ini file.
Anyway, many thanks for your time and effort.
Angus
Afrow UK
30th June 2005 16:05 UTC
If you want it to find out how many lines it takes up when placing the text in a label, then that's completely different. It won't work properly by counting the number of characters, because font sizes and types may vary from system to system, but it's a start.
You can also however chop a string down to a certian length using this function:
http://nsis.sourceforge.net/wiki/Tri...fit_in_a_label
-Stu