Sunday, April 8, 2007

Introducing Windows Forms


Designing Windows Application is simpler and less time consuming with Visual Basic 2005. A number of new facilities and enhancements have been made to assist the developer complete the project in time and with lesser number of errors. Windows Form is the cynosure of the Windows Application. Visual studio 2005 packs more features to the already enriched area of Windows Forms, both at design and run time. Among the several features that have been added some standout as prominent. The management of layout of the form is made easier by providing the snap lines that make it easy to align controls with other controls as the layout is formed. A new deployment technology called ClickOnce for forms is added.
Creating a Windows Application
Understanding Classes, Inheritance, and Namespaces
Using The System.Windows.Forms.Form class
Designing a Form using Windows Forms Designer
Exploring the Forms Designer generated code
Using the Application class
Using the MessageBox class
Setting and Adding Properties to a Windows Form
Using the Visual Designer to set Windows Form Properties
Setting Windows Forms Properties programatically
Adding new Property to a Windows Form
Using Visual Inheritance
Event Handling
Handling Events by attaching a delegate
Handling Events by overriding protected method of base class.
Building graphical interface elements
Understanding The Graphics Object
Understanding The Windows Forms Coordinate System
Drawing Text on a Form
Drawing Shapes
Working with images Building graphical interface elements by using the System.Drawing namespace
In this tutorial we will learn about Graphics Object, The Windows Forms Coordinate System, Drawing Text on a Form, Drawing Shapes and Working with इमागेस

Understanding The Graphics Object
Graphics handling in Visual Basic .NET is based on GDI+ (Graphics Device Interface). A graphics device interface allows you to display graphics on a screen or a printer without having to handle the details of a specific display device. All that you need to do is to make calls to methods supported by the GDI+ classes and those methods make the corresponding calls to individual device drivers as needed to handle the screen or printer.
To create a graphics object
Receive a reference to a graphics object as part of the System.Windows.Forms.PaintEventArgs in the System.Windows.Forms.Control.Paint event of a form or control. This is usually how you obtain a reference to a graphics object when creating painting code for a control.
-or- Call the System.Windows.Forms.Control.CreateGraphics method of a control or form to obtain a reference to a System.Drawing.Graphics object that represents the drawing surface of that control or form. Use this method if you want to draw on a form or control that already exists.
-or- Create a System.Drawing.Graphics object from any object that inherits from System.Drawing.Image. This approach is useful when you want to alter an already existing image.
Let quickly see an example:
Click here for the Sample Code
You can manage the state of the Graphic Object easily as can be seen in the following code fragment
Click here for the Sample Code
The above code generates the output as shown below:

No comments: