. NET Framework drawing techniques for Windows Forms

Source: Internet
Author: User
Tags message queue

Fortunately, when you write a typical Windows Forms program, the drawing, effects, and so on of forms and controls do not need to be specifically considered. Why is that? because by using the. Net Framework, developers can drag a series of controls onto a form, write some simple code associated with the event, and then press F5 in the IDE, a complete form program is born! All controls will draw themselves themselves, The size and scale of the form or control are adjusted freely. What is often used here is a control effect that requires a little attention. Games, custom chart controls, and the writing of screen savers require programmers to write additional code to respond to Paint events.

This article is intended for those Windows Forms developers and helps them to use simple drawing techniques in the application preparation process. First, we'll discuss some basic drawing concepts. Who is in charge of drawing operations? How does a Windows forms program know when to draw? Where are the drawing codes placed? After that, you will also introduce the dual buffer technology for image rendering, and you'll see how it works, and how to use a method to achieve alternating between cached and actually displayed images. Finally, we'll explore the "Smart Invalid Zone," which is actually simply redrawing or clearing the invalid part of the application form, speeding up the program's display and response speed. Hopefully these concepts and techniques will guide readers through this article and help develop Windows Forms programs faster and more efficiently.

Windows Forms uses the GDI + image engine, and all of the drawing code in this article involves using the managed. Net framework to manipulate and use the Windows GDI + image engine.

Although this article is used for basic form drawing operations, it also provides a fast, efficient technique and method for improving program performance. So, before you read through this article, recommend to the reader. NET Framework has a basic understanding, including Windows Forms event handling, simple GDI + objects such as line,pen and brush. Familiar with Visual Basic. NET or C # programming language.

Concept

Windows applications are drawn by themselves, and when a form is "dirty"-that is, the form changes size, or is partially obscured by other program forms, or resumes from a minimized state-the program receives information that needs to be drawn. Windows makes this "dirty" state known as an "invalid (invalidated)" state, which we understand is that it needs to be redrawn, and it gets the drawn information from the Windows message Queue when the Windows Forms program needs to redraw the form. This information passes by. NET Framework is encapsulated and then passed to the Paintbackground and Paint events of the form, in which the appropriate writing of the code specifically for drawing is possible.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.