Skip to content
⌘ NSIS Forum Archive

Vertical progress bar?

6 posts

JasonFriday13#
Same. I've seen a late 1990's installer with vertical progress bars to show drive space, overall install progress, and single file progress. Other than that I've only seen horizontal progress bars.
Kuppy#
# Test Progressbar Vertical
Name "NSIS Test"
Caption "NSIS Test"
OutFile "NSIS Test.exe"
InstallDir "$TEMP\NSIS Test"
# COMPRESS
SetCompressor lzma
# RUN
RequestExecutionLevel user
# HIDE # SHOW
ShowInstDetails nevershow
ShowUninstDetails NeverShow
# INCLUDES
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "FileFunc.nsh"
!include "WinMessages.nsh"
# Icon & Stye
BrandingText /TRIMRIGHT " "
Icon "Icon\appicon.ico"
!define MUI_ICON "Icon\appicon.ico"
Page custom Page.Custom.Test /ENABLECANCEL 
Page instfiles 
# LANGUAGES
!insertmacro MUI_LANGUAGE "English" # first language
Function .onInit
FunctionEnd 
!define PB_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
!define PBS_SMOOTH 0x01
!define /math PBM_SETRANGE32 ${WM_USER} + 6
!define PBS_VERTICAL 0x04
Function Page.Custom.Test
  Var /GLOBAL Dialog
  var /GLOBAL Btn_Test
  var /GLOBAL Percent
  var /GLOBAL ProgressBar
  GetDlgItem $0 $HWNDPARENT 1
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 2
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 3
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1990
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1991
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1992
  ShowWindow $0 ${SW_HIDE}
  System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 632,i 465,i 0x16)" 
  nsDialogs::Create /NOUNLOAD 1044 
  Pop $Dialog 
  ${If} $Dialog == error 
   Abort 
  ${EndIf} 
  System::Call "user32::MoveWindow(i$Dialog,i0,i0,i 632,i 465,i0)" 
  SetCtlColors $Dialog 0xFFD99F 0x0262626
  # TEST
  nsDialogs::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 19%u 15u 8% 10u "0%"
  Pop $Percent
  SetCtlColors $Percent 0xFFD99F 0x0262626
  nsDialogs::CreateControl msctls_progress32 0x40000000|0x10000000|0x04000000|0x01|0x04 0x00000100|0x00000200 5% 30u 5u 205u ""
  Pop $ProgressBar
  # BTN test
  nsDialogs::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 50u 220u 60u 15u "&Test Now ..." 
  Pop $Btn_Test 
  GetFunctionAddress $0 "on.Click.Test" 
  nsDialogs::OnClick $Btn_Test $0 
  SetCtlColors $Btn_Test 0xFFD99F 0x0262626
  nsDialogs::Show 
FunctionEnd 
Function "on.Click.Test"
  GetFunctionAddress $0 "ProgressBar"
  nsDialogs::CreateTimer $0 100
FunctionEnd 
Function ProgressBar
  SendMessage $ProgressBar 0x0408 0 0 $1
  IntOp $1 $1 + 1
  IntCmp $1 100 +1 Done +1
  ${If} $1 >= 100 
    GetFunctionAddress $0 "ProgressBar"
    nsDialogs::KillTimer $0
  ${EndIf}
  Done:
  SendMessage $ProgressBar 0x0402 $1 0
  SendMessage $Percent ${WM_SETTEXT} 0 STR:$1%
FunctionEnd
Section 
SectionEnd 
Function .onGUIEnd 
FunctionEnd 
JasonFriday13#
That's a cool example.

If you are going to post example scripts, at least make sure they compile.

Line 10, unnecessary compressor command.
Line 19, uninstaller code when there is no uninstaller.
Lines 32 and 33, icon doesn't exist on my machine.
Line 36, not using MUI specific pages causes a warning.
Line 47, PBM_SETRANGE32 already defined.
Lines 52 to 55, putting this above the function allows removal of the /global flag.
Line 71, /nounload has been deprecated since 2.42 (20-12-2008).
Lines 82 and 87, inconsistent use of /nounload, make up your mind which one to use.
T.Slappy#
Nice example 🙂

I can remember that feature from old installers too 🙂

Please fix at least !define /math PBM_SETRANGE32 ${WM_USER} + 6 (already defined) and put this example to wiki, which is proper place for this.