Example #1
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case NativeWindowCommon.WM_VSCROLL:
            case NativeWindowCommon.WM_HSCROLL:
                //keep all FitToMDI children at location 0,0 even after scroll
                foreach (var item in mdiClient.MdiChildren)
                {
                    TagData tagData = item.Tag as TagData;
                    if (tagData != null && (tagData.WindowType == WindowType.FitToMdi || tagData.IsMDIClientForm))
                    {
                        item.Location = new Point();
                    }
                }
                mdiClient.Invalidate();
                break;

            case NativeWindowCommon.WM_PAINT:
                using (Graphics gr = Graphics.FromHwnd(mdiClient.Handle))
                {
                    //Paint the mdiClient its children, background image, border etc.
                    ControlRenderer.PaintMgPanel(mdiClient, gr);
                    NativeWindowCommon.ValidateRect(mdiClient.Handle, IntPtr.Zero);
                }
                return;

            default:
                break;
            }
            base.WndProc(ref m);
        }
Example #2
0
        /// <summary></summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            //base paint should always be called -- even if IsBasePaint is false
            //because the borders should always be painted by the framework.
            String orgText = Text;

            TextToDisplay = Text;
            base.Text     = String.Empty;
            base.OnPaint(e);
            base.Text = orgText;
            //Since we are modifying the Text, we need to Validate the Rect. Otherwise, the paint goes in recursion.
            NativeWindowCommon.ValidateRect(this.Handle, IntPtr.Zero);

            //fixedbug #:735118: when the button is UseVisualStyleBackColor=true(no color is set) and it is normal button
            //                   let window to paint the backgound of the control.
            // QCR #997321: if the button has gradient style then we should paint the background.
            bool paintBackground = !UseVisualStyleBackColor || (GradientStyle != GradientStyle.None);

            ButtonRenderer.DrawButton(this, e, paintBackground, true);
        }