Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28593 Discussions

Highlighting text in an edit box after setting focus to the box

Neil_H_
Beginner
399 Views
I am using SetFocus to choose an edit box for input using the coding:
hwndFocus = GetDlgItem( dlg%hwnd, IDC_NAME )
iret = SetFocus( hwndFocus )
This successfully puts the focus in the selected edit box for input. However it does not necessarily select the text that is already in the box - it seems to depend on what previously happened in the edit box (even to the point of remembering the cursor position within the text). Is there some way of selecting all the text, as it would have done if I had been able to tab to the box?

Message Edited by neil.halsall@uk.thalesgroup.com on 02-08-2005 07:31 AM

0 Kudos
4 Replies
anthonyrichards
New Contributor III
399 Views
You could try sendinga messageto the edit boxmessage

iret =

SendDlgItemMessage(dlg%hWnd,IDC_NAME,WM_LBUTTONDOWN, param)

0 Kudos
gregscvf
Beginner
399 Views
I usually use this in the callback:
!Set the focus in the edit box and selectcomplete text
hwnd = GetDlgItem(dlgIn%hwnd, ControlID)
hwnd = SetFocus(hwnd)
IVAL = DlgSendCtrlMessage (dlgIn, ControlID, EM_SETSEL, 0, -1)
Different constants may be used for various cursor locations.
Greg
0 Kudos
Neil_H_
Beginner
399 Views
Hi Greg,
Many thanks for the help. I have used your suggestion, and it works in 99% of the cases. There seems to be a case when it does not work and I cannot quite put my finger on it. I think that it is after I have just redisplayed the text in several edit boxes, and then used SetFocus (and sent the EM_SETSEL message)to go to one of those boxes for input. On the other hand it couldjustbe bad coding on my part. I will get to the bottom of iteventually.
Thanks again,
0 Kudos
Neil_H_
Beginner
399 Views
Hi Anthony
Thanks for your suggestion.
Between you and Greg I have managed to get my coding working.
0 Kudos
Reply