using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; namespace Clipper { public class MainForm : System.Windows.Forms.Form { public MainForm() { InitializeComponent(); int x, y; for (y = 0; y < 10; y ++) { for (x = 0; x < 10; x ++) { Button b = new Button(); b.Location = new Point (x * 40, y * 40); b.Size = new Size (30, 30); Controls.Add (b); } } SetStyle (ControlStyles.DoubleBuffer, true); } [STAThread] public static void Main(string[] args) { Application.Run(new MainForm()); } #region Windows Forms Designer generated code private void InitializeComponent() { // // MainForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(752, 493); this.Name = "MainForm"; this.Text = "MainForm"; } #endregion protected override void WndProc (ref Message m) { DateTime start = DateTime.MinValue; bool paint = false; if (m.Msg == 0x000F /* WM_PAINT*/) paint = true; if (paint) start = DateTime.Now; base.WndProc (ref m); if (paint) { Console.WriteLine ("time to paint = {0}", DateTime.Now - start); } } protected override void OnPaint(PaintEventArgs e) { LinearGradientBrush lgbr = new LinearGradientBrush(new Point(0, 0), new Point(ClientRectangle.Width, ClientRectangle.Height), Color.Blue, Color.Black); e.Graphics.FillRectangle(lgbr, ClientRectangle); } } }