📄 wpw_mfc_cscrollv_95.html
字号:
<HTML>
<HR><A NAME=MFC_CSCROLL_VIEW_SIZE>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Determine the size of CScrollView Doc</H4><PRE>
In article <3rq35p$ojq@falstaff.css.beckman.com>
heffron@falstaff.css.beckman.com "Matt Heffron" writes:
> I'm trying to implement an SDI app where the view of the
> document is based on CScrollView, but the problem is that I
> don't know the size of the document until the Display
> routine of my Document is completed (i.e. it wraps text to
> never exceed the right edge of the view's client area).
> If I call SetScrollSizes after the Display function (in the
> OnDraw handler), the view's scroll bar appear, the display
> is re-drawn (presumably, because the appearance of the
> scroll bar has invalidated part of the client area, forcing
> a re-draw), but the view will not scroll. Interaction with
> the scroll bar is ignored, and the view is always displayed
> from the top.
> Does anyone have any ideas/advice about why I can't scroll
> the view, and the "proper" way to deal with a docment whose
> size can only be determined by displaying it? (Also, how to
> deal with the double-display when the scroll bar appears?)
>
One of my favourite tricks in this situation is to have a boolean
variable as an argument of my drawing code and return a CSize or SIZE.
CSize MyDrawingFunction( CDC *pDC, BOOL bDraw )
{
// all drawing code in here
}
If bDraw is set TRUE then the code draws and returns the Size it has drawn.
If FALSE then it just returns the Size without drawing.
Then you can use it to draw or just determine the size.
Dave
--
+---------------------------+-----------------------------------+
| Dave Webber dave@musical.demon.co.uk |
| Author of MOZART, the Windows 3.1 shareware Music Processor |
| and member of the Association of Shareware Professionals |
+---------------------------+-----------------------------------+
</PRE>
<HR><A NAME=MFC_CSCROLL_YOU_OWN>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Write your own CScrollView</H4><PRE>
In article <3tc8sl$lvg@crl7.crl.com>, hermes@crl.com says...
>
>
>I have an application that needs to display some large amount of text.
>What I'd like to be able to do is create a non scrolling view, create
>the scroll bars, catch the messages as to where in the mound of text
>to display and then draw it.
>How do I write my own CScrollView class?
>Any pointers would be appreciated.
>thanks,
>Don Hermes
>Novato, CA
>hermes@crl.com
Ah, a good question. I had to do the same thing. What I found
was that if you START with CScrollView and then try to override the
scrollbar behavior, you're in for headaches for a long time. Forget
CScrollView.
Rather, use CView, and Scrollbars manually by the member
functions of CView, and catch the WM messages. This way you can "reduce"
MFC to a "dumb" Windows SDK-like application.
Note, however, that the smooth and automatic scrolling associated
with CScrollView will be history for you. You'll have to do everything
manually, and if you want a real smooth scroll like CScrollView has,
you may find yourself having to BitBlt your screen data in addition to
mathematically recalculating where in your text you are. But it's worth
every penny to dump CScrollView.
Regards,
--
--------------- David J. Straley -----------------
------------ djs@abiss.smst290.att.com -------------
</PRE>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -