- NSIS Discussion
- Problem creating a droplist
Archive: Problem creating a droplist
dizou
15th July 2011 15:24 UTC
Problem creating a droplist
I am trying to create a drop list. This is the code I have:
Var TimeDialog
Var TimeZoneDropList
; Pages
Page components
Page directory
Page custom TimePage TimePageLeave "- Schedule Options"
Page instfiles
Function TimePage
nsDialogs::Create 1018
Pop $TimeDialog
${If} $TimeDialog == error
Abort
${EndIf}
${NSD_CreateDropList} 5u 28u 90% 12u
Pop $TimeZoneDropList
SendMessage $TimeZoneDropList ${CB_ADDSTRING} 0 "STR:US/Alaska"
${NSD_CB_AddString} $TimeZoneDropList "US/Arizona"
FunctionEnd
Everything compiles ok, but when I run it, The drop list does not show up.
Afrow UK
15th July 2011 15:54 UTC
Are you sure that compiles? All NSD_Create* macros expect 5 arguments not 4.
Stu
dizou
15th July 2011 16:03 UTC
Yes, it does compile like that. I just changed
${NSD_CreateDropList} 5u 28u 90% 12u
to
${NSD_CreateDropList} 5u 28u 90% 12u ""
and now I have a drop list, but it is empty.
Afrow UK
15th July 2011 17:37 UTC
Use NSD_CB_AddString to add items. Use NSD_CB_SelectString to make a selection.
Stu
dizou
15th July 2011 17:41 UTC
I am. I am doing:
${NSD_CB_AddString} $TimeZoneDropList "US/Arizona"
Nothing shows up.
Afrow UK
15th July 2011 18:17 UTC
Please post your code.
Stu
dizou
15th July 2011 19:57 UTC
Here is my code:
Var TimeDialog
Var TimeZoneDropList
; Pages
Page components
Page directory
Page custom TimePage TimePageLeave "- Schedule Options"
Page instfiles
Function TimePage
nsDialogs::Create 1018
Pop $TimeDialog
${If} $TimeDialog == error
Abort
${EndIf}
${NSD_CreateDropList} 5u 28u 90% 12u ""
Pop $TimeZoneDropList
${NSD_CB_AddString} $TimeZoneDropList "US/Arizona"
nsDialogs::Show
FunctionEnd
Afrow UK
15th July 2011 23:18 UTC
The height needs to be more than 12u as it is the height of the entire control including the drop down list (I don't think this applies to Vista/7 though).
Stu
dizou
19th July 2011 14:11 UTC
It does apply to Windows 7 because I am using Windows 7. Once I changed the height, everything worked. Did I miss something in the documentation because I didn't see anything about this when I was looking stuff up. Thanks!
dizou
19th July 2011 14:35 UTC
So now I have this as my page leave function:
Function TimePageLeave
Var /GLOBAL TimeZone
${NSD_CB_SelectString} $TimeZoneDropList $TimeZone
MessageBox MB_OK "$TimeZone"
FunctionEnd
However, when the messagebox pops up, nothing is displayed even when I am selecting something in my drop list.
Yathosho
19th July 2011 15:42 UTC
i think you must use NSD_GetText instead
dizou
19th July 2011 15:55 UTC
Yes. NSD_GetText worked. When is NSD_CB_SelectString used?
Afrow UK
19th July 2011 16:03 UTC
To select an item in the drop down list.
Stu