Print out Form size and position related information

image_pdfimage_print
   
 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class FormSize: Form
{
     public static void Main()
     {
          Application.Run(new FormSize());
     }
     public FormSize()
     {
          BackColor = Color.White;
     }
     protected override void OnMove(EventArgs ea)
     {
          Invalidate();
     }
     protected override void OnResize(EventArgs ea)
     {
          Invalidate();
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics graphics = pea.Graphics;
          string   str  = "Location: "        + Location        + "
"   +
                          "Size: "            + Size            + "
"   +
                          "Bounds: "          + Bounds          + "
"   +
                          "Width: "           + Width           + "
"   +
                          "Height: "          + Height          + "
"   +
                          "Left: "            + Left            + "
"   +
                          "Top: "             + Top             + "
"   +
                          "Right: "           + Right           + "
"   +
                          "Bottom: "          + Bottom          + "

" +
                          "DesktopLocation: " + DesktopLocation + "
"   +
                          "DesktopBounds: "   + DesktopBounds   + "

" +
                          "ClientSize: "      + ClientSize      + "
"   +
                          "ClientRectangle: " + ClientRectangle;
   
          graphics.DrawString(str, Font, Brushes.Black, 0, 0);
    }
}