在nsDialogs里有以下一些宏是针对列表框操作的!当然也不是都是正确的!
;需修正NSD_LB_DelString
;需修正NSD_LB_Clear
${NSD_CreateListBox} 用于创建列表框
NSD_LB_AddString
${NSD_LB_AddString} listbox_HWND string
添加字符串到列表框(list box)。
NSD_LB_DelString
${NSD_LB_DelString} listbox_HWND string
删除列表框(list box)中字符串。
NSD_LB_Clear
${NSD_LB_Clear} listbox_HWND
删除列表框(list box)中所有字符串。
NSD_LB_GetCount
${NSD_LB_GetCount} listbox_HWND output_variable
返回列表框(list box)中字符串的数量。
NSD_LB_SelectString
${NSD_LB_SelectString} listbox_HWND string
选择列表框(list box)中的字符串。
NSD_LB_GetSelection
${NSD_LB_GetSelection} listbox_HWND output_variable
返回列表框中选定的字符串。如果没有字符串被选中,则返回空字符串。
!include "nsDialogs.nsh"
!include "winmessages.nsh"
!include "logiclib.nsh"
Caption "ListBox列表控件的操作"
OutFile "yhxs3344.exe"
BrandingText "WwW.yhxs3344.Net"
loadlanguagefile "${NSISDIR}ContribLanguage filessimpChinese.nlf"
Page Custom pre
var dialog
Var ListBox
Var button
Var hwnd
Function pre
nsDialogs::Create 1018
Pop $dialog
${NSD_CreateListBox} 0 0 50% 100% ""
Pop $ListBox
;增加文字到列表
Call Addstring
;选择列表框(list box)中的字符串(仅一列)
${NSD_LB_SelectString} $ListBox "似水年华"
${NSD_CreateText} 55% 0 100% 12u "永恒心锁"
Pop $hwnd
${NSD_CreateButton} 55% 15% 40% 13u "删除列表中上文本框文字"
Pop $button
${NSD_OnClick} $button Button1
${NSD_CreateButton} 55% 30% 40% 13u "添加上文本框文字到列表中"
Pop $button
${NSD_OnClick} $button Button2
${NSD_CreateButton} 55% 45% 40% 13u "清空列表中文字"
Pop $button
${NSD_OnClick} $button Button3
${NSD_CreateButton} 55% 60% 40% 13u "恢复默认列表中文字"
Pop $button
${NSD_OnClick} $button Addstring
${NSD_CreateButton} 55% 75% 40% 13u "返回列表中字符串数量"
Pop $button
${NSD_OnClick} $button Button4
${NSD_CreateButton} 55% 90% 40% 13u "获取所选文字"
Pop $button
${NSD_OnClick} $button Button5
nsDialogs::Show
FunctionEnd
;=======默认列表文字=======
Function Addstring
;SendMessage $ListBox ${LB_ADDSTRING} 0 "STR:永恒心锁"
;先清空后添加
${NSD_LB_Clear} $ListBox
${NSD_LB_AddString} $ListBox "永恒心锁"
${NSD_LB_AddString} $ListBox "yhxs3344"
${NSD_LB_AddString} $ListBox "yhxs3344.Net"
${NSD_LB_AddString} $ListBox "永恒心锁"
${NSD_LB_AddString} $ListBox "永恒心锁"
${NSD_LB_AddString} $ListBox "永恒心锁"
FunctionEnd
;=======删除列表文字=======
Function Button1
${NSD_GetText} $hwnd $0
MessageBox MB_OK '删除【$0】?'
;需修正NSD_LB_DelString
${NSD_LB_DelString} $ListBox "$0"
FunctionEnd
;=======添加列表文字=======
Function Button2
${NSD_GetText} $hwnd $0
MessageBox MB_OK '添加【$0】?'
${NSD_LB_AddString} $ListBox "$0"
FunctionEnd
;=======清空列表文字=======
Function Button3
;需修正NSD_LB_Clear
${NSD_LB_Clear} $ListBox
FunctionEnd
;=======列表中字符串数量=======
Function Button4
${NSD_LB_GetCount} $ListBox $0
MessageBox MB_OK '字符串数量$0'
FunctionEnd
;=======返回列表中选中文字=======
Function Button5
${NSD_LB_GetSelection} $ListBox $0
${IF} $0 == ""
MessageBox MB_OK '没有任何选中'
${else}
MessageBox MB_OK '选中了【$0】'
${ENDIF}
FunctionEnd
Section -yhxs3344.Net
SectionEnd
THE END
暂无评论内容