O'Reilly logo

.NET Framework Essentials, 3rd Edition by Hoang Lam, Thuan L. Thai

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Windows Forms

If the goal of Microsoft .NET is to embrace the Web, what will happen to conventional Windows applications? It turns out the .NET Framework not only benefits the development of web applications, but improves the way standard Windows applications are built. In this chapter, we provide you with an understanding of what Windows Forms are, how to use Windows Forms .NET classes to create Windows Forms-based applications, and how you can still “embrace the Web” while creating Windows applications.[1]

Introducing Windows Forms

If you have developed Windows applications since the early 1990s, chances are you have used raw Windows APIs such as RegisterClass, CreateWindow, ShowWindow, GetMessage, TranslateMessage, and DispatchMessage. You certainly had a WinMain entry point in your application. Inside this function, you registered your application with Windows, created and showed the window, and handled messages from the system. Every Windows application has to have a message loop that collects Windows messages and dispatches them to the message-handler function that you’ve registered through RegisterClass function. As a developer, much of your job is handling Windows messages, such as WM_CREATE, WM_SIZE, or WM_CLOSE, that you create and pump into the system with PostMessage or SendMessage.

Classic Windows development is tedious and error-prone. The result is that application frameworks were built as an abstraction on top of all these Windows APIs. Frameworks such as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required