using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
this->SuspendLayout();
this->AutoScrollMinSize = System::Drawing::Size(400,400);
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 273);
this->Name = L"Form1";
this->Text = L"Scrolling Happy Face";
this->Paint +=
gcnew System::Windows::Forms::PaintEventHandler(this,
&Form1::Form1_Paint);
this->ResumeLayout(false);
}
System::Void Form1_Paint(System::Object^ sender,
System::Windows::Forms::PaintEventArgs^ e)
{
Graphics^ g = e->Graphics;
g->TranslateTransform((float)AutoScrollPosition.X,
(float)AutoScrollPosition.Y);
Pen^ b4pen = gcnew Pen(Color::Black, 4);
// Head
Rectangle rect = Drawing::Rectangle(25, 25, 250, 250);
g->FillEllipse(Brushes::Yellow, rect);
g->DrawEllipse(b4pen, rect);
// Mouth
g->FillPie(Brushes::White, 100, 175, 100, 50, 0, 180);
g->DrawPie(b4pen, 100, 175, 100, 50, 0, 180);
// Left Eye
rect = Drawing::Rectangle(100, 100, 25, 25);
g->FillEllipse(Brushes::White, rect);
g->DrawEllipse(b4pen, rect);
// Right Eye
rect = Drawing::Rectangle(175, 100, 25, 25);
g->FillEllipse(Brushes::White, rect);
g->DrawEllipse(b4pen, rect);
// Get rid of pen Created
delete b4pen;
}
};
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Application::Run(gcnew Form1());
return 0;
}
|