1

I use a textbox attach on a panel and then scroll the panel with my scrollbar instead of using windows default scroll bar.

But the problem is i use LockWindowUpdate when scrolling, which will affect the desktop window and make it flicker in windows xp.

The very interesting thing is once I open a file browser in winXp and scroll the scrollbar in the file browser. Then go back to my application and scroll my customized scrollbar again , the flicker disappear.

is there any know what really happen in this case. how does LockWindowUpdate work?

Thanks

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();
                LockWindowUpdate(IntPtr.Zero);
            }
            base.OnScroll(se);
}

is the code for panel scroll event I just use my customized scroll bar to scroll the panel to right position.

if i use

SendMessage(parent.Handle, WM_SETREDRAW, false, 0);
SendMessage(parent.Handle, WM_SETREDRAW, true, 0);

the panel still jitter a lot .

And i found today , if i just focus a icon in desktop , the desktop will not flicker any more, but i add code in program by using

SetForegroundWindow(Win32API.GetDesktopWindow());

it doesn't work also , So i am really tired of this issue.

is there anyone know this case?

Xiwen
  • 253
  • 7
  • 25

2 Answers2

1

try this:

protected override void OnPaintBackground(PaintEventArgs e)
{
// Left empty to avoid undesirable flickering.
}
JAiro
  • 5,914
  • 2
  • 22
  • 21
0

This thread might be helpful: How do I suspend painting for a control and its children?

Try to use WM_SETREDRAW (disable) instead of LockWindowUpdate();

Community
  • 1
  • 1
swissben
  • 1,059
  • 8
  • 13
  • since i am using a transparent textbox , if i stop redraw the background itself will flicker – Xiwen Mar 04 '11 at 22:16