Skip to content
⌘ NSIS Forum Archive

How to access a SysListView32 control

5 posts

jiake#

How to access a SysListView32 control

I write a script to create a SysListView32 control using nsDialogs, but it could only show a box. I want to insert columns and items into it, but after read the Messages of SysListView32 control at MSDN, I know that I must use API to access this control as some of the messages need "the pointer to an LVCOLUMN structure that contains the attributes of the new column".

I don't know how to use System plug-in to access it. I hope that nsDialogs provide more controls support, such as msctls_trackbar32, SysListView32, SysTreeView32 etc. in future.
!include "MUI2.nsh"
;!include "UsefulLib.nsh"
Name "List View"
OutFile SysListView32.exe
InstallDir $TEMP
ShowInstDetails Show
Page custom CreatePage
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section Install
SectionEnd
Function CreatePage
    !insertmacro MUI_HEADER_TEXT "List view control" "A SysListView32 control created by nsDialogs plugin"
    nsDialogs::Create 1018
    Pop $0
    ${If} $0 == error
        Abort
    ${EndIf}
    
    ${NSD_CreateLabel} 0u 0u 300u 8u "Please specify the target folder where to install this software:"
    Pop $1
    ${NSD_CreateFileRequest} 0u 12u 232u 12u "D:\TTPlayer"
    Pop $2
    ${NSD_CreateBrowseButton} 240u 12u 60u 12u "&Browse..."
    Pop $3
    ${NSD_OnClick} $3 DirSelect
    ${NSD_CreateGroupBox} 0u 28u 300u 112u "Drive space:"
    Pop $4
    !define IDC_LISTVIEW        1600
    !define LVS_REPORT          0x00000001
    !define LVS_SINGLESEL       0x00000004
    !define LVM_SETBKCOLOR      0x00001001
    !define LVM_INSERTITEM      0x00001007
    !define LVM_INSERTCOLUMN    0x0000101B
    !define LVM_SETCOLUMNWIDTH  0x0000101E
    ; Using nsDialogs
    nsDialogs::CreateControl /NOUNLOAD SysListView32 ${DEFAULT_STYLES}|${WS_TABSTOP}|${LVS_REPORT}|${LVS_SINGLESEL} ${WS_EX_CLIENTEDGE} 5u 40u 290u 95u "ListView"
    Pop $5
    ; Using Win32 API
    # FindWindow $0 "#32770" "" $HWNDPARENT
    # System::Call 'kernel32::GetModuleHandle(i 0) i.r5'
    # System::Call 'user32::CreateWindowEx(i ${WS_EX_CLIENTEDGE}, t "SysListView32", t "", i ${DEFAULT_STYLES}|${WS_TABSTOP}|${LVS_REPORT}|${LVS_SINGLESEL}, i 8, i 65, i 434, i 154, i $0, i ${IDC_LISTVIEW}, i r5, i 0) i.r5'
    SendMessage $5 ${LVM_SETBKCOLOR} 0 0xC7EDCC
    nsDialogs::Show
FunctionEnd
Function DirSelect
    ${NSD_GetText} $2 $R0
    nsDialogs::SelectFolderDialog "$(^DirBrowseText)" "$R0"
    Pop $R0
    ${IfNot} $R0 == error
        ${NSD_SetText} $2 $R0
    ${EndIf}
FunctionEnd 
Animaether#
until somebody abstracts the System plugin calls to manipulate these, you might be easier off with either http://nsis.sourceforge.net/EmbeddedLists_plug-in or http://nsis.sourceforge.net/InstallOption****plug-in
jiake#
Hey, a person (username gfm688) in Dreams8.com write it to access the ListView control, and I made a demo using it:
jiake#
Originally Posted by JohaViss View Post
Hi Jiake,

This looks great.😎
Any chance to provide the source to this?
See this thread:
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.