Click here to Skip to main content
15,905,504 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralShared Directory Pin
Thierry2-Dec-99 21:57
Thierry2-Dec-99 21:57 
GeneralRE: Shared Directory Pin
Serguei Velikevitch3-Dec-99 4:27
sussSerguei Velikevitch3-Dec-99 4:27 
GeneralRE: RE: Shared Directory Pin
Ghazi /Dundas3-Dec-99 5:14
sussGhazi /Dundas3-Dec-99 5:14 
GeneralRE: Shared Directory Pin
ac2713-Dec-99 8:26
sussac2713-Dec-99 8:26 
GeneralRE: RE: Shared Directory Pin
Anonymous3-Dec-99 8:31
suss Anonymous3-Dec-99 8:31 
GeneralRE: RE: Shared Directory Pin
Thierry6-Dec-99 19:48
Thierry6-Dec-99 19:48 
QuestionHow to get the caret's position in a richedit? Pin
Thömmi25-Nov-99 0:43
Thömmi25-Nov-99 0:43 
AnswerRE: How to get the caret's position in a richedit? Pin
Peter Zajac25-Nov-99 6:56
Peter Zajac25-Nov-99 6:56 
Thömmi,

You are actualy very close to the solution to this problem.

To get the caret position within current line you will have to look at two CRichEditCtrl member functions.

GetSel - if you are not handling the 'EN_SELCHANGE' notification than use this function to get current position of the caret. Vales returned contain character position from the beginning of the rich edit string.

Use the LineIndex function to get total number of characters before current line.

By subtracting chars before line from the caret position you will get column index in current line.

void CRichEditTestDlg::OnSelchangeRichedit(NMHDR* pNMHDR, LRESULT* pResult)
{
SELCHANGE *pSelChange = reinterpret_cast<selchange *="">(pNMHDR);

CString tempStr;
tempStr.Format( "ln: %d, col: %d",
m_richEdit.LineFromChar( -1 ),
pSelChange->chrg.cpMin - m_richEdit.LineIndex( -1 ));
SetDlgItemText( IDC_POS, tempStr );

*pResult = 0;
}

Peter Zajac
Dundas Software

==================
The original message was:

Hi all,

I am writing a MDI application, which views are derivated
by CRichEditView. In the status bar, I want to display the
current position of the caret. The line number is easy to get,
just call GetRichEditCtrl().LineFromChar(-1), but how to determine the column?

Thanks in advance,
Thömmi

QuestionHow to get the caret's position in a richedit? Pin
Thömmi25-Nov-99 0:43
Thömmi25-Nov-99 0:43 
AnswerRE: How to get the caret's position in a richedit? Pin
Dean Edmonds8-Dec-99 13:45
sussDean Edmonds8-Dec-99 13:45 
Generalredirect cerr to a string stream Pin
hhuynh0124-Nov-99 10:01
hhuynh0124-Nov-99 10:01 
GeneralRE: redirect cerr to a string stream Pin
Alex Gorev26-Nov-99 10:24
Alex Gorev26-Nov-99 10:24 
Generalremove scroll bars in Grid Control Pin
Jason24-Nov-99 6:33
Jason24-Nov-99 6:33 
GeneralRE: remove scroll bars in Grid Control Pin
Chris Maunder27-Nov-99 17:04
cofounderChris Maunder27-Nov-99 17:04 
GeneralHtmlHelp in multi-threaded app Pin
Martin Speiser23-Nov-99 21:03
Martin Speiser23-Nov-99 21:03 
GeneralRE: HtmlHelp in multi-threaded app Pin
Member 105424-Nov-99 2:34
Member 105424-Nov-99 2:34 
GeneralRE: RE: HtmlHelp in multi-threaded app Pin
Martin Speiser25-Nov-99 0:50
Martin Speiser25-Nov-99 0:50 
General[Q]Using the MAPI Pin
Member 431523-Nov-99 18:04
Member 431523-Nov-99 18:04 
QuestionMDI custom tile with open/close of childeren? Pin
Michael Peters19-Nov-99 19:45
Michael Peters19-Nov-99 19:45 
AnswerRE: MDI custom tile with open/close of childeren? Pin
Martin Speiser19-Nov-99 23:51
Martin Speiser19-Nov-99 23:51 
GeneralRE: RE: MDI custom tile with open/close of childeren? Pin
Martin Speiser20-Nov-99 0:04
Martin Speiser20-Nov-99 0:04 
Generalmpeg extraction Pin
kai23-Nov-99 5:15
kai23-Nov-99 5:15 
QuestionOnDraw, how can I get the rectangle that is painting ? Pin
Braulio Diez22-Nov-99 22:48
sussBraulio Diez22-Nov-99 22:48 
AnswerRE: OnDraw, how can I get the rectangle that is painting ? Pin
Henk Devos23-Nov-99 9:33
Henk Devos23-Nov-99 9:33 
AnswerRE: OnDraw, how can I get the rectangle that is painting ? Pin
Anonymous24-Nov-99 14:56
suss Anonymous24-Nov-99 14:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.