Here's the C# translation of the other forum's solution ...
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
public class MyPanel : Panel
{
public MyPanel()
{
this.AutoScroll = true;
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
private Image mImage;
public Image Image
{
get { return mImage; }
set
{
mImage = value;
Invalidate();
}
}
protected override void OnScroll(ScrollEventArgs se)
{
if (se.Type == ScrollEventType.First)
{
LockWindowUpdate(this.Handle);
}
else if (
se.Type == ScrollEventType.ThumbTrack ||
se.Type == ScrollEventType.ThumbPosition)
{
LockWindowUpdate(IntPtr.Zero);
this.Refresh();
LockWindowUpdate(this.Handle);
}
else
{
LockWindowUpdate(IntPtr.Zero);
this.Invalidate();
}
base.OnScroll(se);
}
protected override void OnPaint(PaintEventArgs e)
{
using (SolidBrush br = new SolidBrush(this.BackColor))
{
e.Graphics.FillRectangle(br, this.ClientRectangle);
}
if (mImage != null)
{
e.Graphics.DrawImage(mImage, 0, 0);
}
base.OnPaint(e);
}
[DllImport("user32.dll")]
private static extern bool LockWindowUpdate(IntPtr hWnd);
}
The image doesn't move any more but there is still an annoying flicker as the topmost panel scrolls ... may still be some work to do