Пример #1
0
        private void RenderStyle(ref Message m)
        {
            base.WndProc(ref m);

            if (!Natives.CanRender())
            {
                return;
            }

            int partId = Natives.EP_EDITTEXT;

            int stateId;

            if (this.Enabled)
            {
                stateId = this.ReadOnly ? Natives.ETS_READONLY : Natives.ETS_NORMAL;
            }
            else
            {
                stateId = Natives.ETS_DISABLED;
            }

            RECT windowRect;

            Natives.GetWindowRect(this.Handle, out windowRect);
            windowRect.Right  -= windowRect.Left;
            windowRect.Bottom -= windowRect.Top;
            windowRect.Top     = 0;
            windowRect.Left    = 0;

            IntPtr hDC = Natives.GetWindowDC(this.Handle);

            RECT clientRect = windowRect;

            clientRect.Left   += this._border.Left;
            clientRect.Top    += this._border.Top;
            clientRect.Right  -= this._border.Right;
            clientRect.Bottom -= this._border.Bottom;

            Natives.ExcludeClipRect(hDC, clientRect.Left, clientRect.Top, clientRect.Right, clientRect.Bottom);

            IntPtr hTheme = Natives.OpenThemeData(this.Handle, "EDIT");

            if (Natives.IsThemeBackgroundPartiallyTransparent(hTheme, Natives.EP_EDITTEXT, Natives.ETS_NORMAL) != 0)
            {
                Natives.DrawThemeParentBackground(this.Handle, hDC, ref windowRect);
            }


            Natives.DrawThemeBackground(hTheme, hDC, partId, stateId, ref windowRect, IntPtr.Zero);
            Natives.CloseThemeData(hTheme);
            Natives.ReleaseDC(this.Handle, hDC);
            m.Result = IntPtr.Zero;
        }