Old 14th January 2021, 23:04   #1
Junior Member
Join Date: Feb 2013
Posts: 11
Question: Center Align DropList

Hello there,

I am trying to align the strings listed inside a droplist to the horizontal center of said droplist.
Having quite a hard time trying to do so.
${AddStyle} or ${AddExStyle} in combination with ${ES_CENTER} or ${SS_CENTER} does not seem to work for me.
Google brings up html, c#, etc. but nothing what would directly help me or maybe I am just blind.

Does anyone here know of a workaround, besides trying to add spaces to the strings to center them manually, which opens another can of problems for me ?

Thank you for your time!

PHP Code:
!include "MUI2.nsh"
!include "nsDialogs.nsh"

!define PRODUCTNAME "DropListAlignCenter"
OutFile "${PRODUCTNAME}.exe"

RequestExecutionLevel user

Var DropList

!insertmacro MUI_LANGUAGE "English"

Page custom nsDialogsMainPage


Function nsDialogsMainPage
::Create 1044

${If} $== error
NSD_CreateDropList100u 50u 120u 200u ""
Pop $DropList
${NSD_CB_AddString$DropList "Alice"
${NSD_CB_AddString$DropList "Franklin"
${NSD_CB_AddString$DropList "set"
${NSD_CB_AddString$DropList "v0.09"
${NSD_CB_AddString$DropList "Apple Computer, Inc."
${NSD_CB_AddString$DropList "Microsoft Corporation"
nashtor is offline   Reply With Quote
Old 15th January 2021, 15:08   #2
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,542
You can't just mix and match random styles. Combobox styles are CBS_* and there is no style for alignment. The only way to make a droplist center its text would be to use the CBS_OWNERDRAWFIXED style and custom draw. This can only be done with a custom plug-in.

You can also fake it with a ComboBox by playing with its edit control:
PHP Code:
Page Custom custpagecr
!include nsDialogs.nsh

Function custpagecr
::Create 1018

${NSD_CreateComboBox0 13u 100% -13u ""
Pop $0
${NSD_CB_AppendString} $"Hello"
${NSD_CB_AppendString} $"World"
${NSD_CB_SetSelectionIndex} $0 0
$"EDIT" "" $0
NSD_Edit_SetReadOnly} $1 1


IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 15th January 2021, 22:57   #3
Junior Member
Join Date: Feb 2013
Posts: 11
Thanks a lot, especially for your example!
nashtor 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