The splitter walkthrough example causes background windows to be corrupted

G

Guest

The splitter control walkthrough example corrupts the contents of windows (belonging to other processes) that are behind the window containing the splitter control. For example, if I compile the splitter walkthrough example code, and run the program, and move the splitter back and forth, if I then exit the program the contents of the Visual C# .NET code editor (which was behind the splitter program window) are all corrupted
There seems to be a general problem that if you have a control on a form and move it at run time eg by setting the Left property of the child control to some value, when the control is invalidated it actually leaves artifacts on other windows belonging to other processes
I am wondering if when a child control is invalidated, it gets repainted without the normal Win32API BeginPaint/EndPaint bracketing since it is just a child control and not the form itself....(thinking out loud
Is this a known issue and is there any workaround?
 
G

Guest

A workaround I've discovered is to use the Win32API LockWindowUpdate function. The example below allows me to have a splitter and move it around without the underlying background windows being affected (I'm still interested to know if the bug will be fixed properly at some point or if anyone else has come across this problem

using System.Runtime.InteropServices

namespace TestApp1
public class TestAppForm : System.Windows.Forms.Form

// ... Main() etc to get a form with a splitter and a control on each sid

[DllImport("user32.dll", CharSet=CharSet.Auto)
public static extern int LockWindowUpdate(IntPtr hWnd)

private void splitter1_SplitterMoving(object sender, System.Windows.Forms.SplitterEventArgs e)
LockWindowUpdate(Handle)


private void splitter1_SplitterMoved(object sender, System.Windows.Forms.SplitterEventArgs e)
LockWindowUpdate((System.IntPtr)null)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top