Go back a few pages when back button pressed - nsis

I've been trying to figure out how to do that for a few days but no luck. I'm trying to go back a few pages when back button pressed during the installation.
I want to do that in the creater procedure of the page.
Page custom printerPage1 verifyPrinterFunc1 ": 1. Printer Bilgileri"
Normally I'm able to skip pages during installation by RelGotoPage Function.
Function RelGotoPage
IntCmp $R9 0 0 Move Move
StrCmp $R9 "X" 0 Move
StrCpy $R9 "3"
Move:
SendMessage $HWNDPARENT "0x408" "$R9" ""
FunctionEnd
But I can't do that in the back button pressed event (E.x. ${NSD_OnBack})
I'm stuck and need help from the experienced minds. Thank you.

!include nsDialogs.nsh
Licensedata "${__FILE__}"
InstallDir $temp
Page directory
Page components
Page license
Page custom printerPage1 verifyPrinterFunc1 ": 1. Printer Bilgileri"
Function onBack
; Go back two pages to the components page
System::Call 'USER32::PostMessage(i$HWNDPARENT,i0x408,i-2,i0)'
Abort
FunctionEnd
Function printerPage1
nsDialogs::Create 1018
Pop $0
${NSD_OnBack} onBack
nsDialogs::Show
FunctionEnd
Function verifyPrinterFunc1
FunctionEnd

Related

Unable to hide back button in NSIS Uninstaller

I have an uninstaller created in NSIS.
It has 3 pages (1 custom page (Confirm), the macro MUI_UNPAGE_INSTFILES and another custom page (Finish)).
My problem is that I'm unable to hide the 'Back' button in the "INSTFILES" page.
I have tried various things to hide it, but it simply stays there in disabled state.
This is the code that I'm using to hide the Back button:
GetDlgItem $1 $HWNDPARENT 3
ShowWindow $1 ${SW_HIDE}
Above code works fine for Next and Cancel button when used with ID 1 and 2.
I have tried the above code in various places
un.OnInit
myGuiInit (custom)
Page LEAVE callback of confirm page
Page PRE callback of INSTFILES page
Page SHOW callback of INSTFILES page
Code:
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.InstShow
UninstPage custom un.UninstConfirm_Show
!define MUI_PAGE_CUSTOMFUNCTION_PRE un.InstShow
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.InstShow
!insertmacro MUI_UNPAGE_INSTFILES
UninstPage custom un.UninstFinish_Show
un.InstShow has the logic to hide the button.
Any help would be appreciated. I have spent close to 4-5 hours on this with no luck.
This is how the screen looks now (Note that I have hidden Next and Cancel buttons in the image, to illustrate that hiding those buttons are working fine for me) :
The internal page flag PF_BACK_SHOW in NSIS is set for all pages except the first page, you have to hack your way around it.
If the InstFiles page is the last page or if you don't want the back button on the pages after then you can move the button:
Section -un.Main
GetDlgItem $1 $hwndParent 3
System::Call USER32::MoveWindow(pr1,i-9,i-9,i1,i1,i1)
SectionEnd
If you only want to hide it on the InstFiles page but not on the pages after then you must use a timer and call ShowWindow in the timer callback.
GetDlgItem $1 $HWNDPARENT 3
ShowWindow $1 ${SW_HIDE}
This code is perfectly correct and working fine (tested).
I think there is some other code which shows the button again.
E.g. in scenario when you hide the button in LEAVE function of page X, the following page may show the button again. This happens often in regular UI.
The solution is to check all your custom pages and also the standard pages for any operations regarding this button.

write in header section of custom installer page (without MUI)

I used this guide to create custom page in my installer:
nsDialogs
and its working without a problem, this is the code:
!include nsDialogs.nsh
!include LogicLib.nsh
XPStyle on
Var Dialog
Page custom nsDialogsPage nsDialogsPageLeave
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
...
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
...
FunctionEnd
Section
SectionEnd
But the only thing missing is this part:
Could someone help me out and show how to add text there, but without this MUI, all the guides i tried to find are refering to the MUI way but i went with Pages instead so i would like to keep it that way, surely there is a way. Thank you in advance!
Your screenshot looks like MUI. Even when using MUI, custom pages still use Page Custom ....
The MUI has a helper macro to set the text on the top for your custom pages:
!include MUI2.nsh
...
Function nsDialogsPage
!insertmacro MUI_HEADER_TEXT "Blah" "Blah blah"
nsDialogs::...
...
FunctionEnd
This macro is documented in the MUI readme. It is not in the nsDialogs documentation because these labels are in the outer dialog, not in the inner page dialog.
In the unlikely event that you are not using MUI (but you are using the MUI dialog layout and ChangeUI) you can copy the MUI_HEADER_TEXT macro from the MUI(v1) source file or write your own custom macro based on the MUI source.

Change default buttons name NSIS

I am very new to NSIS,
I created a simple installer with 2 screens,
!include LogicLib.nsh
!include nsDialogs.nsh
Page custom someName someEndmethod
Page instfiles
First one is a custom page (nsDialogs) and on it the default button is "install" and i have 2 questtions :
How do i bound a method to its click event ?
How do i change the text on that button ?
BTW - I am not using MUI .
The best reference i could found regarding the nsDialogs was the following:
http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html
but could not seem to find answer to those simple questions.
Thanks
!include WinMessages.nsh
Function MyPageCreate
GetDlgItem $0 $hwndparent 1 ; Get the handle to the button
SendMessage $0 ${WM_SETTEXT} 0 `STR:$(^NextBtn)` ; The part after STR: can be any string, using the next button language string here
nsDialogs::Create 1018
pop $0
nsDialogs::Show
FunctionEnd
Function MyPageLeave
MessageBox mb_yesno "User clicked Next/Install, allow the page change?" IDYES allow
Abort
allow:
FunctionEnd
Page Components
Page Custom MyPageCreate MyPageLeave
Page InstFiles
If you just want to change the string on the install button no matter which page it is on (The page before the instfiles page) you can change it with LangString instead.

NSIS Multiple components option

I am a newbie in NSIS. I need some help regarding the MUI Components page. I am adding 3 section Group and different sections inside the Section Groups. I need to do different actions based on the user selection. Users have the options to select multiple options.
So can anyone please help me with a sample code which is having more than 3 sections and verifying the user selection of those options and based on that displaying different message boxes
It is very unclear to me what your real goal is but checking section states can be done like this:
!include LogicLib.nsh
page components
page instfiles
SectionGroup /e "Group 1"
Section "G1S1" SEC_G1S1
SectionEnd
Section /o "G1S2" SEC_G1S2
SectionEnd
SectionGroupEnd
SectionGroup /e "Group 2"
Section /o "G2S1" SEC_G2S1
SectionEnd
Section "G2S2" SEC_G2S2
SectionEnd
SectionGroupEnd
Section -Hidden
${If} ${SectionIsSelected} ${SEC_G1S1}
MessageBox mb_ok "G1S1 is selected"
${EndIf}
${If} ${SectionIsSelected} ${SEC_G1S2}
MessageBox mb_ok "G1S2 is selected"
${EndIf}
# Check the other sections here ...
SectionEnd

Calling PRE functions of MUI in NSIS installer, skipping pages/dialogs in NSIS installer

Can PRE function of a MUI dialog be called only when required?
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipComponentsPage
!insertmacro MUI_PAGE_COMPONENTS
Function SkipComponentsPage
Abort
MessageBox MB_OK "You chose to UPDATE your current version"
FunctionEnd
//This section will be checked by default, that is , user will not be able to select or unselect this section , this has to be executed..........how to do this?To hide it , i have included a - sign in its name. its name is "mandatory"
Section "-mandatory" SEC_UPDATE
#Do update............
SectionEnd
I have two RadioButtons (Demo & Update) on my custom dialog page in the NSIS installer.
I want that when the user choses to install the UPDATE (choses the UPDATE RadioButton), then the Components Page is skipped , and a specified Section is auto CHECKED and executed.
But if the user choses to install the DEM (choses the DEMO RadioButton) , then the Components page is not skipped & the user can Check or Uncheck Sections on that Component page.
A page callback is always called, but you can put logic inside the function:
...
section "" SEC_UPDATE
sectionend
Function SkipComponentsPage
!insertmacro UnSelectSection ${SEC_UPDATE} ; Don't include update with demo by default?
${If} $InstallType == UPDATE
!insertmacro SelectSection ${SEC_UPDATE}
Abort
${EndIf}
Functionend
It is not really clear to me if you want the user to be able to choose update in the demo mode, but if you want to force the update you can make the section read only:
section "Update" SEC_UPDATE
SectionIn RO
sectionend
(And remove the UnSelectSection call from the pre function)
...or just make the section invisible with the -name prefix like you suggested.

Resources