12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace SIMDP
- {
- //public partial class CoTableLayoutPanel : Control
- //{
- // public CoTableLayoutPanel()
- // {
- // InitializeComponent();
- // }
- // protected override void OnPaint(PaintEventArgs pe)
- // {
- // base.OnPaint(pe);
- // }
- //}
- public partial class CoTableLayoutPanel : TableLayoutPanel
- {
-
- protected override void OnCreateControl()
- {
- base.OnCreateControl();
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.CacheText, true);
- // this.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
- }
- protected override CreateParams CreateParams
- {
- get
- {
- CreateParams cp = base.CreateParams;
- cp.ExStyle |= NativeMethods.WS_EX_COMPOSITED;
- return cp;
- }
- }
- public void BeginUpdate()
- {
- NativeMethods.SendMessage(this.Handle, NativeMethods.WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
- }
- public void EndUpdate()
- {
- NativeMethods.SendMessage(this.Handle, NativeMethods.WM_SETREDRAW, new IntPtr(1), IntPtr.Zero);
- Parent.Invalidate(true);
- }
- }
- public static class NativeMethods
- {
- public static int WM_SETREDRAW = 0x000B; //uint WM_SETREDRAW
- public static int WS_EX_COMPOSITED = 0x02000000;
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); //UInt32 Msg
- }
- }
|