Esempio n. 1
0
        public RoyalMessageBox() : base()
        {
            Font          = new Font(new FontFamily("Segoe UI"), 9.75f, FontStyle.Regular);
            Moveable      = false;
            ControlBox    = false;
            ShowInTaskbar = false;
            StartPosition = FormStartPosition.CenterParent;

            okButton.Text   = "Ok";
            okButton.Size   = new Size(100, 35);
            okButton.Click += OkButton_Click;

            yesButton.Text   = "Yes";
            yesButton.Size   = new Size(100, 35);
            yesButton.Click += YesButton_Click;

            noButton.Text   = "No";
            noButton.Size   = new Size(100, 35);
            noButton.Click += NoButton_Click;

            cancelButton.Text   = "Cancel";
            cancelButton.Size   = new Size(100, 35);
            cancelButton.Click += CancelButton_Click;

            retryButton.Text   = "Retry";
            retryButton.Size   = new Size(100, 35);
            retryButton.Click += RetryButton_Click;

            Controls.Add(okButton);
            Controls.Add(yesButton);
            Controls.Add(noButton);
            Controls.Add(cancelButton);
            Controls.Add(retryButton);

            okButton.Hide();
            yesButton.Hide();
            noButton.Hide();
            cancelButton.Hide();
            retryButton.Hide();
        }
Esempio n. 2
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (Sizable && m.Msg == wmNcHitTest && WindowState != FormWindowState.Maximized)
            {
                int gripDist = 10;
                //int x = (int)(m.LParam.ToInt64() & 0xFFFF);
                //int x = Cursor.Position.X;
                // int y = (int)((m.LParam.ToInt64() & 0xFFFF0000) >> 16);
                //Console.WriteLine(x);
                Point pt = PointToClient(Cursor.Position);
                //Console.WriteLine(pt);
                Size clientSize = ClientSize;
                ///allow resize on the lower right corner
                if (pt.X >= clientSize.Width - gripDist && pt.Y >= clientSize.Height - gripDist && clientSize.Height >= gripDist)
                {
                    m.Result = (IntPtr)(IsMirrored ? htBottomLeft : htBottomRight);
                    return;
                }
                ///allow resize on the lower left corner
                if (pt.X <= gripDist && pt.Y >= clientSize.Height - gripDist && clientSize.Height >= gripDist)
                {
                    m.Result = (IntPtr)(IsMirrored ? htBottomRight : htBottomLeft);
                    return;
                }
                ///allow resize on the upper right corner
                if (pt.X <= gripDist && pt.Y <= gripDist && clientSize.Height >= gripDist)
                {
                    m.Result = (IntPtr)(IsMirrored ? htTopRight : htTopLeft);
                    return;
                }
                ///allow resize on the upper left corner
                if (pt.X >= clientSize.Width - gripDist && pt.Y <= gripDist && clientSize.Height >= gripDist)
                {
                    m.Result = (IntPtr)(IsMirrored ? htTopLeft : htTopRight);
                    return;
                }
                ///allow resize on the top border
                if (pt.Y <= 2 && clientSize.Height >= 2)
                {
                    m.Result = (IntPtr)(htTop);
                    return;
                }
                ///allow resize on the bottom border
                if (pt.Y >= clientSize.Height - gripDist && clientSize.Height >= gripDist)
                {
                    m.Result = (IntPtr)(htBottom);
                    return;
                }
                ///allow resize on the left border
                if (pt.X <= gripDist && clientSize.Height >= gripDist)
                {
                    m.Result = (IntPtr)(htLeft);
                    return;
                }
                ///allow resize on the right border
                if (pt.X >= clientSize.Width - gripDist && clientSize.Height >= gripDist)
                {
                    m.Result = (IntPtr)(htRight);
                    return;
                }
            }

            if (m.Msg == WM_NCHITTEST)
            {
                if (Moveable)
                {
                    if ((int)m.Result == HTCLIENT)
                    {
                        m.Result = new IntPtr(HTCAPTION);
                    }
                }
            }

            if (ControlBox == false)
            {
                closeButton.Hide();
                minimizeButton.Hide();
                maximizeButton.Hide();
            }
            else if (Visible && ControlBox == true && !closeButton.Visible)
            {
                closeButton.Show();

                if (MinimizeBox)
                {
                    minimizeButton.Show();
                }

                if (MaximizeBox)
                {
                    maximizeButton.Show();
                }
            }

            if (Visible && !MinimizeBox && minimizeButton.Visible)
            {
                minimizeButton.Hide();
            }
            else if (Visible && MinimizeBox && !minimizeButton.Visible && ControlBox)
            {
                minimizeButton.Show();
            }

            if (Visible && !MaximizeBox && maximizeButton.Visible)
            {
                maximizeButton.Hide();
            }
            else if (Visible && MaximizeBox && !maximizeButton.Visible && ControlBox)
            {
                maximizeButton.Show();
            }
        }