Archive: Selecting or highlighting text in a textbox


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.

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

SendMessage $editBox ${EM_SETSEL} 0 -1
Stu

That works perfectly. Thanks.