-
October 5th, 2009, 10:07 AM
#1
Keeping the cursor in an CEdit box
Hi All..
I have a simple dialog app which has 1 single line edit box and a couple of buttons on it.
Id like to place the cursor in it when the app opens, but most importantly, the edit box shouldn’t loose the cursor, even it the user clicks a 'reset' button. The idea being that whenever the user starts to type, the cursor will be in the edit box.
Your help would be very appreciated.
Cheers
Phill
-
October 5th, 2009, 10:25 AM
#2
Re: Keeping the cursor in an CEdit box
Use SetFocus() in the OnInitDialog()
Be sure to return false from the dialog or it won't work.
In the on-click handler for the reset button (and any other buttons), set the focus back to the editcontrol also.
You could force the editcontrol to always have focus by overriding the OnSetFocus() and generically reforcing focus to the editcontrol, but this will mean normal tab-behaviour will fail. A user won't be able to tab to the reset button to 'click' it that way in case they have no mouse (or prefer not to use a mouse).
-
October 5th, 2009, 10:43 AM
#3
Re: Keeping the cursor in an CEdit box
You can use the idea described by Reubens. But you should not code such that Edit control "always" have focus. That is bad design!
You should reset all controls, when user clicks on 'Reset' and then set focus on this edit control. But user should be allowed to move between controls.
And for dialog box, you should go to resource editor and set the tab arrangement. Just press Ctrl+D to set the arrangement.
-
October 5th, 2009, 12:37 PM
#4
Re: Keeping the cursor in an CEdit box
Thanks Ajay..
I'll bare it in mind.
-
October 5th, 2009, 12:40 PM
#5
Re: Keeping the cursor in an CEdit box
Originally Posted by Phill Heald
Thanks Ajay..
I'll bare it in mind.
Did you mean bear?
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
|