PDA

View Full Version : Disable progress bar


wheleph
4th July 2008, 14:39
Hello, guys.

I wan't to disable progress bar in MUI_PAGE_INSTFILES windows. Any suggestions?

kichik
11th July 2008, 12:20
Hide it using ShowWindow.

wheleph
11th July 2008, 15:35
> Hide it using ShowWindow
kichik,
I don't understand what do you mean. I don't need to hide the whole window I just don't want a progress bar to be displayed. Give some script snippet to clarify your idea.

Animaether
11th July 2008, 19:25
"ShowWindow" is an unfortunately-named function in the Windows APIs that allow you to show/hide an UI element.. be that a window or a textbox, checkbox, progress bar, etc.

NSIS keeps the same function name for code reasons.

What kichik means is that you should hide the progressbar by using "ShowWindow <progress bar control hwnd> ${SW_HIDE}"

That "${SW_HIDE}" is a code that is defined in one of the include files that comes with NSIS. Add "!include WinMessages.nsh" to the top of your script so that your installer will know what "SW_HIDE" means.

You can get "<progress bar control hwnd>" from the inner dialog of the installer. The inner dialog you can find with:
FindWindow $0 "#32770" "" $HWNDPARENT
Basically this says "Inside $HWNDPARENT (the installer's hwnd), look for the control identified as class #32770 (a dialog) and put the result in $0".

Then you need the ID of the control within that dialog. My suggestion is to download WinSpy++. Run that and drag the crosshairs over the progress bar when running an installer. It'll tell you the Control ID. In my case it's "3EC". This is a hexadecimal number, so if you refer to it, put "0x" in front.

So to get the control's hwnd out of the dialog, you would use:
"GetDlgItem $1 <dialog_hwnd> 0x3ec"
Meaning "From <dialog_hwnd>, get the control with ID 0x3ec, and put that in $1".

So now you have all the information you need to hide it.

Section ""
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $1 $0 0x3ec
ShowWindow $1 ${SW_HIDE}
SectionEnd


That "3ec" isn't likely to change - however, if you want to make your code a little more robust, you can also refer to the progress bar's class. Remember how we got the class "#32770" to get the inner dialog? We can use the same to get the progressbar out of the inner dialog. The progressbar's class is "msctls_progress32". So the new code would become:


FindWindow $0 "#32770" "" $HWNDPARENT
FindWindow $1 "msctls_progress32" "" $0
ShowWindow $1 ${SW_HIDE}


The code above should work fine in your installer (although you may wish to move the code outside of the Section code and inside a function that handles the dialog before any Sections), but I hope the above taught you something about FindWindow, ShowWindow, GetDlgItem and how to get a Control ID using WinSpy++ as well.

wheleph
15th July 2008, 08:48
Thanks, Animaether, for your great post. It gives a comprehensive answer to my question. I've used the second approach (with 'FindWindow $1 "msctls_progress32" "" $0') in my installer.