![]() |
The Forms of an Application |
|
Fundamentals of a Form |
|
Introduction |
|
The form is the most fundamental object used in an application. By itself, a form does nothing. Its main role is to host other objects that the user uses to interact with the computer: ![]()
|
There are various ways you can get a form to your application:
In Lesson 2, we saw that a was based on the Form class that is defined in the System::Windows::Forms namespace created in the System.Windows.Forms.dll assembly. Therefore, if you start an application from scratch and you want to use a form in it, you can include the System.Windows.Forms.dll library to your application. To refer to a form, you can include the System::Windows::Forms namespace in your application. As seen in Lesson 2, to create a form-based application, you can derive a class from Form. Here is an example: #include <windows.h>
#using <System.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Windows::Forms;
public ref class CExercise : public Form
{
public:
CExercise()
{
InitializeComponent();
}
void InitializeComponent()
{
}
};
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
Application::Run(gcnew CExercise());
return 0;
}
|
|
|
||
| Home | Copyright © 2007 FunctionX, Inc. | Next |
|
|
||