请参考:http://blog.csdn.net/muchforest/archive/2007/08/13/1741079.aspx
问题!:给winform窗口加个风格 WS_CLIPCHILDREN? 具体怎么实现
 
问题2:对于GDI,用创建内存DC的方法就可以了? 具体怎么实现参考C#绘图双缓冲技术总结: http://community.csdn.net/Expert/PostNew.asp?room=5201但是这代码运行不了
  protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle rect = e.ClipRectangle;
            Bitmap bufferimage = new Bitmap(this.Width, this.Height);
            Graphics g = Graphics.FromImage(bufferimage);
            g.Clear(this.BackColor);
            g.SmoothingMode = SmoothingMode.HighQuality; //高质量
            g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
            foreach (IShape drawobject in doc.drawObjectList)
            {
                if (rect.IntersectsWith(drawobject.Rect))
                {
                    drawobject.Draw(g);
                    if (drawobject.TrackerState == config.Module.Core.TrackerState.Selected
                        && this.CurrentOperator == Enum.Operator.Transfrom)//仅当编辑节点操作时显示图元热点
                    {
                        drawobject.DrawTracker(g);
                    }
                }            }
            using (Graphics tg = e.Graphics)
            {
                tg.DrawImage(bufferimage, 0, 0);  //把画布贴到画面上
            }
        }

解决方案 »

  1.   


    主界面图片很多???是BackgroundImage ???还是Image ???要是这两个的话 没有办法改另:主窗体弄那么多图片干什么???控件背景???
      

  2.   

    BackgroundImage,Image都有,是MDI winform程序
      

  3.   

    using (Graphics tg = e.Graphics)
    {
        tg.DrawImage(bufferimage, 0, 0);  //把画布贴到画面上
    }改成 e.Graphics.DrawImage(bufferimage, 0, 0);  //把画布贴到画面上
    Bitmap bufferimage 可以定义成private,频繁新建总感觉不好
      

  4.   

    //给窗体添加WS_CLIPCHILDREN风格:[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
    public static extern int GetWindowLong(HandleRef hWnd, int nIndex);
    [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
    public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong);protected override void CreateHandle()
    {
    base.CreateHandle();
    int windowLong = (GetWindowLong(new HandleRef(this, this.Handle), -16));
    SetWindowLong(new HandleRef(this, this.Handle), -16, windowLong | WS_CLIPCHILDREN);
    }
      

  5.   

    你可以双缓冲绘图,不必自己使用Bitmap来绘制,在窗体初始的时候设置如下:this.DoubleBuffered = true;然后在Paint事件或OnPaint方法里正常编写绘图就行了。
    如果需要刷新窗体,只需要调用Invalidate。
      

  6.   

    你是图片太多闪,那没办法,双缓冲也只是用于在MouseMove 这类发生次数很多的事件的绘图中。
      

  7.   

    if (this.Visible && WindowState != FormWindowState.Minimized)
                {
                    int full_time_visible = timerInterval * picboxNetwork.Width / 1000;
                    Bitmap bm = new Bitmap(picboxNetwork.Width, picboxNetwork.Height, PixelFormat.Format16bppRgb555);
                    Graphics g = Graphics.FromImage((Image)bm);                //draw each line in the graph
                    DrawGraph(g, picboxNetwork.Height, full_downlines, full_uplines, false);                IntPtr oBm = bm.GetHbitmap();
                    picboxNetwork.Image = Image.FromHbitmap(oBm);
                    DeleteObject(oBm);
                    bm.Dispose();
                    g.Dispose();
                }
      

  8.   

    frmMain.Activate();//主窗体重新激活时,窗体还是很闪烁
      

  9.   

    双缓冲不一定能解决问题就算你用VC的NATIVE CODE画也是一样的,无法从根本上解决控件多了,图片多了,WINDOWS受不了除非你用DX直接搞
      

  10.   

    我找到问题的根本所在,在主窗体里我有两个panel,panel都设置了backgroundImage.如果用PictureBox来装载图片就没闪烁了,不知道是什么问题
      

  11.   

    long WS_CLIPCHILDREN = 0x02000000L;TO: hbxtlhx ...WS_CLIPCHILDREN的值太大了, 而且是16进制; dwNewLong是整型, 应该放不下...int范围: -32768~32767
      

  12.   

    //设置...
    int windowLong = (GetWindowLong(new HandleRef(this, this.Handle), -16));
    int oldvalue = SetWindowLong(new HandleRef(this, this.Handle), -16, windowLong | WS_CLIPCHILDREN);
    //恢复...
    SetWindowLong(new HandleRef(this, this.Handle), -16, oldvalue);
      

  13.   

    我加了hbxtlhx(平民百姓-自已动手,丰衣足食)那段代码,感觉没起作用
      

  14.   

    有关于vb.net这方面的代码吗?
      

  15.   

                            Bitmap   bufferimage   =   new   Bitmap(this.Width,   this.Height);
                            Graphics   g   =   Graphics.FromImage(bufferimage);
     
    在 OnPaint里面,new Bitmap是很费时的,当然会闪了
      

  16.   

    应该是更新太快,比机机处理当前UI所需的时间快造成的吧,你试试每次刷新前 SELEEP(200),可能要好些