#using <mscorlib.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
__gc public class SimpleForm : public Form
{
public:
SimpleForm();
private:
VScrollBar *Scroller;
Label *lblPosition;
void ScrollerChange(Object *Sender, System::EventArgs *pArgs);
};
SimpleForm::SimpleForm()
{
Text = S"ScrollBar Example";
Scroller = new VScrollBar;
Scroller->Location = Point(20, 20);
Scroller->Size = Drawing::Size(20, 200);
Scroller->Minimum = 5;
Scroller->Maximum = 150;
Scroller->add_ValueChanged(new EventHandler(this, ScrollerChange));
Controls->Add(Scroller);
lblPosition = new Label;
lblPosition->Location = Point(60, 100);
lblPosition->AutoSize = true;
lblPosition->Text = "5";
this->Controls->Add(lblPosition);
}
void SimpleForm::ScrollerChange(Object *Sender, System::EventArgs *pArgs)
{
lblPosition->Text = Scroller->Value.ToString();
}
int __stdcall WinMain()
{
SimpleForm *FM = new SimpleForm();
Application::Run(FM);
return 0;
}
|