VC General control Programming Cslider control

Source: Internet
Author: User
Tags range

The slider control (Slider control) is also called the track strip, which uses a small window with tracks and sliders and a scale on the window to allow the user to select a discrete data or a continuous range of values. Selection of data through the mouse or keyboard, which can be seen in many applications in win98/95, such as the mouse in the Control Panel, the slider can be either horizontal or vertical. The sliding bar controls the following style:

The Tbs_horz slider is horizontally oriented.

The Tbs_vert slider is vertically oriented.

Tbs_left slider is on the left side of the window

Tbs_right Slider is on the right side of the window

Tbs_top slider at top of window

Tbs_bottom slider at the bottom of the window

Tbs_both Slider is positioned on both sides of the window

The Tbs_autoticks slider has a scale, and the default

Tbs_noticks Slider does not have a scale

The tick bars of the slider display a tick mark in each numeric position, and if a value selection interval is displayed on the slider, the style tbs_enableselrange should be used, at which point the selection interval two is no longer a tick mark, but a small triangular symbol. In addition, the use of style tbs_nothumb will make the slider fade.

The slider control is encapsulated in the MFC class Library as CSliderCtrl control, whose main operation is to set scale range, draw tick marks, set selection range and current slide position. When the user interacts, the slider control sends message wm_hscroll to its parent window, so the OnHScroll () member function of the parent window should be overloaded in the application so that the message is properly handled by the system's notification code, The position of the slider and the pointer to the CSliderCtrl object. Since the pointer variable in the OnHScroll () function parameter table is defined as a cscrollbar* type, considering that the same member function is common to the horizontal scroll bar, the pointer variable must be cast to csliderctrl* in the program because the message is actually generated by the slider bar. Type. The message code and meaning of the slider and scroll bar are very similar, such as Tb_bottom, so this method is more reasonable. The SetRange () function is used to set the scope, and the SetPos () function is used to set the current position.

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.