using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.User32;
namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
/// Maximum value for an up-down control.
public const short UD_MAXVAL = 0x7fff;
/// Minimum value for an up-down control.
public const short UD_MINVAL = -UD_MAXVAL;
/// Window class for the up-down control.
public const string UPDOWN_CLASS = "msctls_updown32";
private const int UDN_FIRST = -721;
/// Window messages for the up-down control.
public enum UpDownMessage : uint
{
/// Retrieves acceleration information for an up-down control.
UDM_GETACCEL = WindowMessage.WM_USER + 108,
/// Retrieves the current radix base (that is, either base 10 or 16) for an up-down control.
UDM_GETBASE = WindowMessage.WM_USER + 110,
/// Retrieves the handle to the current buddy window.
UDM_GETBUDDY = WindowMessage.WM_USER + 106,
/// Retrieves the current position of an up-down control with 16-bit precision.
UDM_GETPOS = WindowMessage.WM_USER + 104,
/// Returns the 32-bit position of an up-down control.
UDM_GETPOS32 = WindowMessage.WM_USER + 114,
/// Retrieves the minimum and maximum positions (range) for an up-down control.
UDM_GETRANGE = WindowMessage.WM_USER + 102,
/// Retrieves the 32-bit range of an up-down control.
UDM_GETRANGE32 = WindowMessage.WM_USER + 112,
/// Retrieves the Unicode character format flag for the control.
UDM_GETUNICODEFORMAT = CommonControlMessage.CCM_GETUNICODEFORMAT,
/// Sets the acceleration for an up-down control.
UDM_SETACCEL = WindowMessage.WM_USER + 107,
///
/// Sets the radix base for an up-down control. The base value determines whether the buddy window displays numbers in decimal or
/// hexadecimal digits. Hexadecimal numbers are always unsigned, and decimal numbers are signed.
///
UDM_SETBASE = WindowMessage.WM_USER + 109,
/// Sets the buddy window for an up-down control.
UDM_SETBUDDY = WindowMessage.WM_USER + 105,
/// Sets the current position for an up-down control with 16-bit precision.
UDM_SETPOS = WindowMessage.WM_USER + 103,
/// Sets the position of an up-down control with 32-bit precision.
UDM_SETPOS32 = WindowMessage.WM_USER + 113,
/// Sets the minimum and maximum positions (range) for an up-down control.
UDM_SETRANGE = WindowMessage.WM_USER + 101,
/// Sets the 32-bit range of an up-down control.
UDM_SETRANGE32 = WindowMessage.WM_USER + 111,
///
/// Sets the Unicode character format flag for the control. This message allows you to change the character set used by the
/// control at run time rather than having to re-create the control.
///
UDM_SETUNICODEFORMAT = CommonControlMessage.CCM_SETUNICODEFORMAT,
}
/// Notifications for the up-down control.
public enum UpDownNotification : int
{
///
/// Notifies an up-down control's parent window that the control is releasing mouse capture. This notification is sent in the
/// form of a WM_NOTIFY message.
///
NM_RELEASEDCAPTURE = UDN_FIRST - 1,
///
/// Sent by the operating system to the parent window of an up-down control when the position of the control is about to
/// change.This happens when the user requests a change in the value by pressing the control's up or down arrow. The UDN_DELTAPOS
/// message is sent in the form of a WM_NOTIFY message.
///
UDN_DELTAPOS = UDN_FIRST
}
/// Styles for the up-down control.
[Flags]
public enum UpDownStyle : uint
{
///
/// Positions the up-down control next to the left edge of the buddy window. The buddy window is moved to the right, and its
/// width is decreased to accommodate the width of the up-down control.
///
UDS_ALIGNLEFT = 0x08,
///
/// Positions the up-down control next to the right edge of the buddy window. The width of the buddy window is decreased to
/// accommodate the width of the up-down control.
///
UDS_ALIGNRIGHT = 0x04,
///
/// Causes the up-down control to increment and decrement the position when the UP ARROW and DOWN ARROW keys are pressed.
///
UDS_ARROWKEYS = 0x20,
/// Automatically selects the previous window in the z-order as the up-down control's buddy window.
UDS_AUTOBUDDY = 0x10,
/// Causes the up-down control's arrows to point left and right instead of up and down.
UDS_HORZ = 0x40,
///
/// Causes the control to exhibit "hot tracking" behavior. That is, it highlights the UP ARROW and DOWN ARROW on the control as
/// the pointer passes over them. This style requires Windows 98 or Windows 2000. If the system is running Windows 95 or Windows
/// NT 4.0, the flag is ignored. To check whether hot tracking is enabled, call SystemParametersInfo.
///
UDS_HOTTRACK = 0x100,
/// Does not insert a thousands separator between every three decimal digits.
UDS_NOTHOUSANDS = 0x80,
///
/// Causes the up-down control to set the text of the buddy window (using the WM_SETTEXT message) when the position changes. The
/// text consists of the position formatted as a decimal or hexadecimal string.
///
UDS_SETBUDDYINT = 0x02,
/// Causes the position to "wrap" if it is incremented or decremented beyond the ending or beginning of the range.
UDS_WRAP = 0x01,
}
///
/// Creates an up-down control. Note: This function is obsolete. It is a 16 bit function and cannot handle 32 bit values for range
/// and position.
///
///
/// Type: DWORD
///
/// Window styles for the control. This parameter should include the WS_CHILD, WS_BORDER, and WS_VISIBLE styles,
/// and it may include any of the window styles specific to the up-down control.
///
///
///
/// Type: int
/// Horizontal coordinate, in client coordinates, of the upper-left corner of the control.
///
///
/// Type: int
/// Vertical coordinate, in client coordinates, of the upper-left corner of the control.
///
///
/// Type: int
/// Width, in pixels, of the up-down control.
///
///
/// Type: int
/// Height, in pixels, of the up-down control.
///
///
/// Type: HWND
/// Handle to the parent window of the up-down control.
///
///
/// Type: int
/// Identifier for the up-down control.
///
///
/// Type: HINSTANCE
/// Handle to the module instance of the application creating the up-down control.
///
///
/// Type: HWND
/// Handle to the window associated with the up-down control. If this parameter is NULL, the control has no buddy window.
///
///
/// Type: int
/// Upper limit (range) of the up-down control.
///
///
/// Type: int
/// Lower limit (range) of the up-down control.
///
///
/// Type: int
/// Position of the control.
///
///
/// Type: HWND
///
/// If the function succeeds, the return value is the window handle to the up-down control. If the function fails, the return value
/// is NULL.
///
///
// HWND CreateUpDownControl( DWORD dwStyle, int x, int y, int cx, int cy, HWND hParent, int nID, HINSTANCE hInst, HWND hBuddy, int
// nUpper, int nLower, int nPos); https://msdn.microsoft.com/en-us/library/windows/desktop/bb759977(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb759977")]
public static extern IntPtr CreateUpDownControl(uint dwStyle, int x, int y, int cx, int cy, HWND hParent, int nID, HINSTANCE hInst, HWND hBuddy, int nUpper, int nLower, int nPos);
///
/// Contains information specific to up-down control notification messages. It is identical to and replaces the NM_UPDOWN structure.
///
// typedef struct _NM_UPDOWN { NMHDR hdr; int iPos; int iDelta;} NMUPDOWN, *LPNMUPDOWN; https://msdn.microsoft.com/en-us/library/windows/desktop/bb759893(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb759893")]
public struct NMUPDOWN
{
///
/// Type: NMHDR
/// NMHDR structure that contains additional information about the notification.
///
public NMHDR hdr;
///
/// Type: int
/// Signed integer value that represents the proposed change in the up-down control's position.
///
public int iDelta;
///
/// Type: int
/// Signed integer value that represents the up-down control's current position.
///
public int iPos;
}
/// Contains acceleration information for an up-down control.
// typedef struct { UINT nSec; UINT nInc;} UDACCEL, *LPUDACCEL; https://msdn.microsoft.com/en-us/library/windows/desktop/bb759897(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb759897")]
[StructLayout(LayoutKind.Sequential)]
public struct UDACCEL
{
///
/// Type: UINT
/// Amount of elapsed time, in seconds, before the position change increment specified by nInc is used.
///
public uint nSec;
///
/// Type: UINT
/// Position change increment to use after the time specified by nSec elapses.
///
public uint nInc;
}
}
}