Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 1st December 2008, 00:47   #1
melflex
Junior Member
 
Join Date: Nov 2008
Posts: 3
Problems getting horizontal scrollbars on a listbox working

I am trying to get a horizontal scrollbar to be displayed on the list box but with no success, below is what I am trying to do, I have also tried setting LB_SETHORIZONTALEXTENT as the msdn state that this needs to be set if you want to set WS_HSCROLL but it didn't help.
Has anybody else enabling the horizontal scrollbar?

Function releaseNotesPage

nsDialogs::Create /NOUNLOAD 1018
Pop $ReleaseNotesDialog

${If} $ReleaseNotesDialog == error
Abort
${EndIf}

${NSD_CreateLabel} 0 0 100% 12u "Release notes."
Pop $ReleaseNotesLabel

${NSD_CreateListBox} 0 13u 262u -13u ""
Pop $ReleaseNotesText
${NSD_LB_AddString} $ReleaseNotesText "A really long string that should be longer than the listbox that contains this message, so I can enable the horizontal scrollbar, Please."
SendMessage $ReleaseNotesText ${LB_SETHORIZONTALEXTENT} 20, 0
${NSD_AddStyle} $ReleaseNotesText ${WS_HSCROLL}

nsDialogs::Show

FunctionEnd


Thank-you
Melflex.
melflex is offline   Reply With Quote
Old 1st December 2008, 01:39   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 2,779
LB_SETHORIZONTALEXTENT is used to specify the max scroll width, so it needs to be bigger than the listview. It also works better if WS_HSCROLL is there from the get go so you don't have to refresh the control

PHP Code:
nsDialogs::CreateControl /NOUNLOAD ${__NSD_ListBox_CLASS} ${__NSD_ListBox_STYLE}|${WS_HSCROLL} ${__NSD_ListBox_EXSTYLE0 13u 262u -13u ""
Pop $ReleaseNotesText
${NSD_LB_AddString$ReleaseNotesText "A really long string that should be longer than the listbox that contains this message, so I can enable the horizontal scrollbar, Please."
SendMessage $ReleaseNotesText ${LB_SETHORIZONTALEXTENT2000  0 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 1st December 2008, 01:53   #3
melflex
Junior Member
 
Join Date: Nov 2008
Posts: 3
That worked.

Thanks most appreciated.
Melflex.
melflex is offline   Reply With Quote
Old 1st December 2008, 01:59   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 2,779
But of course, you might not know the end users font, or even how long the text is, so you can calculate it with this ugly code:

code:


nsDialogs::CreateControl /NOUNLOAD ${__NSD_ListBox_CLASS} ${__NSD_ListBox_STYLE}|${WS_HSCROLL} ${__NSD_ListBox_EXSTYLE} 0 13u 262u -13u ""
Pop $ReleaseNotesText
${NSD_LB_AddString} $ReleaseNotesText "A pretty loooooooooooooooooooooooooooooooooooooooooooooooong striiiiiiiiiiing"
${NSD_LB_AddString} $ReleaseNotesText "A really long string that should be longer than the listbox that contains this message, so I can enable the horizontal scrollbar!"


SendMessage $ReleaseNotesText ${WM_GETFONT} 0 0 $R0
System::Call user32::GetDC(i$ReleaseNotesText)i.R1
System::Call gdi32::SelectObject(i$R1,i$R0)i.R0
System::Call *(i,i)i.r0
StrCpy $2 0
${NSD_LB_GetCount} $ReleaseNotesText $1
loop:
IntOp $1 $1 - 1
System::Call 'user32::SendMessage(i $ReleaseNotesText,i ${LB_GETTEXT},i $1,t.r3)'
StrLen $4 $3
System::Call 'gdi32::GetTextExtentPoint32(i $R1,t "$3",i $4,i $0)'
System::Call *$0(i.r4,i)
IntOp $4 $4 + 10 ;add a little padding
${IfThen} $4 > $2 ${|} StrCpy $2 $4 ${|}
IntCmp $1 0 "" "" loop
System::Free $0
System::Call gdi32::SelectObject(i$R1,i$R0)i
System::Call user32::ReleaseDC(i$ReleaseNotesText,i$R1)

SendMessage $ReleaseNotesText ${LB_SETHORIZONTALEXTENT} $2 0



Edit: Added padding

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp 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