forked from mirrors/NBTExplorer
Try to improve control flicker
This commit is contained in:
parent
366ec3fe9e
commit
5d51967501
3 changed files with 92 additions and 2 deletions
64
NBTExplorer/Interop.cs
Normal file
64
NBTExplorer/Interop.cs
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace NBTExplorer
|
||||||
|
{
|
||||||
|
internal static class Interop
|
||||||
|
{
|
||||||
|
public static bool WinInteropAvailable
|
||||||
|
{
|
||||||
|
get { return IsWindows && Type.GetType("Mono.Runtime") == null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsWindows
|
||||||
|
{
|
||||||
|
get { return Environment.OSVersion.Platform == PlatformID.Win32NT; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsWinXP
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
OperatingSystem OS = Environment.OSVersion;
|
||||||
|
return (OS.Platform == PlatformID.Win32NT) &&
|
||||||
|
((OS.Version.Major > 5) || ((OS.Version.Major == 5) && (OS.Version.Minor == 1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsWinVista
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
OperatingSystem OS = Environment.OSVersion;
|
||||||
|
return (OS.Platform == PlatformID.Win32NT) && (OS.Version.Major >= 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr SendMessage (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
|
||||||
|
{
|
||||||
|
if (WinInteropAvailable)
|
||||||
|
return NativeInterop.SendMessage(hWnd, msg, wParam, lParam);
|
||||||
|
else
|
||||||
|
return IntPtr.Zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static class NativeInterop
|
||||||
|
{
|
||||||
|
public const int WM_PRINTCLIENT = 0x0318;
|
||||||
|
public const int PRF_CLIENT = 0x00000004;
|
||||||
|
|
||||||
|
public const int TV_FIRST = 0x1100;
|
||||||
|
public const int TVM_SETBKCOLOR = TV_FIRST + 29;
|
||||||
|
public const int TVM_SETEXTENDEDSTYLE = TV_FIRST + 44;
|
||||||
|
|
||||||
|
public const int TVS_EX_DOUBLEBUFFER = 0x0004;
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern IntPtr SendMessage (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@
|
||||||
<AssemblyName>NBTExplorer</AssemblyName>
|
<AssemblyName>NBTExplorer</AssemblyName>
|
||||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<PublishUrl>publish\</PublishUrl>
|
<PublishUrl>publish\</PublishUrl>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
<InstallFrom>Disk</InstallFrom>
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
@ -24,7 +25,6 @@
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -100,6 +100,7 @@
|
||||||
<Compile Include="Controllers\NodeTreeController.cs" />
|
<Compile Include="Controllers\NodeTreeController.cs" />
|
||||||
<Compile Include="FormRegistry.cs" />
|
<Compile Include="FormRegistry.cs" />
|
||||||
<Compile Include="Controllers\RuleTreeController.cs" />
|
<Compile Include="Controllers\RuleTreeController.cs" />
|
||||||
|
<Compile Include="Interop.cs" />
|
||||||
<Compile Include="Model\Search\SearchRule.cs" />
|
<Compile Include="Model\Search\SearchRule.cs" />
|
||||||
<Compile Include="NbtClipboardController.cs" />
|
<Compile Include="NbtClipboardController.cs" />
|
||||||
<Compile Include="SnapshotList.cs" />
|
<Compile Include="SnapshotList.cs" />
|
||||||
|
|
|
@ -11,7 +11,6 @@ namespace NBTExplorer.Vendor.MultiSelectTreeView
|
||||||
{
|
{
|
||||||
public class MultiSelectTreeView : TreeView
|
public class MultiSelectTreeView : TreeView
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Selected Node(s) Properties
|
#region Selected Node(s) Properties
|
||||||
|
|
||||||
private List<TreeNode> m_SelectedNodes = null;
|
private List<TreeNode> m_SelectedNodes = null;
|
||||||
|
@ -57,14 +56,40 @@ namespace NBTExplorer.Vendor.MultiSelectTreeView
|
||||||
|
|
||||||
public MultiSelectTreeView()
|
public MultiSelectTreeView()
|
||||||
{
|
{
|
||||||
|
DoubleBuffered = true;
|
||||||
|
|
||||||
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
|
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
|
||||||
|
|
||||||
m_SelectedNodes = new List<TreeNode>();
|
m_SelectedNodes = new List<TreeNode>();
|
||||||
base.SelectedNode = null;
|
base.SelectedNode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateExtendedStyles ()
|
||||||
|
{
|
||||||
|
if (Interop.WinInteropAvailable) {
|
||||||
|
int style = 0;
|
||||||
|
|
||||||
|
if (DoubleBuffered)
|
||||||
|
style |= NativeInterop.TVS_EX_DOUBLEBUFFER;
|
||||||
|
|
||||||
|
if (style != 0)
|
||||||
|
Interop.SendMessage(Handle, NativeInterop.TVM_SETEXTENDEDSTYLE, (IntPtr)NativeInterop.TVS_EX_DOUBLEBUFFER, (IntPtr)style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Overridden Events
|
#region Overridden Events
|
||||||
|
|
||||||
|
protected override void OnHandleCreated (EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnHandleCreated(e);
|
||||||
|
|
||||||
|
if (Interop.WinInteropAvailable) {
|
||||||
|
UpdateExtendedStyles();
|
||||||
|
if (!Interop.IsWinXP)
|
||||||
|
Interop.SendMessage(Handle, NativeInterop.TVM_SETBKCOLOR, IntPtr.Zero, (IntPtr)ColorTranslator.ToWin32(BackColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnGotFocus( EventArgs e )
|
protected override void OnGotFocus( EventArgs e )
|
||||||
{
|
{
|
||||||
// Make sure at least one node has a selection
|
// Make sure at least one node has a selection
|
||||||
|
|
Loading…
Reference in a new issue