Old 7th March 2012, 15:42   #1
developer_jim
Junior Member
 
Join Date: Mar 2012
Posts: 2
Selecting or highlighting text in a textbox

Hello

I am working on an installer that uses NSIS with MUI2 and nsDialogs. On one of the pages we have textboxes and if the user input into those is invalid, I don't let the user continue.

In the case that the user's entry is invalid, I set the focus back to the offending textbox. When I set the focus, I would like to also highlight the text within that textbox. How do I highlight said text?

I have looked through the nsDialog documentation to no avail. I have also looked through the code for the MUI2 Directory Page whose textbox starts focused with its text highlighted. This did not help either.

Here is a snippet of my leave function for that particular page.

code:
Function leavePage
StrLen $5 $entry
${If} $5 != 2
messageBox MB_OK "Please enter a valid entry."
${NSD_SetFocus} $editBox
Abort
${EndIf}
FunctionEnd

developer_jim is offline   Reply With Quote
Old 7th March 2012, 15:53   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
code:
SendMessage $editBox ${EM_SETSEL} 0 -1
Stu
Afrow UK is offline   Reply With Quote
Old 7th March 2012, 17:14   #3
developer_jim
Junior Member
 
Join Date: Mar 2012
Posts: 2
That works perfectly. Thanks.
developer_jim 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