Old 22nd July 2008, 23:02   #1
hazmatt
Junior Member
 
Join Date: Jul 2008
Posts: 9
Cancelling during MUI_PAGE_INSTFILES

The cancel buttons on the installer is grayed out when it it is installing files. Is it possible enable that? is there an option I don't know about for that?
Its one of our test center requirements that a user be able to cancel during install.
hazmatt is offline   Reply With Quote
Old 22nd July 2008, 23:47   #2
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
You can force the button to be enabled like this:

code:
Section ""
GetDlgItem $0 $HWNDPARENT 2
EnableWindow $0 1
SectionEnd



But I doubt it will work properly...

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 23rd July 2008, 00:00   #3
hazmatt
Junior Member
 
Join Date: Jul 2008
Posts: 9
Yeah, would be nice to get hitting that as a callback.
hazmatt is offline   Reply With Quote
Old 23rd July 2008, 01:00   #4
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
wouldn't that end up calling .onUserAbort (haven't tested), or its MUI equivalent?

If so, you could set a variable before InstFiles, then unset it after. Then in the user abort handler, check for that variable and if it is set, run special 'abort' code specific to aborting while installing files?
Animaether is offline   Reply With Quote
Old 23rd July 2008, 01:26   #5
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
The problem is, that even if .onUserAbort is invoked, calling "Abort" in that function has a special meaning and would actually prevent the installer from aborting...

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 23rd July 2008, 01:49   #6
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
sure.. but perhaps you can check for a variable set in userAbort ( still not sure if it's invoked ) in your sections before each File command and, if it's set, abort the section.. and any subsequent sections.
Animaether is offline   Reply With Quote
Old 23rd July 2008, 02:02   #7
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Looks like that should, at least in theory, work. Example code:

PHP Code:
outFile "test2008Jul22.exe"

var installingFiles
var abortAbortAbort

Section
    GetDlgItem 
$0 $HWNDPARENT 2
    EnableWindow 
$0 1

    StrCpy $installingFiles 1

    messagebox MB_OK 
"Always trigger"
    
    
StrCpy $0 0
    _again
:
    
IntOp $$1
    IntCmp 
$0 10 +3
        sleep 250
        
goto _again

    StrCmp $abortAbortAbort 1 _aborted
        messagebox MB_OK 
"Only trigger if not aborted"
        
goto _skip
    _aborted
:
        
messagebox MB_OK "Only trigger if aborted"
    
_skip:
    
StrCpy $installingFiles 0
SectionEnd

Function .onUserAbort
    MessageBox MB_OK 
"onUserAbort called"
    
StrCmp $installingFiles 1 0 _skip
    MessageBox MB_OK 
"onUserAbort called during instFiles"
    
StrCpy $abortAbortAbort 1
    Abort
    _skip
:
FunctionEnd 
Edit: hmm not sure if it's a limit of messageboxes, but if you don't click through the .onUserAbort messageboxes quickly enough, the Section code will continue to run in the background, the timer will hit 10, and the script will continue to think it was not aborted. Easily fixed by moving the messageboxes around.. or not using them all, they're only there for debuggery/demonstration purposes.. but it does mean that the aborting may not be *instant* if the Section's File commands continue in the background as well. Extracting files should be a fair bit slower than setting that variable, though - but I've not tested. 3am here, not going to test it fully right now either
Animaether is offline   Reply With Quote
Old 20th May 2009, 13:06   #8
Tintera
Junior Member
 
Join Date: Mar 2008
Location: Czech Republic
Posts: 10
Tryed it

Just tried to add such section on MUI2 based installer.
The cancel button is still dissabled.
Would be nice to enable the cancel button when installing, but it's not must have for my installer.
Tintera is offline   Reply With Quote
Old 6th April 2010, 01:18   #9
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Old thread - just ran into it again (my topic watch stopped working somewhere along the timeline of life) and, after reading a more recent question asking the same thing, decided to give it another stab.

Results are in:
http://nsis.sourceforge.net/InstFile...ring_InstFiles
( InstFiles Cancel - Allowing a user to cancel installation during InstFiles )
Animaether is offline   Reply With Quote
Old 6th April 2010, 11:18   #10
Tintera
Junior Member
 
Join Date: Mar 2008
Location: Czech Republic
Posts: 10
Thank you for the article. Seems complex but will use it if I do some next NSIS based installer.
Tintera is offline   Reply With Quote
Old 6th April 2010, 11:32   #11
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
yep.. one wasn't meant to do this sort of thing with NSIS - the Cancel button was disabled on purpose, after all
Animaether 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