| Header file: | trackbar.h |
| Object name: | fTRACKBAR |
| Object index: | 1 of 1 Object |
The fTRACKBAR is a handy little component that will allow the user to select a number from a slider. You can use it (and it is used) for volume controls and other fancy sound-oriented things. Enjoy!
This component is derived from _GUIBASE, and inherits the properties from that.
One definition before we go on: tick marks are marks around the slider that indicate the distance that the trackbar has travelled. You can see them marked in the picture on the left. These ticks are highly configurable - you can move them, add them, have them automatically assigned - or not have them at all. The choice is yours!
| Name | Description | Value |
| Name | Description | Value |
| tbUsual | This style is just the usual style, which only makes the window visible. To make the trackbar do something, mix it with the other styles following. | AvWind |
| The following options are a little different. Whereas the above options are a mixture of styles to create one type of object, the following styles are by themselves. You can mix them up to make more customised objects. You mix the styles with the OR (|) operator. You can even mix them with the above styles to enhance them further. Mix and match away! | ||
| tbAutoTickMarks | This style makes the trackbar automatically fix its tick marks on the bottom. The tick marks will automatically be sized to fit the range best. | TBS_AUTOTICKS |
| tbTicksOnBothSides | This style makes tick marks appear on both sides of the trackbar. | TBS_BOTTOM |
|
tbTicksBottom tbTicksLeft tbTicksRight tbTicksTop | These styles makes tick marks appear on a certain side of the trackbar. |
TBS_BOTTOM TBS_LEFT TBS_RIGHT TBS_TOP |
| tbEnableSelection | This style allows the user to make a 'selection' of the trackbar. The trackbar will then have a white box underneath, which the user can select a portion of. This can be useful for things like sound files - selecting a certain portion of them to use. | TBS_ENABLESELRANGE |
|
tbHorizontal tbVertical | These styles align the trackbar a certain way, based on which style you use. |
TBS_HORZ TBS_VERT |
| tbNoSlider | This style forces the trackbar not to have a slider. Instead, there is just a little dot that indicates where the trackbars' slider is. | TBS_NOTHUMB |
| tbNoTicks | This style forces the trackbar not to display any ticks at all. | TBS_NOTICKS |
| Prototype | Description |
| void SetPosition(int Position); | This function sets the position of the trackbar. |
| int GetPosition(void); | This function returns the position of the trackbar. |
| void SetRange(int Min, int Max); | This function sets the range of the trackbar. Once this range is set, the position can be anywhere inside this range. |
|
void SetMaxValue(int Max); void SetMinValue(int Min); | These functions set the Maximum and Minimum values, respectively. |
|
int GetMaxValue(void); int GetMinValue(void); | These functions return the Maximum and Minimum values, respectively. |
| void SetLineValue(int Length); | This function sets how much to increase the value by each time the trackbar slider is moved. For example, you could make this 2, and then whenever the trackbar slider is moved one unit, it would actually move 2 units. Also, if the trackbar has focus and the cursor keys are used, the position will increase or decrease by this value. |
| int GetLineValue(void); | This function returns the line value, which can be set with the above function. Please see the above function for a description of line value. |
| void SetPageValue(int Length); | When the user clicks on the trackbar in an area that isn't the slider, the slider jumps up a bit. With this function, you can set how far the slider jumps when the user does this. Also, if the trackbar has focus and the page up / page down keys are pressed, the position will change by this amount. |
| int GetPageValue(void); | This function returns the page value - see the above function for an explanation of what that is. |
| void AddTick(int Position); | This function adds a tick to the trackbar at the specified location. Use this when you want to set your own ticks - but make sure that the trackbar does not have the autotick style. |
| void SetTickFrequency(int Pos, int Frequency); | This function is a little faster than manually setting ticks. Pos is the position to start at, and Frequency is the distance between each tick. |
| void ClearTicks(void); | Want to start the ticks again? Clear them with this function. |
| int GetNumberTicks(void); | This function returns the total number of ticks on the trackbar. |
| int* GetPointerToTicks(void); | This function will return a pointer to an array of int values, each specifying the location of a tick. I think you can directly modify these, but do so with caution! Going outside the range will result in an access violation! |
| int GetTickPosition(int ID); | This function returns the location of a specific tick mark. |
| int GetTickCoordinate(int ID); | This function returns the X or Y coordinate of a particular tick mark. It will be either the X or Y value, depending on the orientation of the trackbar. |
| void SetThumbLength(int Length); | This function sets the length of the slider, or 'thumb'. The value is in pixels. |
| int GetThumbLength(void); | This function returns the length of the slider, or 'thumb'. The value is in pixels. |
| void SetSelection(int Start, int Stop); | If you create a trackbar that can accept selections - this is how to set that selection. Start indicates the start of the selection, and Stop indicates the end of that selection. |
| void SetSelectionStart(int Start); | This function sets the start of the selection. |
| int GetSelectionStart(void); | This function returns the start location of the selection. |
| void SetSelectionEnd(int End); | This function sets the location of the end of the selection. |
| int GetSelectionEnd(void); | This function returns the end of the selection. |
| void ClearSelection(void); | This function clears the selection altogether. |
There are no official events sent by this component... however, it might be very useful to know when it is updated. There are other events inherited from _GUIBASE which you can use to determine when the trackbar has changed. Sorry about that.
The following snippet gives a basic idea of how to use this component.
//Create a simple trackbar...
fTRACKBAR Trackbar;
Trackbar.CreateWin(Window.GetHandle(), "Pointless Caption",
TRACKBAR_ID, tbNormal, tbUsual | tbAutoTickMarks);
//That's about all that needs to be shown!
//Just move the trackbar to wherever you want it to go!
| Back to index | The FreeFoote Foundation Classes Documentation |