Purpose |
Add a scroll bar control to a dialog. A scroll bar allows the user to scroll information left and right, or up and down. Your program, in response to notification messages from the scroll bar control, must do the actual scrolling itself. | ||||||||||||||||||
Syntax |
CONTROL ADD SCROLLBAR, hDlg, id&, txt$, x, y, xx, yy [, [style&] [, [exstyle&]]] [[,] CALL callback] | ||||||||||||||||||
hDlg |
Handle of the dialog in which the scroll bar will be created. The dialog will become the parent of the control. | ||||||||||||||||||
id& |
Unique identifier for the control in the range 1 to 65535, frequently specified with numeric equates for clarity of the code. For example, the equate %ReportScrollUpDown is more informative than a literal value such as 497. Best practice suggests identifiers should start at 100 to avoid conflict with any of the standard predefined identifiers. | ||||||||||||||||||
txt$ |
Text to associate with the scroll bar. A scroll bar control does not
display text, so it is possible to use this
| ||||||||||||||||||
x, y |
| ||||||||||||||||||
xx |
Integer expression, variable, or numeric literal value, specifying the width of the control. The width is given in the same terms (pixels or dialog units) as the parent dialog. The most common value used in the Microsoft Dialog Editor and Visual Studio is 10 dialog units. | ||||||||||||||||||
yy |
Integer expression, variable, or numeric literal value, specifying the height of the control. The height is given in the same terms (pixels or dialog units) as the parent dialog. The most common value used in the Microsoft Dialog Editor and Visual Studio is 11 dialog units. | ||||||||||||||||||
style& |
Primary style of the scroll bar control. The default scroll bar style is %SBS_HORZ; however, if the width is less than the height, the control is automatically switched to %SBS_VERT, regardless of whether %SBS_HORZ is specified or not. If %SBS_VERT is specified, the control will always be created as a vertical scroll bar regardless of the dimensions of the control. The default style is used if both the primary and extended style parameters are omitted from the statement. For example: CONTROL ADD SCROLLBAR, hDlg, id&, txt$, 100, 100, 150, 14, , , _ CALL Scrollbar1Callback() ' Use default styles Custom style values replace the default values. That is, they are not additional to the default style values - your code must specify all necessary primary and extended style parameters. The primary scroll bar style value can be a combination of any values below, combined together with the OR operator to form a bitmask:
| ||||||||||||||||||
exstyle& |
Extended style of the scroll bar control. The default extended scroll bar style comprises %WS_EX_LEFT. The default extended style is used if both the primary and extended style parameters are omitted from the CONTROL ADD SCROLLBAR statement, in the same manner as style& above. The extended scroll bar style value can be a combination of any values below, combined together with the OR operator to form a bitmask:
| ||||||||||||||||||
callback |
Optional name of a Callback Function that receives all %WM_COMMAND and %WM_NOTIFY messages for the control. See the #MESSAGES metastatement to choose which messages will be received. If a callback for the control is not designated, you must create a dialog Callback Function to process messages from your control. If the Callback Function processes a message, it should return TRUE (non-zero) to prevent the message being passed unnecessarily to the dialog callback (if one exists). The dialog callback should also return TRUE non-zero) if the notification message is processed by that Callback Function. Otherwise, the DDT engine processes unhandled messages automatically. | ||||||||||||||||||
Remarks |
If the ampersand (&) character appears in the txt$ parameter, the letter that follows will become a control accelerator (hot-key) to enable the user to directly select the scroll bar control, simply by pressing and holding the ALT key while pressing the specified hot-key. For example, "&9" makes ALT+9 the hot-key. The actual text in txt$ is not displayed in a scroll bar control. When the user clicks on a scroll bar, drags the thumb (also called the scroll box), or initiates a scroll event with the keyboard, a message is sent to the Callback Function designated for the control. If there is no Callback Function designated, the message is sent to the callback for the dialog. The following notifications are sent to the Callback Function:
When a Callback Function receives a %WM_HSCROLL or %WM_VSCROLL message, it should retrieve and set the scroll bar control settings through the GetScrollInfo and SetScrollInfo API function calls. Be sure to use the %SB_CTL flag with these API functions, rather than the %SB_HORZ or %SB_VERT flags. | ||||||||||||||||||
See also |
Dynamic Dialog Tools, CONTROL HANDLE, CONTROL SEND, CONTROL SET COLOR, SCROLLBAR |