解决方案 »

  1.   

    Graphics g=new Graphics ();
    你用g画,在哪个画布上画呢?Graphics g = this.CreateGraphics();明确了g是在this上画(如果this是当前窗体,则在窗体上画;如果this是PictureBox,则在pictureBox上画)还可以是这样的定义
    Graphics g = pictureBox1.CreateGraphics();则g在pictureBox1上画
      

  2.   

     Graphics g = this.CreateGraphics(); 左边是创建对象那么右边又是什么?
    左边是声明,右边才是创建对象,this.CreateGraphics()表示创建当前窗体的画布
      

  3.   

    是不是也就是说Graphics这个类比较特殊,不能用new创建?
      

  4.   


    Graphics这个类,设计成依赖作用对象,故意防止直接调用构造来创建对象
      

  5.   

    Graphics本身就没有可访问的构造函数,lz确认你在vs里能定义 Graphics g= new Graphics(); ?不报错吗?
      

  6.   

    Graphics g = this.CreateGraphics(); 
    左边是定义一个Graphics类型的变量
      

  7.   

    如何:创建用于绘制的 Graphics 对象?
    1、获取对 Paint 事件的 PaintEventArgs 中 Graphics 对象的引用
       private void Form1_Paint(object sender, 
            System.Windows.Forms.PaintEventArgs pe) 
       {
       // Declares the Graphics object and sets it to the Graphics object
       // supplied in the PaintEventArgs.
       Graphics g = pe.Graphics;
       // Insert code to paint the form here.
      }2、CreateGraphics()方法
      也可以使用控件或窗体的 CreateGraphics 方法来获取对 Graphics 对象的引用,该对象表示该控件或窗体的绘 图图面。 
       Graphics g;
       // Sets g to a graphics object representing the drawing surface of the
       // control or form g is a member of.
       g = this.CreateGraphics();3、从 Image 创建 Graphics 对象
       Bitmap myBitmap = new Bitmap(@"C:\Documents and 
       Settings\Joe\Pics\myPic.bmp");
       Graphics g = Graphics.FromImage(myBitmap);参考msdn,自己可以去看看,上面解释得很详细:
    http://msdn.microsoft.com/zh-cn/library/5y289054.aspx
      

  8.   

    为什么我用 Graphics* g = this->CreateGraphics();结果:error C2039: “CreateGraphics”: 不是“Ctest14Dlg”的成员 c:\users\brandy\documents\visual studio 2010\projects\test14\test14\test14dlg.cpp我是建立的基于对话框的MFC应用程序
      

  9.   

    为什么我用 Graphics* g = this->CreateGraphics();结果:error C2039: “CreateGraphics”: 不是“Ctest14Dlg”的成员 c:\users\brandy\documents\visual studio 2010\projects\test14\test14\test14dlg.cpp我是建立的基于对话框的MFC应用程序
      

  10.   

    解释得灰常清楚为什么我用 Graphics* g = this->CreateGraphics();结果:error C2039: “CreateGraphics”: 不是“Ctest14Dlg”的成员 c:\users\brandy\documents\visual studio 2010\projects\test14\test14\test14dlg.cpp我是建立的基于对话框的MFC应用程序
      

  11.   

    有一事不明:
       this.CreateGraphics()这个方法是不是每次调用都会给出不同的Graphics对象,还是说每次都是给的基于this的某个属性呢?
      

  12.   

    貌似在winform里面可以用this.graphics,在WPF里面就只能用Graphics.FromImage了.
      

  13.   

    “Graphics g = this.CreateGraphics();”
      

  14.   

    this也就是Form,this.CreateGraphics()就是Form.CreateGraphics(),所以CreateGraphics()是Form的一个方法而已,这个函数返回的是一个Graphics类型,你见过有int a=new int()这种写法吗