901210-从滚动视图中消除闪烁 [英] 901210 - removing flicker from a scrollview

查看:90
本文介绍了901210-从滚动视图中消除闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 在我的应用程序中,该视图派生自CScrollView.通常需要在处理用户事件后重新绘制视图.为了消除闪烁,我想使用内存DC,以便在其上进行绘制,最后将其复制到客户区.我创建与客户端大小的内存DC.这导致图纸限制了客户的尺寸.例如,如果整个滚动视图为1000x1000,并且客户端大小为100x100(通过滚动视图),则不会绘制超出矩形(0、0、100、100)的任何内容.我不想创建与整个滚动视图一样大的内存DC.它会消耗大量内存,其中大部分不在其可见部分内.
我该如何实施?
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆