home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Hello Windows Forms / TwoPaintHandlers / TwoPaintHandlers.cs next >
Encoding:
Text File  |  2001-01-15  |  1.2 KB  |  37 lines

  1. //-----------------------------------------------
  2. // TwoPaintHandlers.cs ⌐ 2001 by Charles Petzold
  3. //-----------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class TwoPaintHandlers
  9. {
  10.      public static void Main()
  11.      {
  12.           Form form      = new Form();
  13.           form.Text      = "Two Paint Handlers";
  14.           form.BackColor = Color.White;
  15.           form.Paint    += new PaintEventHandler(PaintHandler1);
  16.           form.Paint    += new PaintEventHandler(PaintHandler2);
  17.  
  18.           Application.Run(form);
  19.      }
  20.      static void PaintHandler1(object objSender, PaintEventArgs pea)
  21.      {
  22.           Form     form = (Form)objSender;
  23.           Graphics grfx = pea.Graphics;
  24.  
  25.           grfx.DrawString("First Paint Event Handler", form.Font, 
  26.                           Brushes.Black, 0, 0);
  27.      }
  28.      static void PaintHandler2(object objSender, PaintEventArgs pea)
  29.      {
  30.           Form     form = (Form)objSender;
  31.           Graphics grfx = pea.Graphics;
  32.  
  33.           grfx.DrawString("Second Paint Event Handler", form.Font, 
  34.                           Brushes.Black, 0, 100);
  35.      }
  36. }
  37.