using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32
{
/// The owner-draw required drawing action.
[PInvokeData("winuser.h", MSDNShortId = "NS:winuser.tagDRAWITEMSTRUCT")]
[Flags]
public enum ODA : uint
{
/// The entire control needs to be drawn.
ODA_DRAWENTIRE = 0x0001,
/// The selection status has changed. The itemState member should be checked to determine the new selection state.
ODA_SELECT = 0x0002,
///
/// The control has lost or gained the keyboard focus. The itemState member should be checked to determine whether the control
/// has the focus.
///
ODA_FOCUS = 0x0004,
}
/// The visual state of the item after the current drawing action takes place.
[PInvokeData("winuser.h", MSDNShortId = "NS:winuser.tagDRAWITEMSTRUCT")]
[Flags]
public enum ODS : uint
{
/// The menu item's status is selected.
ODS_SELECTED = 0x0001,
/// The item is to be grayed. This bit is used only in a menu.
ODS_GRAYED = 0x0002,
/// The item is to be drawn as disabled.
ODS_DISABLED = 0x0004,
/// The menu item is to be checked. This bit is used only in a menu.
ODS_CHECKED = 0x0008,
/// The item has the keyboard focus.
ODS_FOCUS = 0x0010,
/// The item is the default item.
ODS_DEFAULT = 0x0020,
/// The drawing takes place in the selection field (edit control) of an owner-drawn combo box.
ODS_COMBOBOXEDIT = 0x1000,
/// The item is being hot-tracked, that is, the item will be highlighted when the mouse is on the item.
ODS_HOTLIGHT = 0x0040,
/// The item is inactive and the window associated with the menu is inactive.
ODS_INACTIVE = 0x0080,
/// The control is drawn without the keyboard accelerator cues.
ODS_NOACCEL = 0x0100,
/// The control is drawn without focus indicator cues.
ODS_NOFOCUSRECT = 0x0200,
}
/// The owner-draw control type.
[PInvokeData("winuser.h", MSDNShortId = "NS:winuser.tagDRAWITEMSTRUCT")]
public enum ODT
{
/// Owner-drawn menu item
ODT_MENU = 1,
/// Owner-drawn list box
ODT_LISTBOX = 2,
/// Owner-drawn combo box
ODT_COMBOBOX = 3,
/// Owner-drawn button
ODT_BUTTON = 4,
/// Owner-drawn static control
ODT_STATIC = 5,
/// Owner-drawn header
ODT_HEADER = 100,
/// Tab control
ODT_TAB = 101,
/// List-view control
ODT_LISTVIEW = 102,
}
///
/// Supplies the identifiers and application-supplied data for two items in a sorted, owner-drawn list box or combo box.
///
/// Whenever an application adds a new item to an owner-drawn list box or combo box created with the CBS_SORT or LBS_SORT style, the
/// system sends the owner a WM_COMPAREITEM message. The lParam parameter of the message contains a long pointer to a
/// COMPAREITEMSTRUCT structure. Upon receiving the message, the owner compares the two items and returns a value indicating
/// which item sorts before the other.
///
///
// https://docs.microsoft.com/ko-kr/windows/win32/api/winuser/ns-winuser-compareitemstruct typedef struct tagCOMPAREITEMSTRUCT {
// UINT CtlType; UINT CtlID; HWND hwndItem; UINT itemID1; ULONG_PTR itemData1; UINT itemID2; ULONG_PTR itemData2; DWORD dwLocaleId;
// } COMPAREITEMSTRUCT, *PCOMPAREITEMSTRUCT, *LPCOMPAREITEMSTRUCT;
[PInvokeData("winuser.h", MSDNShortId = "NS:winuser.tagCOMPAREITEMSTRUCT")]
[StructLayout(LayoutKind.Sequential)]
public struct COMPAREITEMSTRUCT
{
///
/// Type: UINT
/// An ODT_LISTBOX (owner-drawn list box) or ODT_COMBOBOX (an owner-drawn combo box).
///
public ODT CtlType;
///
/// Type: UINT
/// The identifier of the list box or combo box.
///
public uint CtlID;
///
/// Type: HWND
/// A handle to the control.
///
public HWND hwndItem;
///
/// Type: UINT
///
/// The index of the first item in the list box or combo box being compared. This member will be –1 if the item has not been
/// inserted or when searching for a potential item in the list box or combo box.
///
///
public uint itemID1;
///
/// Type: ULONG_PTR
///
/// Application-supplied data for the first item being compared. (This value was passed as the lParam parameter of the message
/// that added the item to the list box or combo box.)
///
///
public IntPtr itemData1;
///
/// Type: UINT
/// The index of the second item in the list box or combo box being compared.
///
public uint itemID2;
///
/// Type: ULONG_PTR
///
/// Application-supplied data for the second item being compared. This value was passed as the lParam parameter of the message
/// that added the item to the list box or combo box. This member will be –1 if the item has not been inserted or when searching
/// for a potential item in the list box or combo box.
///
///
public IntPtr itemData2;
///
/// Type: DWORD
/// The locale identifier. To create a locale identifier, use the MAKELCID macro.
///
public LCID dwLocaleId;
}
///
///
/// Describes a deleted list box or combo box item. The lParam parameter of a WM_DELETEITEM message contains a pointer to this
/// structure. When an item is removed from a list box or combo box or when a list box or combo box is destroyed, the system sends
/// the WM_DELETEITEM message to the owner for each deleted item.
///
///
/// The system sends a WM_DELETEITEM message only for items deleted from an owner-drawn list box (with the LBS_OWNERDRAWFIXED or
/// LBS_OWNERDRAWVARIABLE style) or owner-drawn combo box (with the CBS_OWNERDRAWFIXED or CBS_OWNERDRAWVARIABLE style).
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-deleteitemstruct typedef struct tagDELETEITEMSTRUCT { UINT
// CtlType; UINT CtlID; UINT itemID; HWND hwndItem; ULONG_PTR itemData; } DELETEITEMSTRUCT, *PDELETEITEMSTRUCT, *LPDELETEITEMSTRUCT;
[PInvokeData("winuser.h", MSDNShortId = "NS:winuser.tagDELETEITEMSTRUCT")]
[StructLayout(LayoutKind.Sequential)]
public struct DELETEITEMSTRUCT
{
///
/// Type: UINT
/// Specifies whether the item was deleted from a list box or a combo box. One of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// ODT_LISTBOX
/// A list box.
///
/// -
/// ODT_COMBOBOX
/// A combo box.
///
///
///
public ODT CtlType;
///
/// Type: UINT
/// The identifier of the list box or combo box.
///
public uint CtlID;
///
/// Type: UINT
/// The index of the item in the list box or combo box being removed.
///
public uint itemID;
///
/// Type: HWND
/// A handle to the control.
///
public HWND hwndItem;
///
/// Type: ULONG_PTR
///
/// Application-defined data for the item. This value is passed to the control in the lParam parameter of the message that adds
/// the item to the list box or combo box.
///
///
public IntPtr itemData;
}
///
/// Provides information that the owner window uses to determine how to paint an owner-drawn control or menu item. The owner window
/// of the owner-drawn control or menu item receives a pointer to this structure as the lParam parameter of the WM_DRAWITEM message.
///
/// Some control types, such as status bars, do not set the value of CtlType.
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-drawitemstruct typedef struct tagDRAWITEMSTRUCT { UINT
// CtlType; UINT CtlID; UINT itemID; UINT itemAction; UINT itemState; HWND hwndItem; HDC hDC; RECT rcItem; ULONG_PTR itemData; }
// DRAWITEMSTRUCT, *PDRAWITEMSTRUCT, *LPDRAWITEMSTRUCT;
[PInvokeData("winuser.h", MSDNShortId = "NS:winuser.tagDRAWITEMSTRUCT")]
[StructLayout(LayoutKind.Sequential)]
public struct DRAWITEMSTRUCT
{
///
/// Type: UINT
/// The control type. This member can be one of the following values. See Remarks.
///
///
/// Value
/// Meaning
///
/// -
/// ODT_BUTTON
/// Owner-drawn button
///
/// -
/// ODT_COMBOBOX
/// Owner-drawn combo box
///
/// -
/// ODT_LISTBOX
/// Owner-drawn list box
///
/// -
/// ODT_LISTVIEW
/// List-view control
///
/// -
/// ODT_MENU
/// Owner-drawn menu item
///
/// -
/// ODT_STATIC
/// Owner-drawn static control
///
/// -
/// ODT_TAB
/// Tab control
///
///
///
public ODT CtlType;
///
/// Type: UINT
/// The identifier of the combo box, list box, button, or static control. This member is not used for a menu item.
///
public uint CtlID;
///
/// Type: UINT
///
/// The menu item identifier for a menu item or the index of the item in a list box or combo box. For an empty list box or combo
/// box, this member can be
/// -1
/// . This allows the application to draw only the focus rectangle at the coordinates specified by the rcItem member even
/// though there are no items in the control. This indicates to the user whether the list box or combo box has the focus. How
/// the bits are set in the itemAction member determines whether the rectangle is to be drawn as though the list box or
/// combo box has the focus.
///
///
public uint itemID;
///
/// Type: UINT
/// The required drawing action. This member can be one or more of the values.
///
///
/// Value
/// Meaning
///
/// -
/// ODA_DRAWENTIRE
/// The entire control needs to be drawn.
///
/// -
/// ODA_FOCUS
///
/// The control has lost or gained the keyboard focus. The itemState member should be checked to determine whether the control
/// has the focus.
///
///
/// -
/// ODA_SELECT
/// The selection status has changed. The itemState member should be checked to determine the new selection state.
///
///
///
public ODA itemAction;
///
/// Type: UINT
///
/// The visual state of the item after the current drawing action takes place. This member can be a combination of the values
/// shown in the following table.
///
///
///
/// Value
/// Meaning
///
/// -
/// ODS_CHECKED
/// The menu item is to be checked. This bit is used only in a menu.
///
/// -
/// ODS_COMBOBOXEDIT
/// The drawing takes place in the selection field (edit control) of an owner-drawn combo box.
///
/// -
/// ODS_DEFAULT
/// The item is the default item.
///
/// -
/// ODS_DISABLED
/// The item is to be drawn as disabled.
///
/// -
/// ODS_FOCUS
/// The item has the keyboard focus.
///
/// -
/// ODS_GRAYED
/// The item is to be grayed. This bit is used only in a menu.
///
/// -
/// ODS_HOTLIGHT
/// The item is being hot-tracked, that is, the item will be highlighted when the mouse is on the item.
///
/// -
/// ODS_INACTIVE
/// The item is inactive and the window associated with the menu is inactive.
///
/// -
/// ODS_NOACCEL
/// The control is drawn without the keyboard accelerator cues.
///
/// -
/// ODS_NOFOCUSRECT
/// The control is drawn without focus indicator cues.
///
/// -
/// ODS_SELECTED
/// The menu item's status is selected.
///
///
///
public ODS itemState;
///
/// Type: HWND
///
/// A handle to the control for combo boxes, list boxes, buttons, and static controls. For menus, this member is a handle to the
/// menu that contains the item.
///
///
public HWND hwndItem;
///
/// Type: HDC
/// A handle to a device context; this device context must be used when performing drawing operations on the control.
///
public HDC hDC;
///
/// Type: RECT
///
/// A rectangle that defines the boundaries of the control to be drawn. This rectangle is in the device context specified by the
/// hDC member. The system automatically clips anything that the owner window draws in the device context for combo
/// boxes, list boxes, and buttons, but does not clip menu items. When drawing menu items, the owner window must not draw
/// outside the boundaries of the rectangle defined by the rcItem member.
///
///
public RECT rcItem;
///
/// Type: ULONG_PTR
///
/// The application-defined value associated with the menu item. For a control, this parameter specifies the value last assigned
/// to the list box or combo box by the LB_SETITEMDATA or CB_SETITEMDATA message. If the list box or combo box has the
/// LBS_HASSTRINGS or CBS_HASSTRINGS style, this value is initially zero. Otherwise, this value is initially the value that was
/// passed to the list box or combo box in the lParam parameter of one of the following messages:
///
///
/// -
/// CB_ADDSTRING
///
/// -
/// CB_INSERTSTRING
///
/// -
/// LB_ADDSTRING
///
/// -
/// LB_INSERTSTRING
///
///
/// If
/// CtlType
/// is
/// ODT_BUTTON
/// or
/// ODT_STATIC
/// ,
/// itemData
/// is zero.
///
public IntPtr itemData;
}
///
/// Informs the system of the dimensions of an owner-drawn control or menu item. This allows the system to process user interaction
/// with the control correctly.
///
///
///
/// The owner window of an owner-drawn control receives a pointer to the MEASUREITEMSTRUCT structure as the lParam parameter
/// of a WM_MEASUREITEM message. The owner-drawn control sends this message to its owner window when the control is created. The
/// owner then fills in the appropriate members in the structure for the control and returns. This structure is common to all
/// owner-drawn controls except the owner-drawn button control whose size is predetermined by its window.
///
///
/// If an application does not fill the appropriate members of MEASUREITEMSTRUCT, the control or menu item may not be drawn properly.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-measureitemstruct typedef struct tagMEASUREITEMSTRUCT {
// UINT CtlType; UINT CtlID; UINT itemID; UINT itemWidth; UINT itemHeight; ULONG_PTR itemData; } MEASUREITEMSTRUCT,
// *PMEASUREITEMSTRUCT, *LPMEASUREITEMSTRUCT;
[PInvokeData("winuser.h", MSDNShortId = "NS:winuser.tagMEASUREITEMSTRUCT")]
[StructLayout(LayoutKind.Sequential)]
public struct MEASUREITEMSTRUCT
{
///
/// Type: UINT
/// The control type. This member can be one of the values shown in the following table.
///
///
/// Value
/// Meaning
///
/// -
/// ODT_COMBOBOX
/// Owner-drawn combo box
///
/// -
/// ODT_LISTBOX
/// Owner-drawn list box
///
/// -
/// ODT_LISTVIEW
/// Owner-draw list-view control
///
/// -
/// ODT_MENU
/// Owner-drawn menu
///
///
///
public ODT CtlType;
///
/// Type: UINT
/// The identifier of the combo box or list box. This member is not used for a menu.
///
public uint CtlID;
///
/// Type: UINT
///
/// The identifier for a menu item or the position of a list box or combo box item. This value is specified for a list box only
/// if it has the LBS_OWNERDRAWVARIABLE style; this value is specified for a combo box only if it has the CBS_OWNERDRAWVARIABLE style.
///
///
public uint itemID;
///
/// Type: UINT
///
/// The width, in pixels, of a menu item. Before returning from the message, the owner of the owner-drawn menu item must fill
/// this member.
///
///
public uint itemWidth;
///
/// Type: UINT
///
/// The height, in pixels, of an individual item in a list box or a menu. Before returning from the message, the owner of the
/// owner-drawn combo box, list box, or menu item must fill out this member.
///
///
public uint itemHeight;
///
/// Type: ULONG_PTR
///
/// The application-defined value associated with the menu item. For a control, this member specifies the value last assigned to
/// the list box or combo box by the LB_SETITEMDATA or CB_SETITEMDATA message. If the list box or combo box has the
/// LB_HASSTRINGS or CB_HASSTRINGS style, this value is initially zero. Otherwise, this value is initially the value passed to
/// the list box or combo box in the lParam parameter of one of the following messages:
///
///
/// -
/// CB_ADDSTRING
///
/// -
/// CB_INSERTSTRING
///
/// -
/// LB_ADDSTRING
///
/// -
/// LB_INSERTSTRING
///
///
///
public IntPtr itemData;
}
}
}