Thanks for reading my article. I wish you always good things :)
I'm using NSIS and I've created a custom page to create a button. (using nsDialog) When the button is clicked, the second dialog is created using the nswindows plugin and the search function is implemented in it. I can't add columns because I'm using a ListBox. Columns can only be added through a ListView, but the ${LSW_*} commands can only add a ListBox. Is there any way to add columns? I'll add the image I want to implement. thank you.
Var hwindow3
Var hCtl_test_ListBox1
Function MyTestListBox
${NSW_CreateWindow} $hwindow3 "TEst" 1018
${NSW_SetWindowSize} $hwindow3 400 300
${NSW_CenterWindow} $hwindow3 $hwndparent
${NSW_OnBack} OnBack3
${NSW_CreateListBox} 7u 59u 193u 91u ""
Pop $hCtl_testserchSchool_ListBox1
; i want ListView T_T
${NSW_Show}
Create_End:
ShowWindow $hwindow3 ${SW_SHOW}
FunctionEnd
The ListView is the most complicated Windows common control and NSIS does not have great support for it unfortunately.
Your best option is to use the 3rd-party header file from the Wiki.
!include CommCtrl.nsh
var lv
...
nsWindows::CreateControl /NOUNLOAD ${WC_LISTVIEW} ${__NSD_ListView_STYLE} ${__NSD_ListView_EXSTYLE} 3u 3u 100u 100u ""
Pop $lv
${NSD_LV_InsertColumn} $lv 0 100 "column 0"
${NSD_LV_InsertColumn} $lv 1 70 "column 1"
${NSD_LV_InsertItem} $lv 0 'Item 0'
${NSD_LV_SetItemText} $lv 0 1 'Subitem 0_1'
Reading text
!define /IfNDef LVM_GETITEMCOUNT 0x1004
!define /IfNDef LVM_GETITEMTEXTA 0x102D
!define /IfNDef LVM_GETITEMTEXTW 0x1073
!if "${NSIS_CHAR_SIZE}" > 1
!define /ReDef LVM_GETITEMTEXT ${LVM_GETITEMTEXTW}
!else
!define /ReDef LVM_GETITEMTEXT ${LVM_GETITEMTEXTA}
!endif
var lv
var item
var subitem
StrCpy $item 0
StrCpy $subitem 1
System::Call '*(&t${NSIS_MAX_STRLEN})p.r3'
System::Call "*(i, i, i, i, i, p, i, i, i) p (0, 0, $subitem, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1"
System::Call "User32::SendMessage(p, i, p, p) p ($lv, ${LVM_GETITEMTEXT}, $item, r1)"
System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)"
System::Free $1
System::Free $3
MessageBox mb_ok $4