Old 2nd August 2019, 11:43   #1
DivyaArun
Junior Member
 
Join Date: Jul 2019
Posts: 30
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}
DivyaArun is offline   Reply With Quote
Old 2nd August 2019, 16:25   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,163
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:

Quote:
!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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 8th August 2019, 11:20   #3
DivyaArun
Junior Member
 
Join Date: Jul 2019
Posts: 30
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
DivyaArun is offline   Reply With Quote
Reply
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