protected override void OnPaint(PaintEventArgs e)
{
Win32Helper.StretchBlt(this.Handle, 0, 0, 200, 300,bitmap.GetHbitmap(), 0, 0, bitmap.Width, bitmap.Height, Win32Helper.TernaryRasterOperations.SRCCOPY);
this.CreateGraphics().DrawRectangle(new Pen(Color.Black), 0, 0, 100, 100);
base.OnPaint(e);
}
Rectangle is drawn.. But bitmap isnt… I have set picturebox1.Image=bitmap and works so bitmap isnt empty … Any idea what am i doing wrong ?
I am in compact framework.
I’m not sure what “this.Handle” is, but it might be not be a handle to a DC. And I suspect you are leaking resources as well with each creation of a Pen and Graphics object. (The garbage collector will release it eventually, but it’s not a good idea to leave these handles lingering around). In any case, rather than thunking into StretchBlt, you could just use the Graphics object itself to do the image blit.