How to obtain column number in a file
-
I've created MFC application with Doc/View support. My view class is inherited from CRichEditView class. I need to obtain the row and column number of the current cursor position. The following function gets the current line number. GetRichEditCtrl().LineFromChar(-1); The question is "How can I get the column number"? The ideal example is the Visual C++ IDE that shows the row and column of the cursor in the status bar. The row and column updates whenever the cursor changes.
-
I've created MFC application with Doc/View support. My view class is inherited from CRichEditView class. I need to obtain the row and column number of the current cursor position. The following function gets the current line number. GetRichEditCtrl().LineFromChar(-1); The question is "How can I get the column number"? The ideal example is the Visual C++ IDE that shows the row and column of the cursor in the status bar. The row and column updates whenever the cursor changes.
A quite complicated solution : Use GetSel to retrieve the caracter number. Make a loop on LineFromChar with parameter the character number, which you decrement until LineFromChar changes. Then, the first number minus the final one should give you the pos.
long int i,j;
m_RichEditCtrl.GetSel(&i,&j);
i=(i~RaGE();