How to set the position of the blinking text cursor in a CEdit box.
-
Hi, I am doing some GUI dialogs in MFC. The problem goes like this: I have a parent dialog which can create a modeless child "keyboard" dialog,with some special prescribed keys. The user is suppose to click on keys on the "keyboard" dialog and the input is suppose to appear on an Edit box on the parent dialog. The issue is that I want the user to have the freedom of using both the physical keyboard and the "Keyboard" dialog. So, I tried to use SetFocus() onto the Parent's Edit box after hitting keys on the "Keyboard" dialog. The problem is that the after SetFocus() is issued, the blinking text cursor is always at the beginng left end of the Edit box regardless of whether there is any text in the edit box. This poses a problem when the user changes to using the physical keyboard since text will be input at the beginning of the current text rather than from the end of the text in the Edit box. So my question is how do I set the position of the blinking text cursor to the end of the text after SetFocus()? Thanks alot! :-D
-
Hi, I am doing some GUI dialogs in MFC. The problem goes like this: I have a parent dialog which can create a modeless child "keyboard" dialog,with some special prescribed keys. The user is suppose to click on keys on the "keyboard" dialog and the input is suppose to appear on an Edit box on the parent dialog. The issue is that I want the user to have the freedom of using both the physical keyboard and the "Keyboard" dialog. So, I tried to use SetFocus() onto the Parent's Edit box after hitting keys on the "Keyboard" dialog. The problem is that the after SetFocus() is issued, the blinking text cursor is always at the beginng left end of the Edit box regardless of whether there is any text in the edit box. This poses a problem when the user changes to using the physical keyboard since text will be input at the beginning of the current text rather than from the end of the text in the Edit box. So my question is how do I set the position of the blinking text cursor to the end of the text after SetFocus()? Thanks alot! :-D
What about
CWnd::SetCaretPos
?Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hi, I am doing some GUI dialogs in MFC. The problem goes like this: I have a parent dialog which can create a modeless child "keyboard" dialog,with some special prescribed keys. The user is suppose to click on keys on the "keyboard" dialog and the input is suppose to appear on an Edit box on the parent dialog. The issue is that I want the user to have the freedom of using both the physical keyboard and the "Keyboard" dialog. So, I tried to use SetFocus() onto the Parent's Edit box after hitting keys on the "Keyboard" dialog. The problem is that the after SetFocus() is issued, the blinking text cursor is always at the beginng left end of the Edit box regardless of whether there is any text in the edit box. This poses a problem when the user changes to using the physical keyboard since text will be input at the beginning of the current text rather than from the end of the text in the Edit box. So my question is how do I set the position of the blinking text cursor to the end of the text after SetFocus()? Thanks alot! :-D
You could do this:
CEdit *pEdit = static_cast<CEdit *>( GetDlgItem( IDC_THE_EDIT_BOX ) );
int iLength = pEdit->GetWindowTextLength();
pEdit->SetSel( iLength, iLength );-- gleat http://blogorama.nerdworks.in[^] --
-
What about
CWnd::SetCaretPos
?Prasad Notifier using ATL | Operator new[],delete[][^]
That may cause a visual indication, but the underlying edit control will maintain its last insertion point. Peace!
-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles -
Hi, I am doing some GUI dialogs in MFC. The problem goes like this: I have a parent dialog which can create a modeless child "keyboard" dialog,with some special prescribed keys. The user is suppose to click on keys on the "keyboard" dialog and the input is suppose to appear on an Edit box on the parent dialog. The issue is that I want the user to have the freedom of using both the physical keyboard and the "Keyboard" dialog. So, I tried to use SetFocus() onto the Parent's Edit box after hitting keys on the "Keyboard" dialog. The problem is that the after SetFocus() is issued, the blinking text cursor is always at the beginng left end of the Edit box regardless of whether there is any text in the edit box. This poses a problem when the user changes to using the physical keyboard since text will be input at the beginning of the current text rather than from the end of the text in the Edit box. So my question is how do I set the position of the blinking text cursor to the end of the text after SetFocus()? Thanks alot! :-D
The
SetSel(...)
solution is the best, IMHO, although I question the habit of casting the return ofCWnd::GetDlgItem(...)
unless you really know what you are doing... You should investigate theMA_NOACTIVATE
return value from processing theWM_MOUSEACTIVATE
message. I believe that is how you can get an on-screen keyboard to not cause kill focus events to be sent to another window when it is is being used. You may have to rely on mouse position as opposed to button click events if you do this. Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles -
You could do this:
CEdit *pEdit = static_cast<CEdit *>( GetDlgItem( IDC_THE_EDIT_BOX ) );
int iLength = pEdit->GetWindowTextLength();
pEdit->SetSel( iLength, iLength );-- gleat http://blogorama.nerdworks.in[^] --
This is indeed a great method! works nice n sweet. Thanks.:-D
-
What about
CWnd::SetCaretPos
?Prasad Notifier using ATL | Operator new[],delete[][^]
Thanks for the sugestion. At least I now know that blinking cursor is called a caret. :laugh:
-
The
SetSel(...)
solution is the best, IMHO, although I question the habit of casting the return ofCWnd::GetDlgItem(...)
unless you really know what you are doing... You should investigate theMA_NOACTIVATE
return value from processing theWM_MOUSEACTIVATE
message. I believe that is how you can get an on-screen keyboard to not cause kill focus events to be sent to another window when it is is being used. You may have to rely on mouse position as opposed to button click events if you do this. Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesThanks for your input. the SetSel method has worked well for me. Dint investigate the WM_MOUSEACTIVATE method as using mouse position may complicated matters for me. anyway, thanks!;)