fork download
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace bttest
  5. {
  6. static class Program
  7. {
  8. [STAThread]
  9. static void Main()
  10. {
  11. Application.EnableVisualStyles();
  12. Application.SetCompatibleTextRenderingDefault(false);
  13. Application.Run(new Form1());
  14. }
  15. }
  16. public class Form1 : Form
  17. {
  18. Button button1;
  19. public Form1()
  20. {
  21. button1 = new Button();
  22. this.button1.Location = new System.Drawing.Point(25, 25);
  23. this.button1.Size = new System.Drawing.Size(100, 50);
  24. this.button1.Text = "button1";
  25. this.ClientSize = new System.Drawing.Size(284, 261);
  26. this.Controls.Add(this.button1);
  27. button1.MouseMove += MM; button1.MouseDown += MM;
  28. button1.MouseUp += MU;
  29. button1.MouseLeave += ML;
  30. }
  31. private void MM(object sender, MouseEventArgs e)
  32. {
  33. Rectangle rect = button1.Bounds;
  34. Point p = e.Location; p.X += button1.Left; p.Y += button1.Top;
  35. if (e == null || e.Button != MouseButtons.Left || !rect.Contains(p)) { ML(null, null); return; }
  36. this.Text = "Mouse On";
  37. }
  38. private void MU(object sender, MouseEventArgs e)
  39. {
  40. if (e == null || e.Button != MouseButtons.Left) return;
  41. ML(null, null);
  42. }
  43. private void ML(object sender, EventArgs e)
  44. { this.Text = "Mouse Off"; }
  45. }
  46.  
  47. }
  48.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(3,22): error CS0234: The type or namespace name `Forms' does not exist in the namespace `System.Windows'. Are you missing `System.Windows.Forms' assembly reference?
prog.cs(16,22): error CS0246: The type or namespace name `Form' could not be found. Are you missing an assembly reference?
prog.cs(18,1): error CS0246: The type or namespace name `Button' could not be found. Are you missing an assembly reference?
prog.cs(31,32): error CS0246: The type or namespace name `MouseEventArgs' could not be found. Are you missing an assembly reference?
prog.cs(38,32): error CS0246: The type or namespace name `MouseEventArgs' could not be found. Are you missing an assembly reference?
Compilation failed: 5 error(s), 0 warnings
stdout
Standard output is empty