problem with GDI+

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dawn

    #1

    problem with GDI+

    Hi,

    With the code I use to capture part of a form, an error shows up : External
    GDI+ error

    the code is the following

    private void button3_Click(o bject sender, System.EventArg s e)
    {

    resdial.Activat e() ;

    System.IntPtr srcDC=GetDC(res dial.axWebBrows er1.Handle);

    Bitmap bm=new Bitmap(50,50);

    Graphics g=Graphics.From Image(bm);

    System.IntPtr bmDC=g.GetHdc() ;


    BitBlt(bmDC,0,0 ,bm.Width,bm.He ight,srcDC,0,0, 0x00CC0020 /*SRCCOPY*/);

    this.pictureBox 1.Image = System.Drawing. Image.FromHbitm ap(bmDC);


    ReleaseDC(srcDC );

    g.ReleaseHdc(bm DC);

    g.Dispose();



    }



    The line that gives the error is

    this.pictureBox 1.Image = System.Drawing. Image.FromHbitm ap(bmDC);



    What's wrong with this?



    Thanks



  • Bob Powell [MVP]

    #2
    Re: problem with GDI+

    Please try to post the same subject and content only once. This is a busy
    group and it doesn't need the extra traffic.

    --
    Bob Powell [MVP]
    C#, System.Drawing

    The October edition of Well Formed is now available.
    Find out how to use DirectX in a Windows Forms control


    Answer those GDI+ questions with the GDI+ FAQ


    Read my Blog at http://bobpowelldotnet.blogspot.com

    "dawn" <dawn4715@hotma il.com> wrote in message
    news:3yfob.1158 95$ju5.5326901@ phobos.telenet-ops.be...[color=blue]
    > Hi,
    >
    > With the code I use to capture part of a form, an error shows up :[/color]
    External[color=blue]
    > GDI+ error
    >
    > the code is the following
    >
    > private void button3_Click(o bject sender, System.EventArg s e)
    > {
    >
    > resdial.Activat e() ;
    >
    > System.IntPtr srcDC=GetDC(res dial.axWebBrows er1.Handle);
    >
    > Bitmap bm=new Bitmap(50,50);
    >
    > Graphics g=Graphics.From Image(bm);
    >
    > System.IntPtr bmDC=g.GetHdc() ;
    >
    >
    > BitBlt(bmDC,0,0 ,bm.Width,bm.He ight,srcDC,0,0, 0x00CC0020 /*SRCCOPY*/);
    >
    > this.pictureBox 1.Image = System.Drawing. Image.FromHbitm ap(bmDC);
    >
    >
    > ReleaseDC(srcDC );
    >
    > g.ReleaseHdc(bm DC);
    >
    > g.Dispose();
    >
    >
    >
    > }
    >
    >
    >
    > The line that gives the error is
    >
    > this.pictureBox 1.Image = System.Drawing. Image.FromHbitm ap(bmDC);
    >
    >
    >
    > What's wrong with this?
    >
    >
    >
    > Thanks
    >
    >
    >[/color]


    Comment

    Working...