Skip to content
⌘ NSIS Forum Archive

How to put red border around textbox in NSIS

3 posts

DivyaArun#

How to put red border around textbox in NSIS

Hi,

I have a text field. I would like to add red border to the text control. Can we use {SS_BLACKRECT} with some other color though the fault is black. Is there any other method?

${NSD_CreateText} 0 20u 144u 12u $R0
Pop $TxtGD
${NSD_AddStyle} $TxtGD ${SS_BLACKRECT}
Anders#
SS_BLACKRECT is a Static control style.

Windows does not allow you to modify the border colors of standard controls, you would need a custom plug-in.

You can put another control behind it though:

!include nsDialogs.nsh
Function MyCustomPageCreate
nsDialogs::Create 1044
Pop $0

${NSD_CreateText} 1u 20u 144u 12u "something"
Pop $1

${NSD_CreateLabel} 0u 19u 146u 14u ""
Pop $2
SetCtlColors $2 ff0000 ff0000

; If the above control is not accurate enough you can set the exact pixel size:
System::Call 'USER32::GetWindowRect(p$1, @r3)' ; NSIS 3+
System::Call '*$3(i.r4, i.r5, i.r6, i.r7)'
IntOp $6 $6 - $4
IntOp $7 $7 - $5
System::Call 'USER32::MapWindowPoints(p0, p$hwndParent, p$3, i 1)i.r9'
System::Call '*$3(i.r4, i.r5)'
!define PXBORDERSIZE 1
!define /math PXBORDERSIZEDOUBLE ${PXBORDERSIZE} * 2
IntOp $4 $4 - ${PXBORDERSIZE}
IntOp $5 $5 - ${PXBORDERSIZE}
IntOp $6 $6 + ${PXBORDERSIZEDOUBLE}
IntOp $7 $7 + ${PXBORDERSIZEDOUBLE}
System::Call 'USER32::SetWindowPos(p$2, p0, i $4, i $5, i $6, i $7, i 0x14)'

nsDialogs::Show
FunctionEnd
If you want to mark invalid input I would maybe use a red exclamation triangle icon instead...
DivyaArun#
Hi,

I tried an alternative solution by having a label at the same position with red color filled. And enabling/disabling the same based on my condition.

Thanks