How to handle OnVScroll() and OnHScroll()
wtflanders@micron.com
Thursday, November 14, 1996
Environment: NT 4.0, VC++ 4.2flat
Hi,
Could anyone help me find some info on how to handle OnVscroll() and
OnHscroll() to output text? I'm sure this has been done a thousand
times, I've just avoided it... not any longer.
Specifically, I've derived a class from CWnd (CScrollView or CEditView
will not work) from which I will display text (much like MSVC's build
and debug windows in the output bar.) In fact, I'm creating my own
output bar using Stingray's SECTabWnd from their Objective toolkit
1.1.
My OnPaint() contains:
{
CPaintDC dc(this);
CRect rectClient;
GetClientRect(rectClient);
dc.DrawText(m_infoText, rectClient,
DT_LEFT | DT_TOP |DT_NOCLIP );
}
where m_infoText is a CString. All I want to do is dump text into m_infoText
and output it into the window, with enabled scrollbars if necessary.
any examples out there?
Thanks,
Bill
Mike Blaszczak -- mikeblas@nwlink.com
Friday, November 15, 1996
At , wtflanders@micron.com wrote:
>Environment: NT 4.0, VC++ 4.2flat
>Could anyone help me find some info on how to handle OnVscroll() and
>OnHscroll() to output text?
What do you mean by "output text"? To which device?
When referring to a window, most people say "paint text". They say
that because the only time it is guaranteed to be efficient _and_
appropriate to draw something is in response to a WM_PAINT message.
You can do it at other times, but it's not quite so easy and just
causes trouble in the long run.
If you're referring to another output device, like a printer, or
writing to serial I/O devices, you can do the drawing any time
you like. But I can't understand why you'd want to print or
send stuff to the modem in response to the user playing with
a scrollbar.
>Specifically, I've derived a class from CWnd (CScrollView
>or CEditView will not work)
Do you really mean that you want to draw the text to your
window? CScrollView certainly works for this, but I'm still not
sure I understand why you'd want to draw something in response
to the user scrolling. The HEXVIEW sample in my book shows how
to draw text in a CScrollView and have the scroll bars let you
move around in the text.
>All I want to do is dump text into m_infoText
>and output it into the window, with enabled scrollbars if necessary.
You'll need to measure before you paint and decide
what to do about the scrollbars as a result of your measurements.
You'll need to find the position of the scrollbars and offset
your drawing accordingly.
You might want to avoid drawing some parts of your output if its
not visible--that can save lots (and lots) of time and make your
application have a very snappy response.
.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.
| Вернуться в корень Архива
|