Programming Windows help!!!
Ive been working through "Programming Windows with C#" and I keep getting a compiler error because the class "Draw House" cant come from "PrintableForm". Most of the programs from here on in the book inherit from "PrintableForm". Whats the deal? Thanx for any response!
//----------------------------------------
// DrawHouse.cs © 2001 by Charles Petzold
//----------------------------------------
using System;
using System.Drawing;
using System.Windows.Forms;
class DrawHouse: PrintableForm
{
public new static void Main()
{
Application.Run(new DrawHouse());
}
public DrawHouse()
{
Text = "Draw a House in One Line";
}
protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
grfx.DrawLines(new Pen(clr),
new Point[]
{
new Point( cx / 4, 3 * cy / 4), // Lower left
new Point( cx / 4, cy / 2),
new Point( cx / 2, cy / 4), // Peak
new Point(3 * cx / 4, cy / 2),
new Point(3 * cx / 4, 3 * cy / 4), // Lower right
new Point( cx / 4, cy / 2),
new Point(3 * cx / 4, cy / 2),
new Point( cx / 4, 3 * cy / 4), // Lower left
new Point(3 * cx / 4, 3 * cy / 4) // Lower right
});
}
}
PrintableForm is a class that Petzold introduces in his book. You will need to make sure that the class is in your project and is in the same namespace as the DrawHouse class you are using. Otherwise, you''ll need to add a using declaration to get PrintableForm brought in.
greg
greg
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement