teky 的 blog
在vck中学习,在vck中进步~
<2006年6月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678
公告

留言簿(11)

随笔档案

文章分类

文章档案

相册

Windows Mobile

我的好友

朋友创业,其路漫漫

搜索

最新评论

阅读排行榜

评论排行榜

 
VC知识库BLOG   首页  新随笔  联系  聚合  登录 
  随笔-30 文章-17 评论-94 Trackbacks-4

和MFC一样,在smartphone上绘制的时候也会遇到背景闪烁的问题

在MFC上解决方法一般是三个步骤:

1.屏蔽系统自己的背景刷新(填充背景色)

BOOL XXXX::OnEraseBkgnd(CDC* pDC)
{
   // Left empty, avoids undesirable flickering
  return true;
}

注意:如果屏蔽了这里,一定要自己处理整个的背景刷新


2.在onpaint ondraw中贴图的时候,利用缓冲,整体绘制

void Onpaint()
{
  CDC memdc;
  //....
}

3.尽量进行局部刷新

InvalidateRect(…);


Smartphone上处理背景闪烁,也是相同的步骤

1,屏蔽系统背景绘制

protected override void OnPaintBackground(PaintEventArgs paintg)
{
 // Left empty, avoids undesirable flickering
}

把上面代码写入自己的FORM中就可以,一样需要自己处理整个的背景刷新


2.在中贴图的时候,利用缓冲,整体绘制

private void Mainlist_Paint(object sender, PaintEventArgs e)
 {
     Graphics gxOff; //缓冲Graphics
     if(bkscreen==null) //BITMAP bkscreen
     bkscreen = new Bitmap(ClientSize.Width, ClientSize.Height);

     gxOff = Graphics.FromImage(bkscreen);
     gxOff.Clear(this.BackColor);
     gxOff.DrawImage(bkImage, 0, 0);
     //最后整体贴入设备上
     e.Graphics.DrawImage(bkscreen, 0, 0);
}

3.尽量进行局部刷新

this.Invalidate(new Rectangle(0, 34, 30, 170));
this.Update();


利用上面的方法就能很好的解决背景闪烁的问题了.

posted on 2006-06-13 10:16 teky 阅读(2109) 评论(4)  编辑 收藏
Comments
  • # re: Smartphone上解决背景闪烁问题
    紫水晶
    Posted @ 2006-06-13 10:20
    哦,最烦重绘,弄不清楚
  • # re: Smartphone上解决背景闪烁问题
    zuilang
    Posted @ 2006-06-13 15:10
    你是用evc4.0开发吗?在做些什么呢?
  • # re: Smartphone上解决背景闪烁问题
    teky
    Posted @ 2006-06-13 15:42
    to zuilang:
    没有用EVC,用的是.net2005+CF1
    作一些娱乐性软件

  • # re: Smartphone上解决背景闪烁问题
    ERICSHAN
    Posted @ 2006-06-25 20:33
    在pc上还经常用到memdc,先把要更新的painting画到memdc然后一次性bitblt到device的dc上,是不是也可以在smartphone上试试
标题  
姓名  
主页
验证码 *
内容   
  登录  使用高级评论  Top
[使用Ctrl+Enter键可以直接提交]