Prev Previous Post   Next Post Next
Old 6th August 2020, 23:44   #1
Junior Member
Join Date: May 2016
Posts: 7
Adding a check all / uncheck all

I inherited code that lists a bunch of options and allows the user to select them:


!include nsDialogs.nsh
!include WinMessages.nsh
!define /math LVM_GETITEMTEXTA ${LVM_FIRST} + 45
!define /math LVM_GETITEMTEXTW ${LVM_FIRST} + 115
Var hListCtl
Page Custom LVPageCreate LVPageLeave

Function AddCheckedListViewItemWith1SubItem
System::Store S
Pop $4
Pop $3
Pop $2
Pop $1
System::Call '*(i ${LVIF_TEXT},i 0x7fffffff,i 0,i,&i${NSIS_PTR_SIZE},tr2,i,i,p)p.r9'
SendMessage $1 ${LVM_INSERTITEM} "" $9 $0
System::Call '*$9(i${LVIF_STATE},i,i,i0x2000,&i${NSIS_PTR_SIZE} ${LVIS_STATEIMAGEMASK},p,i,i,p)'
IntCmpU $4 0 +2
SendMessage $1 ${LVM_SETITEMSTATE} $0 $9 $8
System::Call '*$9(i,i 0x7fffffff,i 1,i,i,tr3,i,i,p)'
SendMessage $1 ${LVM_SETITEMTEXT} $0 $9
System::Free $9
System::Store L

!macro AddCheckedListViewItemWith1SubItem hLV txt sub1 checked
Push ${hLV}
Push "${txt}"
Push "${sub1}"
Push "${checked}"
Call AddCheckedListViewItemWith1SubItem

Function LVPageCreate
nsDialogs::Create 1018
Pop $0

${NSD_CreateLabel} 0 0 100% 12u "File associations for mrViewer"

nsDialogs::CreateControl "SysListView32" ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${LVS_REPORT} ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE} 0 20 100% 90% ""
Pop $hListCtl
System::Call '*(i${LVCF_TEXT}|${LVCF_SUBITEM},i,i,t "Extension",i,i 0)p.r9'
SendMessage $hListCtl ${LVM_INSERTCOLUMN} 0x7fffffff $9
System::Call '*$9(i,i,i,t "Description",i,i 1)'
SendMessage $hListCtl ${LVM_INSERTCOLUMN} 0x7fffffff $9
System::Free $9

# ...the options...

!insertmacro AddCheckedListViewItemWith1SubItem $hListCtl ".tiff" "TIFF file" 1
!insertmacro AddCheckedListViewItemWith1SubItem $hListCtl ".tga" "Targa file" 1
!insertmacro AddCheckedListViewItemWith1SubItem $hListCtl ".bmp" "Windows/OS2 Bitmap" 1
# ...etc...

SendMessage $hListCtl ${LVM_SETCOLUMNWIDTH} 0 -1
SendMessage $hListCtl ${LVM_SETCOLUMNWIDTH} 1 -1
System::Call 'USER32::PostMessage(p $hwndparent, i ${WM_NEXTDLGCTL}, p $hListCtl, i1)'

# LVLeavePage not shown

I would like to have a checkin button and function that toggles on/off all the listed items.

Can someone help me write it?
ggarra13 is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump