USING A SPIN BUTTON CONTROL
Now you can look at how the spin button can help in Sketcher. The spin button is particularly useful when you want to constrain an input within a given integer range. It’s normally used in association with another control, called a buddy control, that displays the value that the spin button modifies. The associated control is usually an edit control, but it doesn’t have to be.
It would be nice to be able to draw at different viewing scales in Sketcher. If you had a way to change the scale, you could scale up whenever you wanted to fill in the fine detail in your masterpiece, and scale down again when working across the whole vista. You could apply the spin control to managing scaling in a document view. A drawing scale would be a view-specific property, and you would want the element drawing functions to take the current scale of a view into account. Altering the existing code to deal with view-scaling requires rather more work than setting up the control, so first look at how you create a spin button and make it work.
Adding a Scale Menu Item and Toolbar Button
The first step is to provide a means of displaying the scale dialog. Go to Resource View and open the IDR_SketchTYPE menu. You are going to add a Scale menu item to the end of the View menu. Enter the caption for the unused menu item in the View menu as Scale. . . . This item will bring up the scale dialog, so you end the caption with an ellipsis to indicate this. The default ID is ID_VIEW_SCALE ...
Get Ivor Horton's Beginning Visual C++ 2012 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.