Guest User

Untitled

a guest
Oct 28th, 2011
28
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace DoEventsTest
  2. {
  3.     public partial class Form1 : Form
  4.     {
  5.         static private Timer timer = new Timer();
  6.         static private int TickCount;
  7.  
  8.         public Form1()
  9.         {
  10.             InitializeComponent();
  11.             TickCount = 0;
  12.         }
  13.  
  14.         protected override void OnShown(EventArgs e)
  15.         {
  16.             base.OnShown(e);
  17.             label1.Text = "TestFormRefreshWhenOffScreen";
  18.             timer.Tick += new EventHandler(timer_Tick);
  19.             timer.Interval = 1000;
  20.             timer.Start();
  21.         }
  22.  
  23.         protected override void OnClosed(EventArgs e)
  24.         {
  25.             base.OnClosed(e);
  26.             timer.Stop();
  27.         }
  28.  
  29.         protected void timer_Tick(object sender, EventArgs e)
  30.         {    
  31.             if (this.Left > -1000)
  32.               this.Left -= 32;
  33.         }
  34.  
  35.         protected override void OnPaint(PaintEventArgs e)
  36.         {
  37.             base.OnPaint(e);
  38.             Console.WriteLine("Control is now at {0},{1}", Location.X, Location.Y);
  39.         }
  40.  
  41.         protected override void OnMove(EventArgs e)
  42.         {
  43.             base.OnMove(e);
  44.             Console.WriteLine("Moving");
  45.             Refresh();
  46.         }
  47.     }
  48. }
  49.  
  50.  
  51.  
RAW Paste Data