Paypal Donate button on the welcome/finish screen?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • v47
    Junior Member
    • Jul 2012
    • 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.
  • Anders
    Moderator
    • Jun 2002
    • 5644

    #2
    MUI1 or MUI2?
    IntOp $PostCount $PostCount + 1

    Comment

    • v47
      Junior Member
      • Jul 2012
      • 20

      #3
      1, I believe.

      Comment

      • Anders
        Moderator
        • Jun 2002
        • 5644

        #4
        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

        Comment

        • v47
          Junior Member
          • Jul 2012
          • 20

          #5
          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.

          Comment

          • Anders
            Moderator
            • Jun 2002
            • 5644

            #6
            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

            Comment

            • v47
              Junior Member
              • Jul 2012
              • 20

              #7
              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 Files

              Comment

              • v47
                Junior Member
                • Jul 2012
                • 20

                #8
                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 Files

                Comment

                • Anders
                  Moderator
                  • Jun 2002
                  • 5644

                  #9
                  You can see that the link is under the other control, you need to use SetWindowPos like I did.
                  IntOp $PostCount $PostCount + 1

                  Comment

                  • v47
                    Junior Member
                    • Jul 2012
                    • 20

                    #10
                    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 Files
                    Last edited by v47; 3 April 2017, 20:50.

                    Comment

                    Working...
                    X