15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

39<br />

Windows forms<br />

WhaT ’ s in This ChaPTer<br />

➤<br />

➤<br />

➤<br />

➤<br />

➤<br />

The Form class<br />

The class hierarchy of Windows Forms<br />

The controls <strong>and</strong> components that are part of the System.Windows.Forms<br />

namespace<br />

Menus <strong>and</strong> toolbars<br />

Creating user controls<br />

Web - based applications have taken off over the past several years <strong>and</strong> are fast becoming the st<strong>and</strong>ard.<br />

The ability to have all of your application logic reside on a centralized server is very appealing from<br />

an administrator ’ s viewpoint. The downside of Web - based applications is that they typically don ’ t<br />

provide a rich user experience. The .<strong>NET</strong> Framework has given developers the ability to create rich,<br />

smart client applications <strong>and</strong> eliminate the deployment problems <strong>and</strong> “ DLL Hell ” that existed before.<br />

Whether you choose to use Windows Forms or Windows Presentation Foundation (see Chapter 35,<br />

“ Core WPF ” ), client applications are no longer diffi cult to develop or deploy.<br />

Windows Forms will seem familiar if you are a Visual Basic developer. You create new forms (also<br />

known as windows or dialogs) in much the same way that you drag <strong>and</strong> drop controls from a toolbox<br />

onto the Form Designer. However, if your background is in the classic C style of Windows programming,<br />

where you create the message pump <strong>and</strong> monitor messages, or if you ’ re an MFC programmer, you will<br />

find that you ’ re able to get to the lower - level internals if you need to. You can override the window<br />

procedure <strong>and</strong> catch messages, but you might be surprised that you really won ’ t need to very often.<br />

CreaTing a WindoWs forms aPPliCaTion<br />

In this example, you ’ ll create a very simple Windows Forms application (the rest of the chapter uses a<br />

single example application, which can be found in the 03 MainExample folder in the download code<br />

zip fi le.). This fi rst example does not use Visual Studio .<strong>NET</strong>. It has been entered in a text editor <strong>and</strong><br />

compiled using the comm<strong>and</strong> - line compiler.<br />

using System;<br />

using System.Windows.Forms;<br />

namespace NotepadForms<br />

{<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!