|
-
March 29th, 1999, 07:10 AM
#1
CRichEditCtrl - How to Scroll to a line
Hi,
I am sure I'm missing something.
I implemented a "find" on a Rich Edit control and I want to verify that the "found" word is visible.
I see how to get the current line and the first visible line, but how can I get the LAST VISIBLE LINE to know if the control needs scrolling.
I tried to get it using the EM_CHARFROMPOS (with LPARAM being the bottom left corner of the control) but it crashed the application. (in Win98)
Any help will be appreciated.
Thanks,
Eli
-
March 29th, 1999, 10:36 AM
#2
Re: CRichEditCtrl - How to Scroll to a line
What I did to do this was:
I got the client rectangle, and the character height and determined how many lines could fit in the control. them I
went to the topLine + HowManyLines and got the line length of that line. that is my last pos
//this code is old and I forget what I was doing, basikally the algorithm is as above. Good luck.
CRichEditCtrl &Ctrl = GetRichEditCtrl();
CRect clientRect;
GetClientRect(&clientRect);
CPaintDC dc(this);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
ReleaseDC((CDC *) &dc);
CSize m_cellSize;
m_cellSize.cx = tm.tmAveCharWidth;
m_cellSize.cy = tm.tmHeight + tm.tmExternalLeading;
LPCSTR str = (LPCSTR) malloc(3000);
LRESULT p = ::SendMessage( GetSafeHwnd(), // handle of destination window
EM_GETFIRSTVISIBLELINE, // message to send
(WPARAM) 0, // first message parameter
(LPARAM) 0 );
// Determine first and last visible lines
// (first and last may be partial)
int i = p;
int last = clientRect.Height()/m_cellSize.cy + 2 + i;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|