Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 4th February 2009, 12:38   #1
Crazytje
Junior Member
 
Join Date: Oct 2008
Posts: 3
Check if user selected "Reboot now" when using SetRebootFlag

While installing my application I use the SetRebootFlag. On the finish page, I want to know what the user selected after pressing finish.

The reason I need to know is because if "Reboot Manually Later" is selected I want to start the application.

I've searched around and can't seem to get it working.
One thing I read about is using the page callback function, but how do I do this? And how do I know what the user selected?

Any help is welcome!, I really need all the help I can get for this.
Crazytje is offline   Reply With Quote
Old 4th February 2009, 14:11   #2
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
add a 'MUI_PAGE_CUSTOMFUNCTION_LEAVE function' before your MUI Finish page, then based on whether you use MUI or MUI2, do something like the following in that callback function:

MUI:
Read $PLUGINSDIR\ioSpecial.ini [Field 4] State
Read $PLUGINSDIR\ioSpecial.ini [Field 5] State

If Field 4's State = 1, then the user chose 'reboot now'.
If Field 5's State = 1, then the user chose 'I want to manually reboot later'.

MUI2:
code:

FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $R0 0x4b3
${NSD_GetState} $0 $1
GetDlgItem $0 $R0 0x4b4
${NSD_GetState} $0 $2
MessageBox MB_OK "Reboot now: [$1]$\r$\nReboot later: [$2]"
Abort


And perform the desired action (Reboot / Launch your app) based on the states of $1 and $2.
Animaether is offline   Reply With Quote
Old 5th February 2009, 13:36   #3
Crazytje
Junior Member
 
Join Date: Oct 2008
Posts: 3
Thank you!

I got it working.

Thx for helping me
Crazytje is offline   Reply With Quote
Old 5th February 2009, 19:21   #4
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
No prob

I wonder if MUI2 could store these pre-set dialogs' settings in pre-defined variables. Would waste a bit of memory if unused, but I think there's been a steady trend of making NSIS a bit easier to use at the cost of superlean installers (e.g. recommendations to use LogicLib, despite the overhead that generates) - so maybe they'll add that. I'm glad the above works, regardless
Animaether is offline   Reply With Quote
Old 11th February 2009, 09:45   #5
mx450
Junior Member
 
Join Date: Feb 2009
Posts: 3
@Animaether
Thanks for your info.

One question, is there any way to get status of the MUI_FINISHPAGE_SHOWREADME checkbox?

I used to use
!insertmacro INSTALLOPTIONS_READ $MUI_TEMP1 "ioSpecial.ini" "Field 5" "State"
to get the state of it. Now I use MUI2 and nsDialog. it doesn't work any more as there is no ioSpecial.ini in MUI2.

Thanks.
mx450 is offline   Reply With Quote
Old 11th February 2009, 09:58   #6
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Use WinSpy / WinSpy++ / process explorer / whathaveyou to get the control ID of that checkbox, then use GetDlgItem to get the hwnd for that control, after which you should be able to use '${NSD_GetState} <hwnd> <out var>' to get its checked state.
The control ID should never vary (until somebody mucks with the resources of MUI2), the hwnd does, so you have to look that up via the aforementioned.
Animaether is offline   Reply With Quote
Old 11th February 2009, 11:15   #7
mx450
Junior Member
 
Join Date: Feb 2009
Posts: 3
Quote:
Originally posted by Animaether
Use WinSpy / WinSpy++ / process explorer / whathaveyou to get the control ID of that checkbox, then use GetDlgItem to get the hwnd for that control, after which you should be able to use '${NSD_GetState} <hwnd> <out var>' to get its checked state.
The control ID should never vary (until somebody mucks with the resources of MUI2), the hwnd does, so you have to look that up via the aforementioned.
I did use winspy++ to check the control id, it is 0x4b4.

This is what i tried to do:
code:

FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $R0 0x4b4
${NSD_GetState} $0 $1
MessageBox MB_OK "State of SHOW_READ_ME checkbox: $1"


But, it always shows 0.
Do i do anything wrong?
mx450 is offline   Reply With Quote
Old 11th February 2009, 12:05   #8
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
not sure how you got the 0x4b4 - I think it should be 0x4b3 (as stated in WinSpy++ , don't add 1)

code:

!include "MUI2.NSH"
outfile 'finishpage_readme_checkbox_test.exe'

Section
SectionEnd

!define MUI_FINISHPAGE_SHOWREADME "http://www****n.com/"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "HELLO"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION myFunc
!insertmacro MUI_LANGUAGE "English"
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveFunc
!insertmacro MUI_PAGE_FINISH

Function myFunc
MessageBox MB_OK "Test"
FunctionEnd

Function LeaveFunc
MessageBox MB_OK "Leave"
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $R0 0x4b3
${NSD_GetState} $0 $1
MessageBox MB_OK "State of SHOW_READ_ME checkbox: $1"
Abort
FunctionEnd

Animaether is offline   Reply With Quote
Old 11th February 2009, 12:32   #9
mx450
Junior Member
 
Join Date: Feb 2009
Posts: 3
Quote:
Originally posted by Animaether
not sure how you got the 0x4b4 - I think it should be 0x4b3 (as stated in WinSpy++ , don't add 1)

code:

!include "MUI2.NSH"
outfile 'finishpage_readme_checkbox_test.exe'

Section
SectionEnd

!define MUI_FINISHPAGE_SHOWREADME "http://www****n.com/"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "HELLO"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION myFunc
!insertmacro MUI_LANGUAGE "English"
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveFunc
!insertmacro MUI_PAGE_FINISH

Function myFunc
MessageBox MB_OK "Test"
FunctionEnd

Function LeaveFunc
MessageBox MB_OK "Leave"
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $R0 0x4b3
${NSD_GetState} $0 $1
MessageBox MB_OK "State of SHOW_READ_ME checkbox: $1"
Abort
FunctionEnd

it is 0x4b4 for me and i know why mine doesn't work. i didnt use leavefunc, i place it in somewhere else. Probably it calls after this control has been removed.

Thanks for your kindly help.
mx450 is offline   Reply With Quote
Old 11th February 2009, 12:45   #10
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
huh.. that's odd. I wonder why it would be 0x4b4 for you as, again, that number shouldn't change.. anyway, glad the sample code helped resolve it regardless
Animaether is offline   Reply With Quote
Old 5th November 2010, 09:40   #11
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,362
i tried to build upon this, as i'm trying to enable/disable MUI_FINISHPAGE_SHOWREADME at runtime.
code:
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $R0 0x4b4
${If} $WebsiteURL == ""
EnableWindow $0 0
${Else}
EnableWindow $0 1
${EndIf}


didn't work, any ideas?
Yathosho is offline   Reply With Quote
Old 5th November 2010, 12:16   #12
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Probably the wrong ID again.. seems this varies a bit between versions. Of course using the ID directly is unnecessary with most of MUI as it actually stores the hwnds in variables internally. You can peek at the files in "\Contrib\Modern UI 2\" to find those variables.

In this case, $mui.FinishPage.ShowReadme should be it.

PHP Code:
!include "MUI2.nsh"

OutFile "$%temp%\temp.exe"

Section
SectionEnd

!define MUI_FINISHPAGE_SHOWREADME "c:\test.txt"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW finish.show
!insertmacro MUI_PAGE_FINISH

Function finish.show
    EnableWindow $mui
.FinishPage.ShowReadme 0
FunctionEnd

!insertmacro MUI_LANGUAGE English 
You might want to add code that unchecks the checkbox as well as the above 'as is' can lead to the situation of the control being disabled but checked... which is atypical behavior (but may be desired).
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