Moving Cursor position in Edit box !
-
How can i change the cursor position in a text box ? My month article: Game programming by DirectX by Lan Mader. Please visit in: www.geocities.com/hadi_rezaie/index.html Hadi Rezaie
-
How can i change the cursor position in a text box ? My month article: Game programming by DirectX by Lan Mader. Please visit in: www.geocities.com/hadi_rezaie/index.html Hadi Rezaie
I assume you mean the caret, not the cursor, and you want to do so programmatically. If so, the best way to do so is to sublcass the edit box which allows you to control the positioning of the caret. However, you should be aware that this is not a trivial undertaking as you need to be knowledgeable of text sizing issues. The caret itself can also be problamatic to deal with. "Any clod can have the facts, but having opinions is an art." Charles McCabe, San Francisco Chronicle
-
How can i change the cursor position in a text box ? My month article: Game programming by DirectX by Lan Mader. Please visit in: www.geocities.com/hadi_rezaie/index.html Hadi Rezaie
Actually, I need to correct myself. I checked and the CEdit api does have a PosFromChar method So you could do something like this...
myedit.SetCaretPos( myedit.PosFromChar( index ));
That was not there the last time I had to do the same thing. "Any clod can have the facts, but having opinions is an art." Charles McCabe, San Francisco Chronicle
-
How can i change the cursor position in a text box ? My month article: Game programming by DirectX by Lan Mader. Please visit in: www.geocities.com/hadi_rezaie/index.html Hadi Rezaie
You can do it using the
SetCaretPos()
method. Regards, Brian Dela :-) "There should be an amendment to the constitution, that every president must be examined for paranoia before moving into office." - peterchen -
How can i change the cursor position in a text box ? My month article: Game programming by DirectX by Lan Mader. Please visit in: www.geocities.com/hadi_rezaie/index.html Hadi Rezaie
void CEdit::SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE);
void CEdit::SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE);To set the cursor at the end of the text within the control...
// With associated member variable to the edit control and to the content
UpdateData();
m_EditControl.SetSel(m_EditContent.GetLength(), m_EditContent.GetLength());// With associated member variable to the content
UpdateData();
((CEdit *) GetDlgItem(IDC_EDIT))->SetSel(m_EditContent.GetLength(), m_EditContent.GetLength());If you want to use the first function you have to set the starting position in the low-order word and and the ending position in the high-order word...thus
// With associated member variable to the edit control and to the content
UpdateData();// Set position
DWORD dwSelection = m_EditContent.GetLength();
dwSelection |= m_EditContent.GetLength() << 16;m_EditControl.SetSel(dwSelection);
// With associated member variable to the content
UpdateData();// Set position
DWORD dwSelection = m_EditContent.GetLength();
dwSelection |= m_EditContent.GetLength() << 16;((CEdit *) GetDlgItem(IDC_EDIT))->SetSel(dwSelection);
Ciao, Andreas "Software is like sex, it's better when it's free." - Linus Torvalds