Old 6th October 2016, 06:54   #1
infd
Junior Member
 
Join Date: Oct 2016
Posts: 5
How to make work progress bar on custom page?

I uses MUI2. Before any installation i have 2 custom pages, first with options and second with progress. I not able to make work correctly progress page. I tried many ways and in all of this ways my custom page freezes when operations in progress.
Now code looks like this:
code:

...
Page custom PROGRESS PROGRESS_LEAVE
...
Function PROGRESS
...
nsDialogs::Create 1018
#hide buttons
GetDlgItem $0 $HWNDPARENT 1
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 2
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 3
ShowWindow $0 ${SW_HIDE}
...
${NSD_CreateProgressBar} 0u 20u 100% 10u ""
...
${NSD_CreateTimer} OnTimer 1000
nsDialogs::Show
Function OnTimer
Var /Global clicked
StrCmp $clicked "true" progbar
StrCpy $clicked "true"
GetDlgItem $0 $HWNDPARENT 1
SendMessage $0 ${BM_CLICK} 0 0
progbar:
#animation related code here
...
FunctionEnd
Function PROGRESS_LEAVE #a huge timed operations there
...
FunctionEnd


Page not displays any buttons and clicks for "next" automatically by timer for post function PROGRESS_LEAVE execution. Where i must put my code for file operations for page not freezes and actually show progress? I not able to use sections there since it is pre-installation tasks.
infd is offline   Reply With Quote
Old 6th October 2016, 07:41   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 870
Quote:
Originally Posted by infd View Post
I not able to use sections there since it is pre-installation tasks.
Sure you can. You get all the options required in custom pages, then you create a hidden section that runs all the pre-install tasks.

Example:
code:
Name "test"
OutFile "test.exe"
RequestExecutionLevel user
ShowInstDetails show
; custom pages somewhere here
Page components
Page instfiles
Section -preinstall_tasks
DetailPrint "Preinstall Tasks"
SectionEnd
Section install
DetailPrint "Install"
SectionEnd


"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 6th October 2016, 08:32   #3
infd
Junior Member
 
Join Date: Oct 2016
Posts: 5
Quote:
Sure you can.
Firstly, code was not intended to have pre install tasks and have a huge size. One of preinstall option will exit installer after showing progress. After preinstall pages i have many pages and sections all of this must be modified for check preinstall options and skip them if i want use sections for preinstall tasks, but in possible. If i show custom progress or not show anything then remaining code works without any modification. Currently i forced to not show anything about 1 min since my progress page not works (
infd is offline   Reply With Quote
Old 6th October 2016, 17:48   #4
Kuppy
Junior Member
 
Join Date: Sep 2016
Posts: 34
code:

Page custom PROGRESS PROGRESS_LEAVE

Function PROGRESS

nsDialogs::Create 1018

GetDlgItem $0 $HWNDPARENT 1

ShowWindow $0 ${SW_HIDE}

GetDlgItem $0 $HWNDPARENT 2

ShowWindow $0 ${SW_HIDE}

GetDlgItem $0 $HWNDPARENT 3

ShowWindow $0 ${SW_HIDE}

${NSD_CreateProgressBar} 0u 20u 100% 10u ""
Pop $ProgressBar

${NSD_CreateLabel} 0u 10u 40% 10u "0%"
Pop $Percent

GetFunctionAddress $0 "OnTimer"
nsDialogs::CreateTimer $0 100

nsDialogs::Show

FunctionEnd

Function OnTimer

Var /Global clicked

StrCmp $clicked "true" progbar

StrCpy $clicked "true"

GetDlgItem $0 $HWNDPARENT 1

SendMessage $0 ${BM_CLICK} 0 0

progbar:

loop:
IntCmp $R1 $R0 done 0 done
IntOp $R1 $R1 + 1
SendMessage $ProgressBar ${PBM_SETPOS} "$R1" 0
${NSD_SetText} $Percent "$R1%"
.
Sleep 100
StrCmp $R1 "100" 0 loop
done:
GetFunctionAddress $0 "OnTimer"
nsDialogs::KillTimer $0

Call NextPage
FunctionEnd

Function PROGRESS_LEAVE #a huge timed operations there

FunctionEnd

Kuppy is offline   Reply With Quote
Old 7th October 2016, 06:25   #5
infd
Junior Member
 
Join Date: Oct 2016
Posts: 5
(deleted, need to test)
infd is offline   Reply With Quote
Old 7th October 2016, 09:17   #6
infd
Junior Member
 
Join Date: Oct 2016
Posts: 5
Kuppy, seems like you only write code for bar animation? I make animation code by myself but problem is other - if long processed code resides in function PROGRESS_LEAVE then installer window is hangs and not redrawing while this code is executing.
Today i try to put this long procesing code in timer function and window still freezing.
I also try to put code in background thread inside timer function with BgWorker plug-in but it changes nothing.

My question is simple. nsDialogs plugin designed for creation of custom pages. This plugin is able to create progress bars. How to correctly show custom page with progress bar? My background tasks makes main window freezing ( Main window redraws only when 100% of long timed code is processed (

Maybe it "File" instruction issue?

Last edited by infd; 7th October 2016 at 10:17.
infd is offline   Reply With Quote
Old 7th October 2016, 12:30   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,946
Operations that take a long time should only be performed on the InstFiles page.

The BgWorker plug-in can be used to work around the problem on a custom page but it is not pretty: Create a timer. When the timer fires, kill the timer and start the background thread. The background thread has to update the progressbar in addition to doing its actual work.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 7th October 2016, 13:45   #8
infd
Junior Member
 
Join Date: Oct 2016
Posts: 5
Anders, thanks a lot. I will try your method as last resort. Long processing code is pretty simple - mostly "File" for copying and "StrCpy" instructions for change single variable with processing status.
infd is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump