- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
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
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could try sendinga messageto the edit boxmessage
iret =
SendDlgItemMessage(dlg%hWnd,IDC_NAME,WM_LBUTTONDOWN, param)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anthony
Thanks for your suggestion.
Between you and Greg I have managed to get my coding working.
![](/skins/images/45C6C2D737ED71F4C51F0145C8CB1E9C/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page