Microsoft Visual C# 2005 Unleashed
At its core, Windows Forms is a collection of classes all created in the .NET Framework. These classes provide a completely object-oriented encapsulation of creating and manipulating user interface elements such as forms, dialog boxes, user input, enhanced graphical output, and much more. Although you can create virtually any type of application using the .NET Framework SDK and Notepad, Visual Studio includes a plethora of tools and designers that make creating Windows Forms applications a smooth and efficient process that has become even faster and more powerful with the current version of Visual Studio. Figure 34.1 illustrates how Windows Forms fits in with the rest of the .NET Framework, including ASP.NET applications, Windows Service applications, and console applications. Figure 34.1. Windows Forms within the .NET Framework.
Because of the object-oriented nature of the .NET Framework and of Windows Forms, you can accomplish a lot of things with Windows Forms that are virtually impossible without it. For example, you can use inheritance to create forms that inherit from other forms and you can also use inheritance to create your own custom controls that derive from existing controls. For example, with only a few lines of code you could create a text box with your own custom behavior added to it while reusing all of the existing behavior inherent in a text box control. Windows Forms Versus Web Forms
One of the most common tasks when designing a new application is deciding whether to use Windows Forms or Web Forms. The incredible power, flexibility, and scalability of applications developed using the .NET Framework blurs the line between traditional Windows applications and web applications. Windows Update Is Your Friend Ever since Windows Update started pushing the .NET Framework 1.0 to Windows users through its BITS background transfer system, developers of .NET applications have been extremely happy. The reason is that before that time, developers could not count on users already having the .NET Framework on their machines, so deployment of Windows Forms applications was problematic. With .NET 2.0 available through Windows Update, developers can actually make the business assumption that the majority of Windows XP users already have the .NET Framework installed on their PCs. This is a tremendous advantage in the Windows versus web argument in terms of ease of deployment. There are many arguments for and against Windows Forms applications. Most of the positives for Windows Forms include the fact that a Windows Forms application can have a far more interactive and graphically rich interface, whereas Web Forms applications tend to take less time to build. Table 34.1 takes a look at the various concerns for building applications and indicates whether Web Forms or Windows Forms (or both) support such features.
The bottom line is that although the two platforms are radically different in their purpose, they have very few technical differences that would sway a developer in one direction over the other. In most cases, the decision of Windows versus web comes down to the type of application being created and the environment in which it must be deployed. Time to market and interactivity are the only two major categories in which ASP.NET and Windows Forms evince a large difference in ability. The rest of this chapter should get you started building Windows Forms applications. |