Chapter 16. Drawing in a Window
WHAT YOU WILL LEARN IN THIS CHAPTER:
What coordinate systems Windows provides for drawing in a window
How to use the capabilities provided by a device context to draw shapes
How and when your program draws in a window
How to define handlers for mouse messages
How to define your own shape classes
How to program the mouse to draw shapes in a window
How to get your program to capture the mouse
How to implement Sketcher drawing capabilities in a C++/CLI program
In this chapter, you will add some meat to the Sketcher application. You'll focus on understanding how you get graphical output displayed in the application window. By the end of this chapter, you'll be able to draw all but one of the elements for which you have added menu items. I'll leave the problem of how to store them in a document until the next chapter.
BASICS OF DRAWING IN A WINDOW
As you learned in Chapter 12, if you want to draw in the client area of a window, you must obey the rules. In general, you must redraw the client area whenever a WM_PAINT
message is sent to your application. This is because there are many events that require your application to redraw the window — such the user's resizing the window you're drawing in, or moving another window to expose part of your window that was previously hidden. The Windows operating system sends information along with the WM_PAINT
message that enables you to determine which part of the client area needs to be re-created. This means that you don't have ...
Get Ivor Horton's Beginning Visual C++® 2010 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.