Skip to content
⌘ NSIS Forum Archive

nsDialogs

173 posts

vbguy#
Originally posted by bnicer
Oddly enough,

SetCtlColors $TEXT 0x000000 transparent

does not make the background transparent.

SetCtlColors $TEXT 0x000000 0x0000ff

changes the background to blue. ???
0x0000ff is blue.

This is how you set controls to transparent:

SetCtlColors $TEXT 0x000000 "transparent"
bnicer#
I always get white.

Compile Welcome.nsi with a transparent text background.
Function nsDialogsWelcome
    nsDialogs::Create /NOUNLOAD 1044
    Pop $DIALOG
    nsDialogs::CreateItem /NOUNLOAD STATIC 
${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to nsDialogs!"
    Pop $HEADLINE
    SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
    nsDialogs::CreateItem /NOUNLOAD STATIC 
${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "nsDialogs is the next generation..."
    Pop $TEXT
    SetCtlColors $DIALOG "" 0xffffff
    SetCtlColors $HEADLINE "" 0xffffff
    SetCtlColors $TEXT 0xffffff "transparent"
    nsDialogs::CreateItem /NOUNLOAD STATIC 
${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
    Pop $IMAGECTL
    StrCpy $0 $PLUGINSDIR\welcome.bmp
    System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 497, i 0, i ${LR_LOADFROMFILE}) i.s'
    Pop $IMAGE
    
    SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
    Call HideControls
    nsDialogs::Show
    Call ShowControls
    System::Call gdi32::\DeleteObject(i$IMAGE)
FunctionEnd 
kichik#
That example doesn't use WS_EX_TRANSPARENT, you need to add it. Replace the 0 that comes after the styles with ${WS_EX_TRANSPARENT}. Don't forget to copy its definition from nsDialogs.nsh.
bnicer#
WS_EX_TRANSPARENT extended style; how do I define it?

I have, so far...
nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|$(WS_EX_TRANSPARENT) 0 120u 32u -130u -32u "nsDialogs is the next generation..." 
FoBoT#
does the BrandingImage stuff work with this yet?
I copy/pasted the commands below into InstallOptions.nsi pointing to my .ini file

ChangeUI all "${NSISDIR}\Contrib\UIs\modern.exe"
AddBrandingImage top 20
SetBrandingImage "$PLUGINSDIR\logo.bmp"

from a working InstallOptions version and it displays correctly except the logo is missing from the top of the page
FoBoT#
also, is the functionality in place yet to change the cancel/next button labels? for example my old .ini files has:

[Settings]
NumFields=2
Title=Control Panel
CancelEnabled=1
CancelShow=1
BackEnabled=1
CancelButtonText=Exit
NextButtonText=Enter

so that the cancel/next buttons display custom text

thank you
Animaether#
You can always do that manually, FoBoT. In fact, it's more flexible with nsDialogs as you can enable/disable / change texts on those buttons dynamically based on what the user is doing - with any dialog item rather than only those that would cause an InstallOptions exit.


GetDlgItem $0 $HWNDPARENT 1 ; Next button
SendMessage $0 ${WM_SETTEXT} 0 "STR:Custom Next"
GetDlgItem $0 $HWNDPARENT 3 ; Next button
SendMessage $0 ${WM_SETTEXT} 0 "STR:Custom Back"
Afrow UK#

!macro __NSD_Event NAME HWND FUNC

Push $R0
GetFunctionAddress $R0 ${FUNC}
nsDialogs::${NAME} /NOUNLOAD ${HWND} $R0
Pop $R0

!macroend

!macro __NSD_DefineEvent NAME

!define NSD_${NAME} "!insertmacro __NSD_Event ${NAME}"

!macroend

!insertmacro __NSD_DefineEvent OnBack
!insertmacro __NSD_DefineEvent OnClick
!insertmacro __NSD_DefineEvent OnChange
${NSD_OnClick} $HWND MyOnClickFunction
${NSD_OnBack} $HWND MyOnBackFunction
${NSD_OnChange} $HWND MyOnChangeFunction

Stu
kichik#
Originally posted by FoBoT
does the BrandingImage stuff work with this yet?
I copy/pasted the commands below into InstallOptions.nsi pointing to my .ini file

ChangeUI all "${NSISDIR}\Contrib\UIs\modern.exe"
AddBrandingImage top 20
SetBrandingImage "$PLUGINSDIR\logo.bmp"

from a working InstallOptions version and it displays correctly except the logo is missing from the top of the page
AddBrandingImage is unrelated to nsDialogs. It adds an image control to the external dialog and not the internal dialogs, such as those created by nsDialogs. logo.bmp was probably not extracted to $PLUGINSDIR.
bnicer#
Function OnClick
MessageBox MB_OK "Setup will now abort."
Quit
FunctionEnd
I have a problem with Quit here. Sorry to be disruptive again.
bnicer#
I think you can't create a custom button that closes the installer. The Back, Next and Close buttons are hidden. That's the plan.
bnicer#
Yes, it doesn't quit. nsDialogs is so full of shortcuts, I was kind of hoping that would be another one.
kichik#
That's not currently possible as the code handling g_quit_flag is in the installer itself, separate from nsDialogs which doesn't have access to this flag. That wasn't a problem until the direct function callbacks were added. I need to think how it'd be best to handle this. Please submit a feature request.
Afrow UK#
I'm guessing calling Abort won't work but how about sending WM_NOTIFY_OUTER_NEXT with a value of 120 (cancel)?

Stu
kichik#
I don't know how well that'd work, considering it might start unloading while still handling another callback. It needs testing.
randomSurfer#
I want to resize the NSIS installer window when I display a custom page. Can I specify new rectangle params for nsDialogs::Create? I looked into INI file's Settings\RECT that states "RECT: Overrides the default rect ID to run over. This will make IO resize itself according to a different rect than NSIS's dialogs rect."
What is this rect ID ?

This is what I am trying to do :

Page custom "ShowBrowser" "LeaveBrowser"

function ShowBrowser
nsDialogs::Create /NOUNLOAD 1044 ;how can I resize this window?
Pop $R1
SetPluginUnload alwaysoff
SetOutPath "$INSTDIR\temp"
System::Call 'installer::ShowWebPage(i) v (R1)'
nsDialogs::Show
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 1
functionend

Any help will be appreciated.
Thanks
bnicer#
Quit function

An nsDialogs Close button would be convenient. I hope it works. Thanks. 🙂

randomSurfer, you can resize the controls and the installer window with Resource Hacker. For mui custom pages it's dialog 105, modern.exe. The changes will be visible in other pages.
jdpipe#
This plugin ins great but obviously in dire need of some documentation, however meagre. *PLEASE* try to write something? The examples don't even have commenting.

My particular problem: how to retrieve the value from a checkbox after the user leaves the page?
kichik#
Send the BM_GETCHECK to the control.
SendMessage $CHECKBOX ${BM_GETCHECK} 0 0 $0
If $0 is 0, it's unchecked. If it's 1, it's checked. Anything else is an intermediate state.
jdpipe#
Thanks for that. Can you also tell me: what are the parameters for the '${NSD_CreateCheckbox}' command?
jdpipe#
More questions: Do I need to use 'BM_SETCHECK' to set a new checkbox to 'checked'? Or can I do that via NSD_CreateCheckbox?
kichik#
NSD_CreateCheckbox, like every other NSD_Create* takes x, y, width, height and text. To set the state of a checkbox, use BM_SETCHECK.
lushdog#
Showing, hiding GUI elements...

Just wondering if you can re-create the style of the MS installers that show and hide a checkmark image if the CD-KEY entered is valid.

I have the code setup now to show a message box if the key length is valid so I'd just have to change that code to show/hide an image on the page.
Animaether#
just get a handle to that checkmark and, in the callback function of the nsdialog item, use showwindow <hwnd> 0|1 to hide / unhide it?