Skip to content
⌘ NSIS Forum Archive

Add string in ComboBox (LB_ADDSTRING)

5 posts

berrada#

Add string in ComboBox (LB_ADDSTRING)

I need to add some strings in a ComboBox.
I think to use the SendMessage to this, but the Windows event LB_ADDSTRING don't exist in WinMessages.nsh

I added the following lignes in this file:
!define LB_ADDSTRING 0x180
!define LB_INSERTSTRING 0x181

and I write the following code:
; [Get HWND current page of installation]
FindWindow $hwnd "#32770" "" $HWNDPARENT
; [Disable Directory field]
GetDlgItem $item $hwnd 1019 ; IDC_DIR
SendMessage $item ${LB_ADDSTRING} "STR:line one"
SendMessage $item ${LB_ADDSTRING} "STR:line two"
SendMessage $item ${WM_SETTEXT} "STR:init value"

and it's not work !

help, please.
kichik#
If it's a combo box, you need to use CB_ADDSTRING not LB_ADDSTRING. In both cases, the string should be passed in lParam, not wParam as in your example.
berrada#
no change when I do:

SendMessage $item ${CB_ADDSTRING} 0 "STR:line one"
SendMessage $item ${CB_ADDSTRING} 0 "STR:line two"

NB:
I'v added the CB_ADDSTRING in WinMessages.nsh
!define CB_ADDSTRING 0x403
kichik#
CB_ADDSTRING is 0x0143 not 0x403. Additionally, it seems you're trying to use the message with a edit box, not a combo box. IDC_DIR is the id of the directory edit box.