![]() ![]() The Canvas control has a method that handles scrolling the image that gets viewed in the control, but it does not work exactly like the Scrollbar control does, so there is some additional work to be done to get the scrolling to work properly. Next, I'll show you what happens when the Scrollbar control to the right of Canvas1 gets moved. There is a trick to this, however, that will be explained shortly. One consequence of setting LiveScroll to true is that you will be able to see the text move up or down as you move the Slider. The LineStep property equals 1, the PageStep property equals 20, and LiveScroll is set to TRue. In this example, the Minimum value is 0 the Maximum value is 100. However, if you have LiveScroll set to TRue, the Value property gets updated as you drag it. Normally, as you drag the Slider control one direction or another, nothing happens until you release it. If you click a location in the Slider, the value of Value increments or decrements by the value set in PageStep. Dragging moves the value of Value up or down by increments set in the LineStep property. There are two ways to move the Slider: the first is to click and drag the Slider, and the second is to click a position in the Control. You can set the Minimum and Maximum values, which proscribes the available range of values for the Slider control. If it is wider than it is long, it moves along the horizontal axis otherwise, it moves along the vertical axis. The direction is set by how you size the control. The Value property represents how far to the right (or down toward the bottom) the Slider has been moved. Slider.Value as Integer Slider.Minimum as Integer Slider.Maximum as Integer Slider.LineStep as Integer Slider.PageStep as Integer Slider.LiveScroll as Boolean The Slider control has the following properties that you access to find out the position of the slider: Drawing text offset vertically by 100 pixels. As a result, the text is drawn in the middle of the Picture instead of at the top of the Picture object.įigure 10.2. In the Figure 10.2, the ImageMover Slider has been moved all the way to the right, meaning that the vertical position starts at 100. The Slider ImageMover (labeled as Vertical in the Window) moves the text up or down within the Canvas. In Figure 10.1, the horizontal position of the text is 0, the vertical position is set to 10, and the width of the String is set to 100. In other words, it determines when the text gets wrapped. ![]() ![]() Finally, the last EditField is used to set the width of the String. Beneath the EditField is a Slider control called ImageMover that sets the vertical position of the text. Below that button is an EditField, which is used to set the horizontal position of the text when it is drawn in Canvas1. The first is labeled Draw Text, and it takes the text from the EditField to the right of it and draws the String in the Canvas1 control. If this is a little unclear, a look at the comments in the code will show you exactly what is happening. In a sense, this is like scrolling, except that the text being displayed is moving within the Graphic object, whereas when using the ScrollBar, the entire image contained by the Graphic object is moving up and down. If text is being displayed, it adjusts the vertical position of the text. If graphics are being displayed, the Slider control will scale the image size, making it larger or smaller. There is also a Slider control that serves two purposes, depending on whether a graphic or text is being displayed. The example will show you how to draw and position both text and images as well as how to scroll a Canvas control using a Scrollbar control. The next example is one whose only reason for being is to provide an example. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |