TreeViewEx.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. namespace OpcUaHelper.Forms
  8. {
  9. /// <summary>
  10. /// 无闪烁的树节点控件,结果还是没有实现
  11. /// </summary>
  12. public class TreeViewEx : TreeView
  13. {
  14. /// <summary>
  15. /// 实例化一个新的控件
  16. /// </summary>
  17. public TreeViewEx()
  18. {
  19. // 开启双缓冲
  20. SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
  21. // Enable the OnNotifyMessage event so we get a chance to filter out
  22. // Windows messages before they get to the form's WndProc
  23. SetStyle(ControlStyles.EnableNotifyMessage, true);
  24. }
  25. /// <summary>
  26. /// 通知
  27. /// </summary>
  28. /// <param name="m"></param>
  29. protected override void OnNotifyMessage(Message m)
  30. {
  31. //Filter out the WM_ERASEBKGND message
  32. if (m.Msg != 0x14)
  33. {
  34. base.OnNotifyMessage(m);
  35. }
  36. }
  37. //protected override void WndProc(ref Message m)
  38. //{
  39. // if (m.Msg == 0x0014) // 禁掉清除背景消息
  40. // return;
  41. // base.WndProc(ref m);
  42. //}
  43. }
  44. }