Ivan Andreevich
23rd December 2008 02:25 UTC
MUI_PAGE_INSTFILES progress bar doesn't show 100%
The progress bar is behaving strangely on my MUI instfiles page. When the installation is complete and all that's left to do is to press the "Close" button, the it stops at around 80%.
Any way to force it to be 100% at this point? I seem to remember seeing a way of doing it, but I can't find it any more. Or, perhaps, someone has an idea about why it's at 80%?
Ivan
Animaether
23rd December 2008 03:28 UTC
are you exiting a Section early, perhaps? The progress bar depends on the number of commands in each section combined, increasing with each command passed. If you bail out of a section early using some other method than a goto, it might not catch that the installer is actually 'done' as far as you're concerned.
as far as changing the progress bar:
OutFile "c:\testsetup.exe"
Page InstFiles
!define PBM_SETPOS 0x0402
Function SetProgress
IntOp $R9 $R9 * 300
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 0x3ec
SendMessage $R0 ${PBM_SETPOS} $R9 ""
; MessageBox to show the progress in example
MessageBox MB_OK "."
FunctionEnd
Section
StrCpy $R9 10
Call SetProgress
StrCpy $R9 50
Call SetProgress
StrCpy $R9 30
Call SetProgress
StrCpy $R9 100
Call SetProgress
SectionEnd
You'd stick something like that (sans the messagebox) in the installfiles page's exit function, perhaps, making sure to set it to 100%.
Ivan Andreevich
25th December 2008 02:04 UTC
I was exiting via "Return". Switched to using GoTo and a label at the end of the section. For some reason it's still showing around 95% completion, but much better than before.
JasonFriday13
26th December 2008 17:59 UTC
Try using a Nop (placeholder) at the very end of the section.
[edit] I'm a programmer and goto's are evil (for me anyway).
Ivan Andreevich
5th January 2009 18:56 UTC
Awesome, dude - Nop did the trick perfectly :) Progress bar is now at 100%.
I don't like goto's as well, but in this case what do you suggest?
JasonFriday13
7th January 2009 06:45 UTC
I would suggest LogicLib.nsh, which is included in nsis. It makes the code easier to read and you don't have to worry about label names for goto's. It also makes the code look more like the 'if' statement from C. Example:
${if} $0 == 1
; $0 equals 1 (its a True statement in boolean terms).
${else}
; $0 not equal, so do something else (False statement).
${endif}
Ivan Andreevich
7th January 2009 20:13 UTC
I do use LogicLib, but in this case I need to be at the end of the section for the progress bar to show 100%. I don't see how it helps here.
JasonFriday13
9th January 2009 23:58 UTC
Well, the progress bar is calculated on how many instructions are in the section(s). So if you have a compare statement and it jumps to the end of the section, the progress bar won't change to 100% because there are no more instructions in that section to execute. Thats why putting Nop at the end of that section makes the progress show 100%. Nop executes as an instruction but it does nothing, so its great as a placeholder.
I'm not sure how to solve your code (because I haven't seen it), but you could try wrapping that entire section of code in an if statement, and when its false it skips the code in the if statement (same as a jump-to).