ScrollBar Class

 

 

About ScrollBar Class

 

ScrollBar class is mainly used for creating and managing scroll bars.

 

ScrollBar Class Methods

 

ScrollBar.Create( long ParentHandle, long X, long Y, long Width, long Height, long Style, long ExStyle ) creates a scroll bar. If the function succeeds, the return value is a handle to the new control. If the function fails, the return value is 0.

long ParentHandle: a handle to the parent or owner control of the control being created.
long X: x coordinate. You can also use CW_USEDEFAULT constant for this argument.
long Y: y coordinate. You can also use CW_USEDEFAULT constant for this argument.
long Width: width. You can also use CW_USEDEFAULT constant for this argument.
long Height: height. You can also use CW_USEDEFAULT constant for this argument.
long Style: the style of the control being created. This parameter can be a combination of the window styles and scroll bar styles.
long ExStyle: the extended style of the control being created. This parameter can be a combination of the extended window styles.

 

ScrollBar.Exists( long ScrollBarHandle ) returns true if the specified control was created with ScrollBar.Create() method and not destroyed yet or false otherwise. Note that all child controls are destroyed when parent control is destroyed. You can also call Control.Destroy() method for destroying a specific control with all of its children.

long ScrollBarHandle: scroll bar handle.

 

ScrollBar.Count() returns the total number of controls created with ScrollBar.Create() method and not destroyed yet. Note that all child controls are destroyed when parent control is destroyed. You can also call Control.Destroy() method for destroying a specific control with all of its children.

 

ScrollBar.GetHandleByIndex( ulong ScrollBarIndex ) returns the handle from an index if the specified control was created with ScrollBar.Create() method and not destroyed yet or 0 otherwise. Note that all child controls are destroyed when parent control is destroyed. You can also call Control.Destroy() method for destroying a specific control with all of its children. ScrollBarIndex parameter should be less or equal to ScrollBar.Count()-1.

ulong ScrollBarIndex: zero-based index of the scroll bar.

 

ScrollBar.SetRange( long ScrollBarHandle, long Type, long Minimum, long Maximum ) sets the minimum and maximum scroll box positions for the specified scroll bar. The return value is the current position of the scroll box.

long ScrollBarHandle: scroll bar handle or window handle.
long Type: specifies the scroll bar type.
long Minimum: the minimum scrolling position.
long Maximum: the maximum scrolling position.

Type parameter can be one of the following constants.

SB_CTL Sets the range of a scroll bar control. The ScrollBarHandle parameter must be the handle to the scroll bar control.

SB_HORZ Sets the range of a window’s standard horizontal scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL style.

SB_VERT Sets the range of a window’s standard vertical scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_VSCROLL style.

 

ScrollBar.GetRange( long ScrollBarHandle, long Type, long MinimumOrMaximum ) returns the minimum or maximum scroll box positions for the specified scroll bar.

long ScrollBarHandle: scroll bar handle or window handle.
long Type: specifies the scroll bar type.
long MinimumOrMaximum: retrieves the minimum (false) or maximum (true) scroll box position.

Type parameter can be one of the following constants.

SB_CTL Sets the range of a scroll bar control. The ScrollBarHandle parameter must be the handle to the scroll bar control.

SB_HORZ Sets the range of a window’s standard horizontal scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL style.

SB_VERT Sets the range of a window’s standard vertical scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_VSCROLL style.

 

ScrollBar.SetPage( long ScrollBarHandle, long Type, long Page ) sets the page size for the specified scroll bar. The return value is the current position of the scroll box.

long ScrollBarHandle: scroll bar handle or window handle.
long Type: specifies the scroll bar type.
long Page: specifies the page size, in device units. A scroll bar uses this value to determine the appropriate size of the proportional scroll box.

Type parameter can be one of the following constants.

SB_CTL Sets the range of a scroll bar control. The ScrollBarHandle parameter must be the handle to the scroll bar control.

SB_HORZ Sets the range of a window’s standard horizontal scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL style.

SB_VERT Sets the range of a window’s standard vertical scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_VSCROLL style.

 

ScrollBar.GetPage( long ScrollBarHandle, long Type ) returns the page size of the specified scroll bar.

long ScrollBarHandle: scroll bar handle or window handle.
long Type: specifies the scroll bar type.

Type parameter can be one of the following constants.

SB_CTL Sets the range of a scroll bar control. The ScrollBarHandle parameter must be the handle to the scroll bar control.

SB_HORZ Sets the range of a window’s standard horizontal scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL style.

SB_VERT Sets the range of a window’s standard vertical scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_VSCROLL style.

 

ScrollBar.SetPosition( long ScrollBarHandle, long Type, long Position ) sets the position of the scroll box in the specified scroll bar. The return value is the current position of the scroll box.

long ScrollBarHandle: scroll bar handle or window handle.
long Type: specifies the scroll bar type.
long Position: specifies the new position of the scroll box. The position must be within the scrolling range.

Type parameter can be one of the following constants.

SB_CTL Sets the range of a scroll bar control. The ScrollBarHandle parameter must be the handle to the scroll bar control.

SB_HORZ Sets the range of a window’s standard horizontal scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL style.

SB_VERT Sets the range of a window’s standard vertical scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_VSCROLL style.

 

ScrollBar.GetPosition( long ScrollBarHandle, long Type ) returns the position of the scroll box in the specified scroll bar.

long ScrollBarHandle: scroll bar handle or window handle.
long Type: specifies the scroll bar type.

Type parameter can be one of the following constants.

SB_CTL Sets the range of a scroll bar control. The ScrollBarHandle parameter must be the handle to the scroll bar control.

SB_HORZ Sets the range of a window’s standard horizontal scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL style.

SB_VERT Sets the range of a window’s standard vertical scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_VSCROLL style.

 

ScrollBar.SetEnabled( long ScrollBarHandle, long Type, long Enabled ) enables or disables one or both scroll bar arrows. If the arrows are enabled or disabled as specified, the return value is true. If the arrows are already in the requested state or an error occurs, the return value is false.

long ScrollBarHandle: scroll bar handle or window handle.
long Type: specifies the scroll bar type.
long Position: specifies the new position of the scroll box. The position must be within the scrolling range.

Type parameter can be one of the following constants.

SB_BOTH Enables or disables the arrows on the horizontal and vertical scroll bars associated with the specified window. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL and WS_VSCROLL styles.

SB_CTL Sets the range of a scroll bar control. The ScrollBarHandle parameter must be the handle to the scroll bar control.

SB_HORZ Sets the range of a window’s standard horizontal scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL style.

SB_VERT Sets the range of a window’s standard vertical scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_VSCROLL style.

Enabled parameter can be one of the following flags:

ESB_DISABLE_BOTH Disables both arrows on a scroll bar.

ESB_DISABLE_DOWN Disables the down arrow on a vertical scroll bar.

ESB_DISABLE_LEFT Disables the left arrow on a horizontal scroll bar.

ESB_DISABLE_LTUP Disables the left arrow on a horizontal scroll bar or the up arrow of a vertical scroll bar.

ESB_DISABLE_RIGHT Disables the right arrow on a horizontal scroll bar.

ESB_DISABLE_RTDN Disables the right arrow on a horizontal scroll bar or the down arrow of a vertical scroll bar.

ESB_DISABLE_UP Disables the up arrow on a vertical scroll bar.

ESB_ENABLE_BOTH Enables both arrows on a scroll bar.

 

ScrollBar.Show( long ScrollBarHandle, long Type, bool Show ) shows or hides the specified scroll bar. If the function succeeds, the return value is true. If the function fails, the return value is false.

long ScrollBarHandle: scroll bar handle or window handle.
long Type: specifies the scroll bar type.
bool Show: shows (true) or hides (false) the specified scroll bar.

Type parameter can be one of the following constants.

SB_BOTH Enables or disables the arrows on the horizontal and vertical scroll bars associated with the specified window. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL and WS_VSCROLL styles.

SB_CTL Sets the range of a scroll bar control. The ScrollBarHandle parameter must be the handle to the scroll bar control.

SB_HORZ Sets the range of a window’s standard horizontal scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_HSCROLL style.

SB_VERT Sets the range of a window’s standard vertical scroll bar. The ScrollBarHandle parameter must be a WindowHandle with WS_VSCROLL style.

 

Code Example

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Giavapps.Windows.API;

public class CodeExample : MonoBehaviour
{

private long WindowHandle = 0;
private long ScrollBarHandle = 0;

void Start()
{
Plugin.Initialize();//Initializes Giavapps Windows API
WindowHandle = Window.Create(0, 100, 100, 400, 400, Constant.WS_VISIBLE | Constant.WS_SYSMENU | Constant.WS_MINIMIZEBOX | Constant.WS_MAXIMIZEBOX | Constant.WS_SIZEBOX, Constant.WS_EX_TOPMOST);//Creates a new window
Control.SetText(WindowHandle, "Giavapps Windows API");//Sets a new title for the specified window
ScrollBarHandle = ScrollBar.Create(WindowHandle, 10, 10, 150, Control.GetSystemMetrics(Constant.SM_CYHSCROLL), Constant.WS_VISIBLE | Constant.WS_CHILD, 0);//creates a new scroll bar
ScrollBar.SetRange(ScrollBarHandle, Constant.SB_CTL, 0, 100);//sets the range of the scroll bar
ScrollBar.SetPage(ScrollBarHandle, Constant.SB_CTL, 10);//sets the page size of the scroll bar
}

void Update()
{

//Checks if the specified window has been closed
if(Window.GetClosed(WindowHandle))
{
Control.Destroy(WindowHandle);//Destroys the specified window
}

}

void OnApplicationQuit()
{
Plugin.Deinitialize();//Deinitializes Giavapps Windows API
}

}

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Comments are closed.