Windows Applications in .NET

 
Chapter 7 - Windows Applications
bySimon Robinsonet al.
Wrox Press 2002
  

It is important to understand the differences between rich and thin clients , as this is crucial to understanding why Windows applications are considered rich clients. A thin client does not require much installation or configuration before using the application itself. The classic example of this is a web application - all that is required to utilize the functionality is a Web browser and an Internet connection. Rich clients, sometimes called fat clients, require some form of installation or configuration on the client machine. Businesses have moved away from rich clients precisely for this reason - installing and upgrading an application installed on thousands of separate desktops can be a daunting challenge! However, because rich clients run on the client they can take full advantage of the environment and processing power of the client machine. This allows developers to create a much more interactive and user-friendly experience for the user .

Before .NET, developers had several choices in building a Windows application. They could go all the way down to the API layer and build a C or C++ application using the Win32 API. This is a very difficult and time consuming task, and not many businesses can afford to spend the time required to develop applications at this layer. Because of this, several environments have evolved to provide an easier interface into the Win32 API and allow developers to be more productive. Microsoft Foundation Classes (MFC) is a productivity class library using C++ that encapsulates the Win32 API. Visual Basic is a rapid application development tool utilizing a derivation of the Basic programming language that allows developers to create Windows applications relatively quickly. However, neither of these solutions utilizes the .NET Framework or the CLR.

The .NET Framework contains a new productivity layer that encapsulates the Win32 API, and much like MFC and Visual Basic, it allows for easier and more efficient development of Windows applications. This environment is called Windows Forms; it allows developers to create highly interactive and rich Windows applications using any .NET language. We will be examining the Windows Forms environment extensively in this chapter.

By using .NET itself to create Windows applications, developers gain access to the many new and exciting features exposed by .NET. All of the namespaces and classes available in the .NET Framework can be utilized within a .NET rich client. In addition, the application can be developed in any of the many .NET languages; different components of the application can even utilize different languages.

Almost all of the functionality we will be examining in this chapter is exposed through classes contained within the System.Windows.Forms namespace. This is an extremely large namespace containing many classes and additional namespaces, all of which facilitate creating Windows applications. The following diagram displays just some of the many classes that derive from System.Windows.Forms.Control . This object acts as a base class for the majority of classes within this namespace, and contains much of the basic functionality for interface display and interaction with the user:

click to expand

In this diagram, if a class is not prefixed with a namespace it is contained within the System.Windows.Forms namespace. Not displayed are the incredibly large number of classes that derive from Control , all of which provide specialized functionality. These provide access to the extensive library of Windows Forms controls. This diagram provides an overview of how the hierarchy is laid out and how the Form and Control classes fit into the big picture.

  • System.Windows.Forms.Control  - this acts as the base class for the majority of classes in the namespace. It contains very basic functionality for processing keyboard and mouse input and processing Windows messages.

  • System.Windows.Forms.ButtonBase  - this class supports the basic functionality of a button, which each of the three derived classes utilizes in different ways.

  • System.Windows.Forms.TextBoxBase  - again, this is a generic base class that is used to provide common functionality and properties to the derived classes. Both the TextBox and RichTextBox classes utilize the functionality provided by TextBoxBase .

  • System.Windows.Forms.ScrollableControl  - this is another base class that provides support for derived classes. This class manages the generation and display of scroll bars to enable the user to have access to the whole of a display.

  • System.Windows.Forms.ContainerControl  - this class manages the functionality required for a control to act as a container for other controls.

  • System.Windows.Forms.Panel  - this is another control that can contain additional controls, but unlike the ContainerControl class it simply groups controls. A perfect example is a set of mutually exclusive RadioButtons : the Panel groups the RadioButtons into sets.

  • System.Windows.Forms.Form  - this is the class that deals with creating and displaying windows. This class can be used to create any kind of window: standard, toolbox, borderless, even modal dialog boxes and multi-document interfaces.

  • System.Windows.Forms.UserControl  - this is the class that can be used to derive from when creating a custom control to be used in multiple places in an application or organization. This class will be covered extensively later in the chapter.

  


Professional C#. 2nd Edition
Performance Consulting: A Practical Guide for HR and Learning Professionals
ISBN: 1576754359
EAN: 2147483647
Year: 2002
Pages: 244

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net