901210-从滚动视图中消除闪烁 [英] 901210 - removing flicker from a scrollview
问题描述
我该如何实施?
thx
您需要(从滚动位置中)找出要显示图形的哪一部分,然后将其映射到实际位于位置[0,0,100,100].例如,如果水平滚动为+50,垂直滚动为+100,则需要将逻辑图片[100、50、200、150]绘制到DC上的[0、0、100、100].只是数学问题.
通常是这样的
1.创建一个包含要绘制的原始内容(位图,形状或其他内容)的源DC
2.根据您的滚动条位置,使用BitBlt函数将所需数量的像素从源DC复制到客户端DC(其大小为GetClientRect).
希望这会对您有所帮助.
jkchan
http://cgmath.blogspot.com
hi
in my application the view is derived from CScrollView. it''s usually required to redraw the view after handling user events. for removing flicker, i want to use a memory DC, so that the drawings occur on it and at last i copy it to the client area. i create the memory DC with size of the client. this causes the drawings limit to the size of the client. for example if the whole scroll view is 1000x1000 and the client size is 100x100 by scrolling the view nothing is drawn beyond rectangle (0, 0, 100, 100). i don''t want to create a memory DC as big as the whole scroll view. it consumes a large amount of memory most of it is out of the visible part of it.
how can i implement it?
thx
You need to figure out (from the scroll positions) which part of your drawing is to be displayed, and then map that onto the rectangle that is physically at location [0, 0, 100, 100]. For example, if horizontal scroll is +50 and vertical scroll is +100, then you need to draw the logical picture [ 100, 50, 200, 150] onto the DC at [0, 0, 100, 100]. It''s just a matter of mathematics.
it is usually like this
1. create a source dc which contains the original thing to draw(bitmap,shape or whatever)
2. depends upon your scroll bar position, use BitBlt function to copy the required amount of pixels from source DC to your client dc(whose size is GetClientRect)..
hopes this will help you somewhat.
jkchan
http://cgmath.blogspot.com
这篇关于901210-从滚动视图中消除闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!