Old 2nd April 2017, 18:19   #1
v47
Junior Member
 
Join Date: Jul 2012
Posts: 20
Paypal Donate button on the welcome/finish screen?

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.
v47 is offline   Reply With Quote
Old 2nd April 2017, 21:45   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,507
MUI1 or MUI2?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 3rd April 2017, 07:23   #3
v47
Junior Member
 
Join Date: Jul 2012
Posts: 20
1, I believe.
v47 is offline   Reply With Quote
Old 3rd April 2017, 16:59   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,507
Doing it with MUI2 is a lot less work so I did that:

PHP Code:
!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 TODOSet 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-${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 
$${STM_SETIMAGE} ${IMAGE_BITMAP$g_hPaypalImage
${Else}
    
File "/oname=$PluginsDir\PayPal.bmp" "${PAYPAL_SRC}"
    
${NSD_SetStretchedImage} $"$PluginsDir\PayPal.bmp" $g_hPaypalImage
${EndIf}
FunctionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 3rd April 2017, 17:37   #5
v47
Junior Member
 
Join Date: Jul 2012
Posts: 20
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.
v47 is offline   Reply With Quote
Old 3rd April 2017, 18:33   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,507
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:

PHP Code:
!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 $"ioSpecial.ini" "Settings" "NumFields"
IntOp $$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 $"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 $"${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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 3rd April 2017, 19:09   #7
v47
Junior Member
 
Join Date: Jul 2012
Posts: 20
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.
code:
!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


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.
Attached Thumbnails
Click image for larger version

Name:	insttest.jpg
Views:	32
Size:	31.8 KB
ID:	53151  
v47 is offline   Reply With Quote
Old 3rd April 2017, 19:26   #8
v47
Junior Member
 
Join Date: Jul 2012
Posts: 20
Ok, removed the bmp stuff for now - again, almost there. Almost.
code:
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


As long as the box can be made to wrap around the right or left lower corner properly, I'll be happy with this.
Attached Thumbnails
Click image for larger version

Name:	insttest2.jpg
Views:	17
Size:	32.1 KB
ID:	53152  
v47 is offline   Reply With Quote
Old 3rd April 2017, 19:36   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,507
You can see that the link is under the other control, you need to use SetWindowPos like I did.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 3rd April 2017, 19:48   #10
v47
Junior Member
 
Join Date: Jul 2012
Posts: 20
Ok, ended up with this;
code:
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


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.

//this also works (moves the link box low enough and makes it always visible without IniPageHacks):
code:
!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

Attached Thumbnails
Click image for larger version

Name:	insttest3.jpg
Views:	27
Size:	33.3 KB
ID:	53153  

Last edited by v47; 3rd April 2017 at 20:50.
v47 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