Skip to content
⌘ NSIS Forum Archive

How to populate a ComboBox?

5 posts

Lupo73#

How to populate a ComboBox?

How can I add items to a combobox? I need to create a combobox in a custom page, that the user can use to select his language. Then I need to pass this info to a Section to make different operations for different languages.
Lupo73#
Good! ..and now how can I know what item is selected? I need to know what language the user have selected and set the language name as a string variable, to use it during the extraction process.
Animaether#
CB_GETCURSEL:
http://msdn.microsoft.com/en-us/library/bb775845(VS.85).aspx

SendMessage <hwnd> ${CB_GETCURSEL} 0 0 $0
$0 will contain selected index (0-based, so first item is zero, 2nd item is one, etc.)


!include "winmessages.nsh"
!include "LogicLib.nsh"
!include "nsDialogs.nsh"

Outfile "test.exe"

var dialog
var hwnd
var null

Page custom customPageA

Function customPageA

nsDialogs::Create 1018
Pop $dialog

${NSD_CreateCombobox} 0 0 100% 100% ""
Pop $hwnd
${NSD_CB_ADDSTRING} $hwnd "Hello"
${NSD_CB_ADDSTRING} $hwnd "World"
${NSD_OnChange} $hwnd combobox.onchange
nsDialogs::Show
Abort
FunctionEnd

Function combobox.onchange
Pop $hwnd
SendMessage $hwnd ${CB_GETCURSEL} 0 0 $0
MessageBox MB_OK "[$0]"
FunctionEnd

Section ""
SectionEnd