Skip to content
⌘ NSIS Forum Archive

label alignment

5 posts

zivha#

label alignment

Hi,

I am trying to figure out how to place a static text label in a dialog and have it centered (i.e. something like CreateLabel with width 100% but tell the control to align the text to the center).

Thanks!
JohaViss#
If you are using nsDialogs, it is simple:

${NSD_CreateLabel} 0 190 100% 20 "Test"  
pop $lblTest
${NSD_AddStyle} $lblTest ${SS_CENTER}

Look here for more styles:


Regards,
Johan
Animaether#
given the handle to your label control in $hwnd, use...
${NSD_AddStyle} $hwnd ${SS_CENTER} 
...before displaying the dialog.

Example:
!include "nsDialogs.nsh"
OutFile "$%temp%\temp.exe"
var dialog
var hwnd
var null
Var hUpDown
Page custom Test
Function Test
    nsDialogs::Create 1018
        Pop $dialog
    ${NSD_CreateLabel} 0 0 100% 20% "This is a test$\nThis is only a test."
        Pop $hwnd
        ${NSD_AddStyle} $hwnd ${SS_CENTER}
    nsDialogs::Show
FunctionEnd
Section
SectionEnd 
For more Static Control Styles, see:
To create a static control using the CreateWindow or CreateWindowEx function, specify the STATIC class, appropriate window style constants, and a combination of the following static control styles.
Animaether#
odd.. JohaViss's reply suddenly popped up and inserted itself in the middle.. silly forums 🙂
'll stick it in the the FAQ as well, gotta add that updown control thing anyway