View Single Post
Old 27th March 2015, 21:50   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
Showing 60 pages in a installer is insane!

There are several ways to show the same page several times, they all suck:

Quote:
!include LogicLib.nsh
var test_max
var test_num
!macro InitPageLoopTest
StrCpy $test_num 0
!macroend
!macro _ShowAnotherTestPage _a _b _t _f
IntOp $test_num $test_num + 1
IntCmp $test_num $test_max `${_f}` `${_t}` `${_f}`
!macroend
!define ShowAnotherTestPage `"" ShowAnotherTestPage ""`

!include nsDialogs.nsh
Page Components
Page Custom myCreate_Method1 myLeave_Method1
Page Custom myCreate_Method2 myLeave_Method2
Page Custom myCreate_Method3 myLeave_Method3
Page InstFiles



Function LoadProfileData
System::Call 'ADVAPI32::SystemFunction036(*i.r0,i4)' ; Generate some data for this page
${NSD_SetText} $1 $0
System::Call 'KERNEL32::GetTickCount()i.r0'
${NSD_SetText} $2 $0
FunctionEnd


Function myCreate_Method1
StrCpy $test_max 3
${If} $test_num > 0
GetDlgItem $0 $hwndparent 3
EnableWindow $0 0 ; Disable back button
${EndIf}
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 -12u 100% 12u "Method1"
Pop $0
${NSD_CreateText} 3u 13u 50% 13u ""
Pop $1
${NSD_CreateText} 3u 30u 50% 13u ""
Pop $2
Call LoadProfileData
nsDialogs::Show
FunctionEnd

Function myLeave_Method1
${If} ${ShowAnotherTestPage}
SendMessage $HWNDPARENT 0x408 0 "" # Go to NSIS page
${EndIf}
FunctionEnd


Function myCreate_Method2
GetDlgItem $0 $hwndparent 1
${NSD_SetText} $0 "$(^NextBtn)"
!insertmacro InitPageLoopTest
again:
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 -12u 100% 12u "Method2"
Pop $0
${NSD_CreateText} 3u 13u 50% 13u ""
Pop $1
${NSD_CreateText} 3u 30u 50% 13u ""
Pop $2
Call LoadProfileData
StrCpy $0 0
nsDialogs::Show
${If} $0 <> 0 ; Cancel or Next?
${AndIf} ${ShowAnotherTestPage}
GetDlgItem $0 $hwndparent 3
EnableWindow $0 0 ; Disable back button
Goto again
${EndIf}
FunctionEnd

Function myLeave_Method2
StrCpy $0 1
FunctionEnd


Function myCreate_Method3
GetDlgItem $0 $hwndparent 1
${NSD_SetText} $0 "$(^NextBtn)"
!insertmacro InitPageLoopTest
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 -12u 100% 12u "Method3"
Pop $0
${NSD_CreateText} 3u 13u 50% 13u ""
Pop $1
${NSD_CreateText} 3u 30u 50% 13u ""
Pop $2
Call LoadProfileData
nsDialogs::Show
FunctionEnd

Function myLeave_Method3
${If} ${ShowAnotherTestPage}
# Fake another page by staying on this page but with new values
Call LoadProfileData
GetDlgItem $0 $hwndparent 3
EnableWindow $0 0 ; Disable back button
Abort
${EndIf}
FunctionEnd
I would recommend that you just have 2 custom pages. Page 1 would contain a list of profiles and page 2 would edit the selected profile. You would then skip the 2nd page if no profile is selected or jump back to page 1 after editing a profile...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote