Re: CEditView and linie numbers
Hi
I found it on GodeGuru, so no panic
ON_UPDATE_COMMAND_UI(ID_INDICATOR_CURPOS, OnUpdateCurPosIndicator)
void CMainFrame::OnUpdateCurPosIndicator(CCmdUI *pCmdUI)
{
CString strCurPos;
int nLineNum, nColNum;
int nSelStart, nSelEnd;
// you're going to have to get a pointer
// to the edit control in the view
m_wndEditCtrl->GetSel(nSelStart, nSelEnd);
nLineNum = m_wndEditCtrl->LineFromChar(nSelStart);
nColNum = nSelStart - m_wndEditCtrl->LineIndex(nLineNum);
strCurPos.Format(ID_INDICATOR_CURPOS,
nLineNum+1,
nColNum+1);
m_wndStatusBar.SetPaneText(
m_wndStatusBar.CommandToIndex(ID_INDICATOR_CURPOS),
strCurPos);
}
"Laurs" wrote:
Hi
Thanks. I see both proposals as possible, but have ended with a more lazy
version. I just write the line number and caracter position (L,P) in a Pane
in my CStatusBar.
Only one thing is missing. When I move the caret(text cursor) with the
keyboard or mouse I get no event.
How can I get a notification for that in in my messagehandler:
BEGIN_MESSAGE_MAP(MICVIWTXT, GICVED)
ON_WM_HSCROLL()
ON_WM_VSCROLL()
END_MESSAGE_MAP()
None of these
ON_WM_PAINT()
ON_WM_SETCURSOR()
ON_WM_KEYDOWN()
gives me any help.
Best regards
Laurs
"Joseph M. Newcomer" wrote:
There are three approaches:
(a) write your own edit control
(b) create your control borderless. Put a borderless control next to it, in which you put
the line numbers. Keep the two controls "in sync" as you scroll the edit control (it
isn't impossible, but is tedious)
(c) use rich edit, make the line numbers protected, keep them updated as you add or remove
lines (really tedious, as it turns out, but I've been told it is comparable to (b))
joe
On Fri, 12 Dec 2008 01:39:00 -0800, Laurs <Laurs@discussions.microsoft.com> wrote:
My apllication should display line numbers in a MDI applications Text windows
view. Each line should have its own line number, like:
00001 Some text
00002 Next line with text
00003 Another ....
Wordwrap is not on
Any hint?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm