I'm trying to write a panel in CF.NET that allows me to scroll the contents inside without flickering. I thought I'd try having a WrapperPanel class that contains another panel with the actual contents. Then I'd bitblt the contents of the interior panel to the wrapper based on the scrolling position.
But the bitblt isn't working for me. It's just leaving the destination surface as it was, with no visible change.
Here's the relevant code:
protected override void OnPaint(PaintEventArgs e)
{
//Generate a proper-sized bitmap
using (Bitmap bmp = new Bitmap(ClientSize.Width, ClientSize.Height))
{
using (Graphics bgr = Graphics.FromImage(bmp))
{
//bitblt from interior panel to that bitmap
var srcDC = GetDC(_interiorPanel.Handle);
var bmDC = bgr.GetHdc();
var res = BitBlt(bmDC, 0, YOffSet, Width, Height, srcDC, 0, 0, 0x00CC0020);
System.Diagnostics.Debug.WriteLine(res);
ReleaseDC(_interiorPanel.Handle, srcDC);
bgr.ReleaseHdc(bmDC);
}
//Draw that bitmap to this panel
e.Graphics.DrawImage(bmp, 0, 0);
}
base.OnPaint(e);
}
Both the GetDC() and GetHdc() calls return a value, so at least they aren't failing. But that's about the extent of my troubleshooting knowledge with GDI+. Can someone see what I'm doing wrong?