NSD_CreateDropList creates a droplist.
nsDialogs
173 posts
seems my nsis was outdated
Invalid command: ${NSD_CreateDropList}
however - it's not mentioned how to add values to a droplist val1|val2|val3 did nothing
Invalid command: ${NSD_CreateDropList}
however - it's not mentioned how to add values to a droplist val1|val2|val3 did nothing
Droplist doesn't swing that way. Use SendMessage to send CB_ADDSTRING message to the droplist control.
SendMessage $CONTROL ${CB_ADDSTRING} 0 "STR:val1"
SendMessage $CONTROL ${CB_ADDSTRING} 0 "STR:val2"
SendMessage $CONTROL ${CB_ADDSTRING} 0 "STR:val3"
And to get the value from droplist I use this.
SendMessage $CONTROL ${CB_GETCURSEL} 0 0 $0
System::Call 'User32::SendMessage(i $CONTROL, i ${CB_GETLBTEXT}, i r0, t .s)'
Pop $VALUE
Even though simple ${NSD_GetText} seems to work too.
SendMessage $CONTROL ${CB_ADDSTRING} 0 "STR:val1"
SendMessage $CONTROL ${CB_ADDSTRING} 0 "STR:val2"
SendMessage $CONTROL ${CB_ADDSTRING} 0 "STR:val3"
And to get the value from droplist I use this.
SendMessage $CONTROL ${CB_GETCURSEL} 0 0 $0
System::Call 'User32::SendMessage(i $CONTROL, i ${CB_GETLBTEXT}, i r0, t .s)'
Pop $VALUE
Even though simple ${NSD_GetText} seems to work too.
thanks trueparuex!
will it stay this way or are there more macros in the working? if not, let me point out that "Each of those macros takes 5 parameters" from the docs does not apply to DropList then (to whoever updates the docs)
will it stay this way or are there more macros in the working? if not, let me point out that "Each of those macros takes 5 parameters" from the docs does not apply to DropList then (to whoever updates the docs)
once a nsDialogs page is displayed, is it possible to control the state of an element (hide, disable/gray out, enable again, show again) in the OnChange function? any hints how this is done?
NSD_CreateListBox
Hi,
How can I add item into List box? How can add event with this list box? I am doing the following but no item inside list box is appearing:
${NSD_CreateListBox} 30u 90u -30u 38u $R4
Pop $R4
SendMessage $R4 ${CB_ADDSTRING} 0 "STR:val1"
SendMessage $R4 ${CB_ADDSTRING} 0 "STR:val2"
SendMessage $R4 ${CB_ADDSTRING} 0 "STR:val3"
Could you please give me an example for list box using nsDialog?
Thanks in advance.
Ekhuq
Hi,
How can I add item into List box? How can add event with this list box? I am doing the following but no item inside list box is appearing:
${NSD_CreateListBox} 30u 90u -30u 38u $R4
Pop $R4
SendMessage $R4 ${CB_ADDSTRING} 0 "STR:val1"
SendMessage $R4 ${CB_ADDSTRING} 0 "STR:val2"
SendMessage $R4 ${CB_ADDSTRING} 0 "STR:val3"
Could you please give me an example for list box using nsDialog?
Thanks in advance.
Ekhuq
@Yathosho
Yes. The notification (OnClick, OnChange and OnNotify) callback functions are exactly for that kind of operations. I made a small example that uses the OnChange callback. It's little light on the comments, but it should give the basic idea.
The example uses EnableWindow to enable / disable conrols, but you can use ShowWindow, SendMessage and system plugin just as well. 🙂
@ekramulhuq
CB_* messages are only for ComboBox controls. For ListBox you need to use LB_* messages E.g. LB_ADDSTRING.
See the example. It uses ListBox to do things... 🙂
Yes. The notification (OnClick, OnChange and OnNotify) callback functions are exactly for that kind of operations. I made a small example that uses the OnChange callback. It's little light on the comments, but it should give the basic idea.
The example uses EnableWindow to enable / disable conrols, but you can use ShowWindow, SendMessage and system plugin just as well. 🙂
@ekramulhuq
CB_* messages are only for ComboBox controls. For ListBox you need to use LB_* messages E.g. LB_ADDSTRING.
See the example. It uses ListBox to do things... 🙂
thanks again
one remaining question, how to manipulate the state of a checkbox? my attempts using SendMessage with ${BM_SETSTATE} weren't successful..
SendMessage $CheckBox ${BM_SETCHECK} ${BST_CHECKED} 0Transparent bitmap
I have some difficulties to migrate from Installoptions to nsDialog. On the first page I've seen an example how to make transparent controls, but is it possible to do it in a easier way? I need a bitmap control which would make the white background color of the loaded image in it transparent. Is there a color which is handled as transparent by default?
Should ${NSD_AddExStyle} $Image1 ${WS_EX_TRANSPARENT} work?
I have some difficulties to migrate from Installoptions to nsDialog. On the first page I've seen an example how to make transparent controls, but is it possible to do it in a easier way? I need a bitmap control which would make the white background color of the loaded image in it transparent. Is there a color which is handled as transparent by default?
Should ${NSD_AddExStyle} $Image1 ${WS_EX_TRANSPARENT} work?
Function DriverSelection
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"
nsDialogs::Create /NOUNLOAD 1018
Pop $DriverDialog
${If} $DriverDialog == error
Abort
${EndIf}
${NSD_CreateGroupBox} 0 0 100% 100% "$(TEXT_IO_TITLE)"
Pop $0
${NSD_CreateLabel} 14 21 100% 16u "$(TEXT_LABEL_TITLE)"
Pop $0
${NSD_CreateRadioButton} 108 55 100% 16u "$(TEXT_YES_TITLE)"
${NSD_CreateRadioButton} 108 109 100% 16u "$(TEXT_NONE_TITLE)"
${NSD_CreateBitmap} 14 41 29u 39u ""
Pop $Image1
${NSD_SetImage} $Image1 $PLUGINSDIR\1.bmp $ImageHandle1
${NSD_AddExStyle} $Image1 ${WS_EX_TRANSPARENT}
${NSD_CreateBitmap} 51 41 29u 39u ""
Pop $Image2
${NSD_SetImage} $Image2 $PLUGINSDIR\2.bmp $ImageHandle2
${NSD_AddExStyle} $Image2 ${WS_EX_TRANSPARENT}
${NSD_CreateBitmap} 33 103 27u 23u ""
Pop $Image3
${NSD_SetImage} $Image3 $PLUGINSDIR\3.bmp $ImageHandle3
${NSD_AddExStyle} $Image3 ${WS_EX_TRANSPARENT}
nsDialogs::Show
${NSD_FreeImage} $ImageHandle1
${NSD_FreeImage} $ImageHandle2
${NSD_FreeImage} $ImageHandle3
FunctionEnd
You can add two flags to the LoadImage call that'd make it load the image with the first pixel's color being "transparent". By transparent, I actually mean gray as the window behind it. The flags are ${LR_LOADTRANSPARENT}|${LR_LOADMAP3DCOLORS}. You can drop the second one to make "transparent" white instead of gray.
Originally posted by kichikwhite and gray are the colors in classic windows theme, but the actual color used is from GetSysColor(COLOR_WINDOW or COLOR_3DFACE)
You can add two flags to the LoadImage call that'd make it load the image with the first pixel's color being "transparent". By transparent, I actually mean gray as the window behind it. The flags are ${LR_LOADTRANSPARENT}|${LR_LOADMAP3DCOLORS}. You can drop the second one to make "transparent" white instead of gray.
I've tried this, but it's still white...
Something else to consider?
Something else to consider?
${NSD_CreateBitmap} 36 58 53 80 ""
Pop $Image1
System::Call `user32::LoadImage(i 0, t "$PLUGINSDIR\1.bmp", i 0, i 0, i 0, i ${LR_LOADTRANSPARENT}|${LR_LOADFROMFILE}) i.s`
Pop $ImageHandle1
SendMessage $Image1 ${STM_SETIMAGE} 0 $ImageHandle1
thanks it works now. My bitmaps had more than 8bpp so it couldn't work... But I remember that 24 bit bitmaps worked with InstallOptions...
The ${NSD_On*} event macros in the nsDialogs documentation are still defined as ${NSD_On*} control_HWND function_address. Should be ideally ${NSD_On*} control_HWND function_name.
Stu
Stu
I cut down sab0tage's code to what I need:
It works as expected, but, how do I set the inital directory for the SelectFileDialog?!include "MUI.nsh"
!include nsDialogs.nsh
!include LogicLib.nsh
!include winmessages.nsh
Var INST_SDAT_LOC
Var INST_SDAT_BTN
Name "test"
OutFile "nsDialogFileBrowse.exe"
Page custom SettingsPage
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function SettingsPage
nsDialogs::Create /NOUNLOAD 1018
Pop $0
${NSD_CreateBrowseButton} 410 170 25 12u "..."
Pop $INST_SDAT_BTN
nsDialogs::SetUserData /NOUNLOAD $INST_SDAT_BTN FileRequest # remember field id
GetFunctionAddress $0 SDATFileBrowseButton
nsDialogs::OnClick /NOUNLOAD $INST_SDAT_BTN $0
${NSD_CreateFileRequest} 110 170 300 12u ""
Pop $INST_SDAT_LOC
nsDialogs::Show
FunctionEnd
Function SDATFileBrowseButton
nsDialogs::SelectFileDialog /NOUNLOAD open $2 "sdatXXXX.exe|sdat*.exe"
Pop $2
${If} $2 != ""
SendMessage $INST_SDAT_LOC ${WM_SETTEXT} 0 STR:$2
${EndIf}
FunctionEnd
Section
SectionEnd
I have figured out that the way to do it is to change the value of $2 before calling SelectFileDialog.
I tried the following (the Program Files directory is just called Program on my system):
StrCpy $2 "C:\Program" ; The dialog will begin in C:\ looking for a file called Program
StrCpy $2 "C:\Program\" ; The dialog will begin in the current working directory
StrCpy $2 "C:\Program\*" ; The dialog will begin in C:\Program looking for a file called *
How do I make it start in C:\Program but without looking for any particular filename?
I tried the following (the Program Files directory is just called Program on my system):
StrCpy $2 "C:\Program" ; The dialog will begin in C:\ looking for a file called Program
StrCpy $2 "C:\Program\" ; The dialog will begin in the current working directory
StrCpy $2 "C:\Program\*" ; The dialog will begin in C:\Program looking for a file called *
How do I make it start in C:\Program but without looking for any particular filename?
Hi,
I'm trying to disable a ListBox with:
I searched my code for "Layer 8" faults but couldn't find any what of course doesn't mean that there is none 😉
If it's not supported by nsDialogs: Do I have to make a system call?
Till
I'm trying to disable a ListBox with:
But this apparently does not work (i.e. it does not get grayed out as opposed to a simple "Text" or "CheckBox").
EnableWindow $ListBox 0
I searched my code for "Layer 8" faults but couldn't find any what of course doesn't mean that there is none 😉
If it's not supported by nsDialogs: Do I have to make a system call?
Till
wrong window handle? try to hide it with ShowWindow to make sure
Hi,
Originally posted by AndersShowWindow works as expected. Same handle, same line.
wrong window handle? try to hide it with ShowWindow to make sure
Using "Enable Window" only grays out the text inside the ListBox.
I can live with that but it still doesn't look right to me.
I can live with that but it still doesn't look right to me.
any plans to add tooltip support?
Originally posted by elllitEnableWindow just calls the win api, what the disabled windows looks like depends on your theme, has nothing to do with nsis
Using "Enable Window" only grays out the text inside the ListBox.
I can live with that but it still doesn't look right to me.
Anders: True! Thanks 🙂
Yathosho: Theres a plug-in, but I haven't tested it yet. see: http://nsis.sourceforge.net/ToolTips_plug-in
Yathosho: Theres a plug-in, but I haven't tested it yet. see: http://nsis.sourceforge.net/ToolTips_plug-in
http://nsis.sourceforge.net/ToolTips_plug-in and works! 😉
in a prior script i used these lines of code to change the caption of a custom page (mui)
!insertmacro MUI_HEADER_TEXT "$(LabelCaption)" "$(LabelDescription)"
GetDlgItem $0 $HWNDPARENT 3
ShowWindow $0 0 however, since i added a dialog using nsdialogs, this code is getting ignored. it's placed in the show function to the components page. any help?You should be using the MUI_PAGE_HEADER_TEXT and MUI_PAGE_HEADER_SUBTEXT defines for non custom pages.
Stu
Stu
Can you add TreeView and RishText controls support in nsDialog?
There is a patch already submitted to add support for RichText controls, but for some reason it hasn't been added yet. I don't know why it wasn't included in the last release of nsis... Patch URL: http://sourceforge.net/tracker/index...49&atid=373087