Hello, looking for the easiest, simplest way to add a paypal donate button to the welcome and/or finish screen. No need for any fancy stuff like animations or auto-open webpage, just a simple clickable button (even a clickable link would be fine).
Thanks.
Paypal Donate button on the welcome/finish screen?
10 posts
MUI1 or MUI2?
1, I believe.
Doing it with MUI2 is a lot less work so I did that:
!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ModifyPage
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!define PAYPAL_SRC "${NSISDIR}\Contrib\Graphics\Header\Orange.bmp" ; Using whatever I have available
!define PAYPAL_W 88 ; TODO: Set these to the correct size of your image
!define PAYPAL_H 25
Var g_hPaypalImage
Function OnPaypalClick
Pop $0
ExecShell "" "https://paypal.com/whatever"
FunctionEnd
Function .onGUIEnd
${NSD_FreeImage} $g_hPaypalImage
FunctionEnd
Function ModifyPage
!if ${MUI_SYSVERSION} < "2.0"
!error "MUI2 required"
!endif
${NSD_CreateBitmap} 0 -${PAYPAL_H} ${PAYPAL_W} ${PAYPAL_H} "" ; Change "0" to "-${PAYPAL_W}" to place it on the right side
Pop $0
System::Call 'USER32::SetWindowPos(i$0,i0,i,i,i,i,i0x13)' ; Make sure it is on top of other controls
${NSD_OnClick} $0 OnPaypalClick
${If} $g_hPaypalImage <> 0
SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $g_hPaypalImage
${Else}
File "/oname=$PluginsDir\PayPal.bmp" "${PAYPAL_SRC}"
${NSD_SetStretchedImage} $0 "$PluginsDir\PayPal.bmp" $g_hPaypalImage
${EndIf}
FunctionEnd Ok, I'll see whether I can (painlessly) migrate to MUI2 - thanks.
But if someone else has something that would work in MUI1, I'm still all ears - as mentioned, I think a simple clickable link would be enough for what I need.
But if someone else has something that would work in MUI1, I'm still all ears - as mentioned, I think a simple clickable link would be enough for what I need.
Unless you are already modifying the pages you should just be able to change !include MUI.nsh to MUI2.nsh
Something like this for MUI1:
Something like this for MUI1:
!include MUI.nsh
!define MUI_PAGE_CUSTOMFUNCTION_PRE ModifyIniPage
!define MUI_PAGE_CUSTOMFUNCTION_SHOW IniPageHacks
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Var FieldId
Function ModifyIniPage
!if ${MUI_SYSVERSION} >= "2.0"
!error MUI1
!endif
Push $0
!insertmacro INSTALLOPTIONS_READ $0 "ioSpecial.ini" "Settings" "NumFields"
IntOp $0 $0 + 1
StrCpy $FieldId $0
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Type" "Link"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Text" "PayPal"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "State" "https://paypal.com/whatever"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Left" -30u
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Top" -12u
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Right" -1
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Bottom" -1
/*!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Type" "Bitmap"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Text" "$PluginsDir\PayPal.bmp"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Flags" "NOTIFY"
File "/oname=$PluginsDir\PayPal.bmp" "${PAYPAL_SRC}"*/
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "NumFields" $0
Pop $0
FunctionEnd
Function IniPageHacks
Push $0
!insertmacro INSTALLOPTIONS_READ $0 "ioSpecial.ini" "Field $FieldId" "HWND"
System::Call 'USER32::SetWindowPos(i$0,i0,i,i,i,i,i0x13)'
!insertmacro MUI_DEFAULT MUI_FINISHPAGE_LINK_COLOR "000080"
SetCtlColors $0 "${MUI_FINISHPAGE_LINK_COLOR}" "${MUI_BGCOLOR}"
Pop $0
FunctionEnd It might be possible to get a clickable bitmap but it will probably require some more hacking to get a control with the NOTIFY flag on top of the bitmap.Ok, I think that works, but I need to supply it with a correct bmp (right now it's just a black square).
Also, found this in the meantime, and it actually almost does what I want.
Also, found this in the meantime, and it actually almost does what I want.
All that I need now is to move it way down so it wouldn't obstruct the text (see pic) - tried playing around with the top/bottom values, but as soon as I change anything the link is gone.!define MUI_PAGE_CUSTOMFUNCTION_PRE WelcomePageSetupLinkPre
Function WelcomePageSetupLinkPre
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "Numfields" "4" ; increase counter
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 3" "Bottom" "122" ; limit size of the upper label
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Type" "Link"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Text" "Paypal Donate"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "State" "http://www.google.com/"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Left" "120"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Right" "315"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Top" "123"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Bottom" "132"
FunctionEnd
Ok, removed the bmp stuff for now - again, almost there. Almost.
As long as the box can be made to wrap around the right or left lower corner properly, I'll be happy with this.Var FieldId
Function ModifyIniPage
!if ${MUI_SYSVERSION} >= "2.0"
!error MUI1
!endif
Push $0
!insertmacro INSTALLOPTIONS_READ $0 "ioSpecial.ini" "Settings" "NumFields"
IntOp $0 $0 + 1
StrCpy $FieldId $0
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Type" "Link"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Text" "PayPal Donate"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "State" "https://paypal.com/"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Left" -30u
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Top" -12u
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Right" -1
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Bottom" -1
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "NumFields" $0
Pop $0
FunctionEnd
You can see that the link is under the other control, you need to use SetWindowPos like I did.
Ok, ended up with this;
//this also works (moves the link box low enough and makes it always visible without IniPageHacks):
I think it's good enough - thanks again. I'll probably try to be less stupid later, but my time is short for the moment.Var FieldId
Function ModifyIniPage
!if ${MUI_SYSVERSION} >= "2.0"
!error MUI1
!endif
Push $0
!insertmacro INSTALLOPTIONS_READ $0 "ioSpecial.ini" "Settings" "NumFields"
IntOp $0 $0 + 1
StrCpy $FieldId $0
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Type" "Link"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Text" "PayPal Donate"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "State" "https://paypal.com/"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Left" "120"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Top" -12u
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Right" "315"
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field $0" "Bottom" -1
!insertmacro INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "NumFields" $0
Pop $0
FunctionEnd
Function IniPageHacks
Push $0
!insertmacro INSTALLOPTIONS_READ $0 "ioSpecial.ini" "Field $FieldId" "HWND"
System::Call 'USER32::SetWindowPos(i$0,i0,i,i,i,i,i0x13)'
Pop $0
FunctionEnd
//this also works (moves the link box low enough and makes it always visible without IniPageHacks):
!define MUI_PAGE_CUSTOMFUNCTION_PRE WelcomePageSetupLinkPre
Function WelcomePageSetupLinkPre
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "Numfields" "4" ; increase counter
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 3" "Bottom" "180" ; limit size of the upper label go up
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Type" "Link"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Text" "Paypal Donate"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "State" "http://www.google.com/"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Left" "120"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Right" "315"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Top" "180" ; go up
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Bottom" "190" ; go up
FunctionEnd