Newer
Older
IRIS_COLLECT / IOM_cs / MyTabControl.cs
yangqianqian on 29 Dec 2020 2 KB first
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace IOM_cs
{
    public partial class MyTabControl : TabControl
    {
        public MyTabControl()
        {
            InitializeComponent();

            SetStyle

                      ( ControlStyles.AllPaintingInWmPaint  //全部在窗口绘制消息中绘图

                      | ControlStyles.OptimizedDoubleBuffer //使用双缓冲

                      , true);
        }


         protected override void WndProc(ref Message m)
            {
                if ((m.Msg == TCM_ADJUSTRECT))
                {
                    RECT rc = (RECT)m.GetLParam(typeof(RECT));
                    //Adjust these values to suit, dependant upon Appearance
                    rc.Left -= 3;
                    rc.Right += 3;
                    rc.Top -= 3;
                    rc.Bottom += 3;
                    Marshal.StructureToPtr(rc, m.LParam, true);
                }
                base.WndProc(ref m);
            }

            private const Int32 TCM_FIRST = 0x1300;
            private const Int32 TCM_ADJUSTRECT = (TCM_FIRST + 40);
            private struct RECT
            {
                public Int32 Left;
                public Int32 Top;
                public Int32 Right;
                public Int32 Bottom;
            }
         

        ///<summary>

        /// 设置控件窗口创建参数的扩展风格

        ///</summary>
            protected override CreateParams CreateParams
            {
                get
                {
                    var parms = base.CreateParams;
                    parms.Style &= ~0x02000000;
                    return parms;
                }
            }

       //protected override CreateParams CreateParams

       // {

       //    get

       //     {

       //        CreateParams cp = base.CreateParams;

       //        cp.ExStyle |= 0x02000000;

       //        return cp;

       //     }

       // }
    }
}