Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

What is gdl+ in vb.net in hindi?

4 Answer(s) Available
Answer # 1 #

Visual Basic uses statements to specify actions. The most common statement is an expression statement, consisting of an expression to be evaluated, on a single line. As part of that evaluation, functions or subroutines may be called and variables may be assigned new values. To modify the normal sequential execution of statements, Visual Basic provides several control-flow statements identified by reserved keywords. Structured programming is supported by several constructs including two conditional execution constructs (If ... Then ... Else ... End If and Select Case ... Case ... End Select ) and three iterative execution (loop) constructs (Do ... Loop, For ... To, and For Each) . The For ... To statement has separate initialisation and testing sections, both of which must be present. (See examples below.) The For Each statement steps through each value in a list.

In addition, in Visual Basic:

The following is a very simple Visual Basic program, a version of the classic "Hello, World!" example created as a console application:

It prints "Hello, World!" on a command-line window. Each line serves a specific purpose, as follows:

This is a module definition. Modules are a division of code, which can contain any kind of object, like constants or variables, functions or methods, or classes, but can't be instantiated as objects like classes and cannot inherit from other modules. Modules serve as containers of code that can be referenced from other parts of a program.It is common practice for a module and the code file which contains it to have the same name. However, this is not required, as a single code file may contain more than one module and/or class.

This line defines a subroutine called "Main". "Main" is the entry point, where the program begins execution.

This line performs the actual task of writing the output. Console is a system object, representing a command-line interface (also known as a "console") and granting programmatic access to the operating system's standard streams. The program calls the Console method WriteLine, which causes the string passed to it to be displayed on the console.

Instead of Console.WriteLine, one could use MsgBox, which prints the message in a dialog box instead of a command-line window.

This piece of code outputs Floyd's Triangle to the console:

Whether Visual Basic .NET should be considered as just another version of Visual Basic or a completely different language is a topic of debate. There are new additions to support new features, such as structured exception handling and short-circuited expressions. Also, two important data-type changes occurred with the move to VB.NET: compared to Visual Basic 6, the Integer data type has been doubled in length from 16 bits to 32 bits, and the Long data type has been doubled in length from 32 bits to 64 bits. This is true for all versions of VB.NET. A 16-bit integer in all versions of VB.NET is now known as a Short. Similarly, the Windows Forms editor is very similar in style and function to the Visual Basic form editor.

The things that have changed significantly are the semantics—from those of an object-based programming language running on a deterministic, reference-counted engine based on COM to a fully object-oriented language backed by the .NET Framework, which consists of a combination of the Common Language Runtime (a virtual machine using generational garbage collection and a just-in-time compilation engine) and a far larger class library. The increased breadth of the latter is also a problem that VB developers have to deal with when coming to the language, although this is somewhat addressed by the My feature in Visual Studio 2005.

The changes have altered many underlying assumptions about the "right" thing to do with respect to performance and maintainability. Some functions and libraries no longer exist; others are available, but not as efficient as the "native" .NET alternatives. Even if they compile, most converted Visual Basic 6 applications will require some level of refactoring to take full advantage of the new language. Documentation is available to cover changes in the syntax, debugging applications, deployment and terminology.

The following simple examples compare VB and VB.NET syntax. They assume that the developer has created a form, placed a button on it and has associated the subroutines demonstrated in each example with the click event handler of the mentioned button. Each example creates a "Hello, World" message box after the button on the form is clicked.

Visual Basic 6:

VB.NET (MsgBox or MessageBox class can be used):

The following example demonstrates a difference between Visual Basic 6 and VB.NET. Both examples close the active window.

Visual Basic 6:

VB.NET:

The 'cmd' prefix is replaced by the 'btn' prefix, conforming to the new convention previously mentioned.

Visual Basic 6 did not provide common operator shortcuts. The following are equivalent:

Visual Basic 6:

VB.NET:

[4]
Edit
Query
Report
Kiana Stanier
Chief Privacy Officer
Answer # 2 #

This article is the first part of a complete introduction to using GDI+ in Visual Basic .NET.

GDI+ is an unusual part of .NET. It was here before .NET (GDI+ was released with Windows XP) and it doesn't share the same update cycles as the .NET Framework. Microsoft's documentation usually states that Microsoft Windows GDI+ is an API for C/C++ programmers into the Windows OS. But GDI+ also includes the namespaces used in VB.NET for software-based graphics programming.

But it's not the only graphics software provided by Microsoft, especially since Framework 3.0. When Vista and 3.0 were introduced, the totally new WPF was introduced with it. WPF is a high-level, hardware accelerated approach to graphics. As Tim Cahill, Microsoft WPF software team member, puts it, with WPF "you describe your scene using high-level constructs, and we’ll worry about the rest." And the fact that it's hardware accelerated means that you don't have to drag down the operation of your PC processor drawing shapes on the screen. Much of the real work is done by your graphics card.

We've been here before, however. Every "great leap forward" is usually accompanied by a few stumbles backward, and besides, it will take years for WPF to work its way through the zillions of bytes of GDI+ code. That's especially true since WPF just about assumes that you're working with a high-powered system with lots of memory and a hot graphics card. That's why many PCs couldn't run Vista (or at least, use the Vista "Aero" graphics) when it was first introduced. So this series continues to be available on the site for any and all who continue to need to use it.

GDI+ isn't something that you can drag onto a form like other components in VB.NET. Instead, GDI+ objects generally have to be added the old way -- by coding them from scratch! (Although, VB .NET does include a number of very handy code snippets that can really help you.)

To code GDI+, you use objects and their members from a number of .NET namespaces. (At the present time, these are actually just wrapper code for Windows OS objects which actually do the work.)

The namespaces in GDI+ are:

System.Drawing

This is the core GDI+ namespace. It defines objects for basic rendering (fonts, pens, basic brushes, etc.) and the most important object: Graphics. We'll see more of this in just a few paragraphs.

System.Drawing.Drawing2D

This gives you objects for more advanced two-dimensional vector graphics. Some of them are gradient brushes, pen caps, and geometric transforms.

System.Drawing.Imaging

If you want to change graphical images - that is, change the palette, extract image metadata, manipulate metafiles, and so forth - this is the one you need.

System.Drawing.Printing

To render images to the printed page, interact with the printer itself, and format the overall appearance of a print job, use the objects here.

System.Drawing.Text

You can use collections of fonts with this namespace.

The place to start with GDI+ is the Graphics object. Although the things you draw show up on your monitor or a printer, the Graphics object is the "canvas" that you draw on.

But the Graphics object is also one of the first sources of confusion when using GDI+. The Graphics object is always associated with a particular device context. So the first problem that virtually every new student of GDI+ confronts is, "How do I get a Graphics object?"

There are basically two ways:

Here's an example of the first method:

Click Here to display the illustration

Add this into the Form1 class for a standard Windows Application to code it yourself.

In this example, a Graphics object is already created for the form Form1. All your code has to do is create a local instance of that object and use it to draw on the same form. Notice that your code Overrides the OnPaint method. That's why MyBase.OnPaint(e) is executed at the end. You need to make sure that if the base object (the one you're overriding) is doing something else, it gets a chance to do it. Often, your code works without this, but it's a good idea.

You can also get a Graphics object using the PaintEventArgs object handed to your code in the OnPaint and OnPaintBackground methods of a Form. The PrintPageEventArgs passed in a PrintPage event will contain a Graphics object for printing. It's even possible to get a Graphics object for some images. This can let you paint right on the image the same way you would paint on a Form or component.

Another variation of method one is to add an event handler for the Paint event for the form. Here's what that code looks like:

The second method to get a Graphics object for your code uses a CreateGraphics method that is available with many components. The code looks like this:

[3]
Edit
Query
Report
Ina Pleasence
Renal Nursing
Answer # 3 #

Microsoft .NET is Microsoft's recent released development framework. Microsoft .NET not only introduces powerful languages such as C# and VB.NET, it also brings relief to other programmers including graphics, multimedia, web development and speech.

In this article, we'll see basics of GDI+ and how GDI+ is much better interface than its predecessor GDI.

GDI stands for Graphic Device Interface. In Microsoft Windows, GDI is a way to work with paining graphic objects such as painting on windows, forms or other media.

Why do you need GDI? To write GUI application, you need to write some kind of visual interface in the form of windows and controls. There is only one way to see the visual interface - through hardware, such as printer and monitor.

GDI is a set of C++ classes, which provides functionality to render data to a program to hardware devices with the help of device drivers. GDI sits between the program and the hardware and transfer data from one to other

Working with GDI objects in earlier versions of Microsoft products was a pain. I've been programming with Microsoft products (C++ and VB) for over 5 years in C++ and I know the pain of using GDI. If you've ever programmed in C++ or MFC, I bet you must be frustrated using GDI objects too. Have you ever try changing color or font of windows and controls in C++/MFC?

For example, if you want to change the font of a control in C++ (MFC), you need to create a font with its type and then call SetFont. See fig. 1.1.

Fig 1.1.

This is just a simple example. What if you want to change the background color of a toolbar? That's more pain. You need to override OnEraseBackground and get pDC object and so on.

GDI+: A Higher Level API

In Visual Studio .NET, Microsoft has taken care of most of the GDI problems and have made it easy to use. The GDI version of .NET is called GDI+.

GDI+ is next evolution of GDI. It's much better improved and easy to use version of GDI. The best thing about GDI is you don't need to know any details of drivers to render data on printers and monitors. GDI+ takes care of it for you. In other words, GDI was a low-middle level of programming API, where you need to know about devices too, while GDI+ is a higher level of programming model, which provides functions to do work for you.

For example, if you want to set background or foreground color of a control, just set ForeGroundColor property of the control. We'll see this all in more depth later in this tutorial.

Beside the fact that GDI+ API is easier and flexible than GDI, there are many more new features added to the API. Some of the new features GDI+ offers are -

It's hard to cover every thing in this article, but may be in next article of this series, I would cover some of these details.

In this article, first we'll talk about GDI+ classes (also called types in .NET) and interfaces followed by GDI+ objects and then we'll see some sample examples.

In Microsoft .NET library, all classes (types) are grouped in namespaces. A namespace is nothing but a category of similar kind of classes. For example, Forms related classes are stored in Windows.Forms namespace, database related classed are grouped in Data and its sub namespaces such as System.Data.SqlClient, System.Data.OleDb, and System.Data.Common. Similarly, GDI+ classes are grouped under six namespaces, which reside in System.Drawing.dll assembly.

GDI+ is defined in the Drawing namespace and its five sub namespaces. All drawing code resides in System.Drawing.DLL assembly. These namespaces System.Drawing, System.Drawing.Design, System.Drawing.Printing,  System.Drawing.Imaging, System.Drawing.Drawing2D and System.Drawing.Text namespaces.

Now let's take a quick overview of these namespaces.

The System.Drawing namespace provides basic GDI+ functionality. If contains the definition of basic classes such as Brush, Pen, Graphics, Bitmap, Font etc.  The Graphics class plays a major role in GDI+ and contains methods for drawing to the display device. The following table contains some of the System.Drawing namespace classes, structures and their definition.

The System.Drawing.Design namespace is somewhat smaller in compare to the System.Drawing. It xtends design-time user interface (UI) logic and drawing functionality and provides classes for customizing toolbox and editor classes. For beginners there is nothing in this namespace. At present (.NET Beta 2) it has two types of classes -

Editor Classes

BitmapEditor, FontEditor, and ImageEditor are the editor classes. You can use these classes to extend the functionality and provide an option in properties window to edit images and fonts.

ToolBox Classes

ToolBoxItem, ToolBoxItemCollection are two major toolbox classes. By using these classes you can extend the functionality of toolbox and provide the implementation of toolbox items.

This namespace consists classes and enumerations for advanced 2-dimmensional and vector graphics functionality. It contains classes for gradient brushes, matrix and transformation and graphics path. Some of the common classes and enumerations are defined in the following tables -

This namespace provides advanced GDI+ imaging functionality. It defines classes for metafile images. Other classes are encoder and decoder, which let you use any image format. It also defines a class PropertyItem, which let you store and retrieve information about the image files.

The System.Drawing.Printing namespace defines classes for printing functionality in your applications. Some of its major classes are defines in the following table -

Even though most of the font's functionality is defined in System.Drawing namespace, this provides advanced typography functionality such as creating collection of fonts. Right now, this class has only three classes - FontCollection, InstalledFontCollection, and PrivateFontCollection. As you can see all of these classes are self-explanatory

The Graphics class is center of all GDI+ classes. After discussing graphics class, I'll discuss some common GDI+ objects and their representation and then we'll see some sample applications to apply this theory in our applications and how it works.

The Graphics class plays a vital role in GDI+. No matter where you go, you go through this class ;). The Graphics class encapsulates GDI+ drawing surfaces. Before drawing any object (for example circle, or rectangle ) we have to create a surface using Graphics class.

There're different of ways to get a graphics object in your application. You can either get a graphics object on your form's paint event or by overriding OnPaint() method of a form. These both have one argument of type System.Windows.Forms.PaintEventArgs. You call its Graphics member to get the graphics object in your application. For example:

Now you've the Graphics object. Now you can do any thing you want. The Graphics class has tons of methods to drawing graphics objects such as fonts, pens, lines, path and polygons, images and ellipse and so on. Some of the graphics class members are described in the following table -

Now say, if you want to draw an ellipse using the same method we've described above, you override OnPaint method and write the following code -

That will draw a ellipse. Before we see more samples, let's discuss some GDI+ objects.

The graphics objects are the objects, which you use to draw your GDI+ items such as images, lines, rectangles, and path. For example, to fill a rectangle with a color, you need a color object and type of style you want to fill such as solid, texture and so on.

There are four common GDI+ objects, which you'll be using throughout your GDI+ life to fill GDI+ items. The major objects are:

In GDI+, each of these object is represented by a class (also called type).

A pen draws a line of specified width and style. You always use Pen constructor to create a pen. The constructor initializes a new instance of the Pen class. You can initialize it with a color or brush.

Initializes a new instance of the Pen class with the specified color.

Initializes a new instance of the Pen class with the specified Brush.

Initializes a new instance of the Pen class with the specified Brush and width.

Initializes a new instance of the Pen class with the

specified Color and Width.

Here is one example:

Some of its most commonly used properties are:

[2]
Edit
Query
Report
Bunny Arend
Comedian
Answer # 4 #

GDI+ is the way to draw shapes, fonts, images or generally anything graphic in Visual Basic.

[0]
Edit
Query
Report
Luv Raj
Fish Hatchery Specialist