|
-
August 15th, 2011, 09:50 AM
#1
Setting cursor in a dialog's edit-ctrl
I want to set the cursor into an edit-ctrl preferably to a specific position. As far as I understood I have to set the focus to this ctrl and then doing a selection in that box. As SetFocus() is said not to work in dialogs properly (see http://blog.m-ri.de/index.php/2007/0...wm_nextdlgctl/), I used WM_NEXTDLGCTL to achieve that. EM_SETSEL with startpos equal to endpos shall provide positioning. Does anyone sees an error in the following which does not work as expected?
Code:
SendMessage(WM_NEXTDLGCTL, WPARAM(GetDlgItem(Item)->m_hWnd), LPARAM(LOWORD(TRUE)));
GetDlgItem(Item)->SendMessage(EM_SETSEL, WPARAM(INT(VarValue.length())), LPARAM(INT(VarValue.length())));
BTW: Item is the ID of the ctrl. VarValue the string being on display in the ctrl.
Many Thanks in advance for any reply!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|