0

I'm trying to put various images (as icons) in a single custom page using nsDialogs.

This example i provided do that, but it only shows the first image. But if i comment/delete the code for the first image, shows the second one, if i do the same with the second one, it shows the third, and so on.

Screenshot: Custom page with the code provided: Only one icon is shown when are set four with the same code.

For me i am missing something but i have searched for a example of using NSD_CreateIcon/NSD_SetIcon to help with this with any luck. Also i tried to use NSD_CreateBitmap/NSD_SetBitmap instead, but i have the same issue (and i want the icons better because they have transparency).

Here is the code:

Name "Example NSD Icon Test"
Outfile "ExampleNSDiconsTest.exe"

RequestExecutionLevel user
Unicode True
XPStyle on

!include nsDialogs.nsh
!include LogicLib.nsh

Page Custom FirstCreate
Page Custom SecondCreate
Page instfiles

Function .onGuiInit
    InitPluginsDir
    File /oname=$PLUGINSDIR\1.ico "1.ico"
    File /oname=$PLUGINSDIR\2.ico "2.ico"
    File /oname=$PLUGINSDIR\3.ico "3.ico"
    File /oname=$PLUGINSDIR\4.ico "4.ico"
FunctionEnd

Function FirstCreate

    nsDialogs::Create 1018
    
    ${NSD_CreateIcon} 8u 12u 32px 32px
        Pop $1
        ${NSD_SetIcon} $1 "$PLUGINSDIR\1.ico" $R1
    
    ${NSD_CreateIcon} 8u 47u 32px 32px
        Pop $2
        ${NSD_SetIcon} $2 "$PLUGINSDIR\2.ico" $R2
    
    ${NSD_CreateIcon} 8u 60u 32px 32px
        Pop $3
        ${NSD_SetIcon} $3 "$PLUGINSDIR\3.ico" $R3
        
    ${NSD_CreateIcon} 8u 84u 32px 32px
        Pop $4
        ${NSD_SetIcon} $4 "$PLUGINSDIR\4.ico" $R4
    
    nsDialogs::Show
    
FunctionEnd

Function SecondCreate
    nsDialogs::Create 1018
    nsDialogs::Show
FunctionEnd

Section
    
SectionEnd

The full package with the icons and the example can be downloaded here (updated)

Thanks!

Edit:

Doing more testing, i just found that if i create a second custom page using nsDialogs after that first one, totally empty, the first page show only "1", you can go to the second page, go back to the first one, and it shows "1" and "2". I updated everything in this page with the new example.

1 Answers1

1
  1. You are missing a Pop after nsDialogs::Create.
  2. There is no px suffix.
  3. You are missing the last parameter when creating the controls.

RequestExecutionLevel User


!include nsDialogs.nsh

Page Custom FirstCreate

Function .onGUIInit
    InitPluginsDir
    File /oname=$PLUGINSDIR\1.ico "${NSISDIR}\Contrib\Graphics\Icons\llama-blue.ico"
    File /oname=$PLUGINSDIR\2.ico "${NSISDIR}\Contrib\Graphics\Icons\llama-grey.ico"
    File /oname=$PLUGINSDIR\3.ico "${NSISDIR}\Contrib\Graphics\Icons\nsis1-install.ico"
    File /oname=$PLUGINSDIR\4.ico "${NSISDIR}\Contrib\Graphics\Icons\nsis1-uninstall.ico"

FunctionEnd

Function FirstCreate

    nsDialogs::Create 1018
    Pop $0
    
    ${NSD_CreateIcon} 8u 12u 32 32 ""
    Pop $1
    ${NSD_SetIcon} $1 "$PLUGINSDIR\1.ico" $R1
    
    ${NSD_CreateIcon} 8u 47u 32 32 ""
    Pop $2
    ${NSD_SetIcon} $2 "$PLUGINSDIR\2.ico" $R2
    
    ${NSD_CreateIcon} 8u 60u 32 32 ""
    Pop $3
    ${NSD_SetIcon} $3 "$PLUGINSDIR\3.ico" $R3
        
    ${NSD_CreateIcon} 8u 84u 32 32 ""
    Pop $4
    ${NSD_SetIcon} $4 "$PLUGINSDIR\4.ico" $R4
    
    nsDialogs::Show
    ${NSD_FreeIcon} $R1
    ${NSD_FreeIcon} $R2
    ${NSD_FreeIcon} $R3
    ${NSD_FreeIcon} $R4
    
FunctionEnd


Section
SectionEnd
Anders
  • 97,548
  • 12
  • 110
  • 164
  • D'oh! I knew it was something so simple that i wasn't seeing... the lack of errors or warning (about the missing parameters what is the big issue in my code) confused me. Thanks! – Lukas ThyWalls Dec 20 '21 at 00:26
  • Yes, the lack of a warning is unfortunate. It happens because it ends up as a plug-in call and not actually a macro. – Anders Dec 20 '21 at 01:49
  • @LukasThyWalls you can try the WYSIWYG editor for creating custom pages to minimize the errors from manual editing. See install-designer.com/ (sorry for self promo) – Slappy Dec 20 '21 at 06:37
  • Haha, thanks Slappy, don't worry. But i learn the basics to code long time ago and i didn't do very often since then, so from time to time learning something new and coding with it creating something from scratch, although it is for little personal projects, is a bit of a joy for me. – Lukas ThyWalls Dec 20 '21 at 21:53