* UINavMenu: 防止控件闪烁

This commit is contained in:
Sunny 2024-05-17 23:50:56 +08:00
parent 35ef10547f
commit 99ab567b2e

View File

@ -38,6 +38,7 @@
* 2023-05-29: V3.3.7 PageGuid相关扩展方法 * 2023-05-29: V3.3.7 PageGuid相关扩展方法
* 2023-11-16: V3.5.2 * 2023-11-16: V3.5.2
* 2024-04-13: V3.6.5 * 2024-04-13: V3.6.5
* 2024-05-17: V3.6.6
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -61,22 +62,26 @@ namespace Sunny.UI
public UINavMenu() public UINavMenu()
{ {
SetStyle(ControlStyles.DoubleBuffer | base.SetStyle(
ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer |
ControlStyles.OptimizedDoubleBuffer, true); ControlStyles.OptimizedDoubleBuffer |
UpdateStyles(); ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw |
ControlStyles.SupportsTransparentBackColor, true);
base.UpdateStyles();
DoubleBuffered = true;
this.HotTracking = true;
this.CheckBoxes = false;
this.ShowPlusMinus = false;
this.ShowRootLines = false;
BorderStyle = BorderStyle.None; BorderStyle = BorderStyle.None;
//HideSelection = false; //HideSelection = false;
DrawMode = TreeViewDrawMode.OwnerDrawAll; DrawMode = TreeViewDrawMode.OwnerDrawAll;
FullRowSelect = true; FullRowSelect = true;
ShowLines = false; ShowLines = false;
//ShowPlusMinus = false;
//ShowRootLines = false;
DoubleBuffered = true;
base.Font = UIStyles.Font(); base.Font = UIStyles.Font();
//CheckBoxes = false;
ItemHeight = 50; ItemHeight = 50;
BackColor = Color.FromArgb(56, 56, 56); BackColor = Color.FromArgb(56, 56, 56);
@ -103,6 +108,14 @@ namespace Sunny.UI
_timer.Tick += Timer_Tick; _timer.Tick += Timer_Tick;
} }
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
int Style = 0;
if (DoubleBuffered) Style |= 0x0004;
if (Style != 0) Win32.User.SendMessage(Handle, 0x112C, new IntPtr(0x0004), new IntPtr(Style));
}
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
_timer.Dispose(); _timer.Dispose();
@ -649,6 +662,8 @@ namespace Sunny.UI
protected override void OnDrawNode(DrawTreeNodeEventArgs e) protected override void OnDrawNode(DrawTreeNodeEventArgs e)
{ {
if (e.Bounds.IsEmpty) return;
if (_resizing) if (_resizing)
{ {
return; return;
@ -656,13 +671,10 @@ namespace Sunny.UI
} }
else else
{ {
if (BorderStyle != BorderStyle.None) if (BorderStyle != BorderStyle.None) BorderStyle = BorderStyle.None;
{ if (checkBoxes != false) CheckBoxes = false;
BorderStyle = BorderStyle.None;
}
SetScrollInfo(); SetScrollInfo();
CheckBoxes = false;
if (e.Node == null || (e.Node.Bounds.Width <= 0 && e.Node.Bounds.Height <= 0 && e.Node.Bounds.X <= 0 && e.Node.Bounds.Y <= 0)) if (e.Node == null || (e.Node.Bounds.Width <= 0 && e.Node.Bounds.Height <= 0 && e.Node.Bounds.X <= 0 && e.Node.Bounds.Y <= 0))
{ {