using System;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
///
public const int TCM_FIRST = 0x1300;
///
public const int TCN_FIRST = -550;
/// Variable that receives the results of a hit test.
[PInvokeData("Commctrl.h", MSDNShortId = "bb760813")]
[Flags]
public enum TabControlHitTestFlags
{
/// The position is not over a tab.
TCHT_NOWHERE = 0x0001,
/// The position is over a tab's icon.
TCHT_ONITEMICON = 0x0002,
/// The position is over a tab's text.
TCHT_ONITEMLABEL = 0x0004,
///
/// The position is over a tab but not over its icon or its text. For owner-drawn tab controls, this value is specified if the
/// position is anywhere over a tab.
///
TCHT_ONITEM = TCHT_ONITEMICON | TCHT_ONITEMLABEL,
}
/// Value that specifies which members of TCITEM to retrieve or set.
[PInvokeData("Commctrl.h", MSDNShortId = "bb760554")]
[Flags]
public enum TabControlItemMask
{
/// The pszText member is valid.
TCIF_TEXT = 0x0001,
/// The iImage member is valid.
TCIF_IMAGE = 0x0002,
/// The string pointed to by pszText will be displayed in the direction opposite to the text in the parent window.
TCIF_RTLREADING = 0x0004,
/// The lParam member is valid.
TCIF_PARAM = 0x0008,
/// Version 4.70. The dwState member is valid.
TCIF_STATE = 0x0010,
/// All members are valid.
TCIF_ALL = 0x001B,
}
///
/// Tab control items now support an item state to support the TCM_DESELECTALL message. Additionally, the TCITEM structure supports
/// item state values.
///
[PInvokeData("Commctrl.h", MSDNShortId = "bb760547")]
[Flags]
public enum TabControlItemStates
{
///
/// Version 4.70. The tab control item is selected. This state is only meaningful if the TCS_BUTTONS style flag has been set.
///
TCIS_BUTTONPRESSED = 0x0001,
///
/// Version 4.71. The tab control item is highlighted, and the tab and text are drawn using the current highlight color. When
/// using high-color, this will be a true interpolation, not a dithered color.
///
TCIS_HIGHLIGHTED = 0x0002,
/// Look at all states.
TCIS_ALL
}
/// Tab Control Messages
// https://docs.microsoft.com/en-us/windows/win32/controls/bumper-tab-control-reference-messages
[PInvokeData("Commctrl.h", MSDNShortId = "bb760813")]
public enum TabControlMessage
{
///
/// Retrieves the image list associated with a tab control. You can send this message explicitly or by using the
/// TabCtrl_GetImageList macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Must be zero.
/// Returns
/// Returns the handle to the image list if successful, or NULL otherwise.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-getimagelist
TCM_GETIMAGELIST = TCM_FIRST + 2,
///
/// Assigns an image list to a tab control. You can send this message explicitly or by using the TabCtrl_SetImageList macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Handle to the image list to assign to the tab control.
/// Returns
/// Returns the handle to the previous image list, or NULL if there is no previous image list.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setimagelist
TCM_SETIMAGELIST = TCM_FIRST + 3,
///
/// Retrieves the number of tabs in the tab control. You can send this message explicitly or by using the
/// TabCtrl_GetItemCount macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Must be zero.
/// Returns
/// Returns the number of items if successful, or zero otherwise.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-getitemcount
TCM_GETITEMCOUNT = TCM_FIRST + 4,
///
/// Retrieves information about a tab in a tab control. You can send this message explicitly or by using the
/// TabCtrl_GetItem macro.
/// Parameters
/// wParam
/// Index of the tab.
/// lParam
///
/// Pointer to a TCITEM structure that specifies the information to retrieve and receives information about the tab. When
/// the message is sent, the mask member specifies which attributes to return. If the mask member specifies the
/// TCIF_TEXT value, the pszText member must contain the address of the buffer that receives the item text, and the
/// cchTextMax member must specify the size of the buffer.
///
/// Returns
/// Returns TRUE if successful, or FALSE otherwise.
///
///
/// If the TCIF_TEXT flag is set in the mask member of the TCITEM structure, the control may change the
/// pszText member of the structure to point to the new text instead of filling the buffer with the requested text. The
/// control may set the pszText member to NULL to indicate that no text is associated with the item.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-getitem
TCM_GETITEM = TCM_FIRST + 60,
///
/// Sets some or all of a tab's attributes. You can send this message explicitly or by using the TabCtrl_SetItem macro.
/// Parameters
/// wParam
/// Index of the item.
/// lParam
///
/// Pointer to a TCITEM structure that contains the new item attributes. The mask member specifies which attributes
/// to set. If the mask member specifies the TCIF_TEXT value, the pszText member is the address of a
/// null-terminated string and the cchTextMax member is ignored.
///
/// Returns
/// Returns TRUE if successful, or FALSE otherwise.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setitem
TCM_SETITEM = TCM_FIRST + 61,
///
/// Inserts a new tab in a tab control. You can send this message explicitly or by using the TabCtrl_InsertItem macro.
/// Parameters
/// wParam
/// Index of the new tab.
/// lParam
///
/// Pointer to a TCITEM structure that specifies the attributes of the tab. The dwState and dwStateMask
/// members of this structure are ignored by this message.
///
/// Returns
/// Returns the index of the new tab if successful, or -1 otherwise.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-insertitem
TCM_INSERTITEM = TCM_FIRST + 62,
///
/// Removes an item from a tab control. You can send this message explicitly or by using the TabCtrl_DeleteItem macro.
/// Parameters
/// wParam
/// Index of the item to delete.
/// lParam
/// Must be zero.
/// Returns
/// Returns TRUE if successful, or FALSE otherwise.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-deleteitem
TCM_DELETEITEM = TCM_FIRST + 8,
///
/// Removes all items from a tab control. You can send this message explicitly or by using the TabCtrl_DeleteAllItems macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Must be zero.
/// Returns
/// Returns TRUE if successful, or FALSE otherwise.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-deleteallitems
TCM_DELETEALLITEMS = TCM_FIRST + 9,
///
/// Retrieves the bounding rectangle for a tab in a tab control. You can send this message explicitly or by using the
/// TabCtrl_GetItemRect macro.
/// Parameters
/// wParam
/// Index of the tab.
/// lParam
/// Pointer to a RECT structure that receives the bounding rectangle of the tab, in viewport coordinates.
/// Returns
/// Returns TRUE if successful, or FALSE otherwise.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-getitemrect
TCM_GETITEMRECT = TCM_FIRST + 10,
///
/// Determines the currently selected tab in a tab control. You can send this message explicitly or by using the
/// TabCtrl_GetCurSel macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Must be zero.
/// Returns
/// Returns the index of the selected tab if successful, or -1 if no tab is selected.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-getcursel
TCM_GETCURSEL = TCM_FIRST + 11,
///
/// Selects a tab in a tab control. You can send this message explicitly or by using the TabCtrl_SetCurSel macro.
/// Parameters
/// wParam
/// Index of the tab to select.
/// lParam
/// Must be zero.
/// Returns
/// Returns the index of the previously selected tab if successful, or -1 otherwise.
///
///
/// A tab control does not send a TCN_SELCHANGING or TCN_SELCHANGE notification code when a tab is selected using this message.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setcursel
TCM_SETCURSEL = TCM_FIRST + 12,
///
/// Determines which tab, if any, is at a specified screen position. You can send this message explicitly or by using the
/// TabCtrl_HitTest macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Pointer to a TCHITTESTINFO structure that specifies the screen position to test.
/// Returns
/// Returns the index of the tab, or -1 if no tab is at the specified position.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-hittest
TCM_HITTEST = TCM_FIRST + 13,
///
/// Sets the number of bytes per tab reserved for application-defined data in a tab control. You can send this message explicitly
/// or by using the TabCtrl_SetItemExtra macro.
/// Parameters
/// wParam
/// Number of extra bytes.
/// lParam
/// Must be zero.
/// Returns
/// Returns TRUE if successful, or FALSE otherwise.
///
///
///
/// By default, the number of extra bytes is four. An application that changes the number of extra bytes cannot use the
/// TCITEM structure to retrieve and set the application-defined data for a tab. Instead, you must define a new structure
/// that consists of the TCITEMHEADER structure followed by application-defined members.
///
/// An application should only change the number of extra bytes when a tab control does not contain any tabs.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setitemextra
TCM_SETITEMEXTRA = TCM_FIRST + 14,
///
/// Calculates a tab control's display area given a window rectangle, or calculates the window rectangle that would correspond to
/// a specified display area. You can send this message explicitly or by using the TabCtrl_AdjustRect macro.
/// Parameters
/// wParam
///
/// Operation to perform. If this parameter is TRUE, lParam specifies a display rectangle and receives the corresponding
/// window rectangle. If this parameter is FALSE, lParam specifies a window rectangle and receives the corresponding
/// display area.
///
/// lParam
/// Pointer to a RECT structure that specifies the given rectangle and receives the calculated rectangle.
/// Returns
/// No return value.
///
///
/// This message applies only to tab controls that are at the top. It does not apply to tab controls that are on the sides or bottom.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-adjustrect
TCM_ADJUSTRECT = TCM_FIRST + 40,
///
/// Sets the width and height of tabs in a fixed-width or owner-drawn tab control. You can send this message explicitly or by
/// using the TabCtrl_SetItemSize macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
///
/// The LOWORD is an INT value that specifies the new width, in pixels. The HIWORD is an INT value
/// that specifies the new height, in pixels.
///
/// Returns
/// Returns the old width and height. The width is in the LOWORD of the return value, and the height is in the HIWORD.
///
///
/// If the width is set to a value less than the image width set by ImageList_Create, the width of the tab is set to the
/// lowest value that is greater than the image width.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setitemsize
TCM_SETITEMSIZE = TCM_FIRST + 41,
///
/// Removes an image from a tab control's image list. You can send this message explicitly or by using the
/// TabCtrl_RemoveImage macro.
/// Parameters
/// wParam
/// Index of the image to remove.
/// lParam
/// Must be zero.
/// Returns
/// No return value.
///
///
/// The tab control updates each tab's image index, so each tab remains associated with the same image as before. If a tab is
/// using the image being removed, the tab will be set to have no image.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-removeimage
TCM_REMOVEIMAGE = TCM_FIRST + 42,
///
/// Sets the amount of space (padding) around each tab's icon and label in a tab control. You can send this message explicitly or
/// by using the TabCtrl_SetPadding macro.
/// Parameters
/// lParam
///
/// The LOWORD is an INT value that specifies the amount of horizontal padding, in pixels. The HIWORD is an
/// INT value that specifies the amount of vertical padding, in pixels.
///
/// Returns
/// No return value.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setpadding
TCM_SETPADDING = TCM_FIRST + 43,
///
/// Retrieves the current number of rows of tabs in a tab control. You can send this message explicitly or by using the
/// TabCtrl_GetRowCount macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Must be zero.
/// Returns
/// Returns the number of rows of tabs.
///
/// Only tab controls that have the TCS_MULTILINE style can have multiple rows of tabs.
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-getrowcount
TCM_GETROWCOUNT = TCM_FIRST + 44,
///
/// Retrieves the handle to the tooltip control associated with a tab control. You can send this message explicitly or by using
/// the TabCtrl_GetToolTips macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Must be zero.
/// Returns
/// Returns the handle to the tooltip control if successful, or NULL otherwise.
///
///
/// A tab control creates a tooltip control if it has the TCS_TOOLTIPS style. You can also assign a tooltip control to a
/// tab control by using the TCM_SETTOOLTIPS message.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-gettooltips
TCM_GETTOOLTIPS = TCM_FIRST + 45,
///
/// Assigns a tooltip control to a tab control. You can send this message explicitly or by using the TabCtrl_SetToolTips macro.
/// Parameters
/// wParam
/// Handle to the tooltip control.
/// lParam
/// Must be zero.
/// Returns
/// No return value.
///
/// You can retrieve the tooltip control associated with a tab control by using the TCM_GETTOOLTIPS message.
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-settooltips
TCM_SETTOOLTIPS = TCM_FIRST + 46,
///
/// Returns the index of the item that has the focus in a tab control. You can send this message explicitly or by using the
/// TabCtrl_GetCurFocus macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Must be zero.
/// Returns
/// Returns the index of the tab item that has the focus.
///
/// The item that has the focus may be different than the selected item.
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-getcurfocus
TCM_GETCURFOCUS = TCM_FIRST + 47,
///
/// Sets the focus to a specified tab in a tab control. You can send this message explicitly or by using the
/// TabCtrl_SetCurFocus macro.
/// Parameters
/// wParam
/// Index of the tab that gets the focus.
/// lParam
/// Must be zero.
/// Returns
/// No return value.
///
///
///
/// If the tab control has the TCS_BUTTONS style (button mode), the tab with the focus may be different from the selected
/// tab. For example, when a tab is selected, the user can press the arrow keys to set the focus to a different tab without
/// changing the selected tab. In button mode, TCM_SETCURFOCUS sets the input focus to the button associated with the
/// specified tab, but it does not change the selected tab.
///
///
/// If the tab control does not have the TCS_BUTTONS style, changing the focus also changes the selected tab. In this
/// case, the tab control sends the TCN_SELCHANGING and TCN_SELCHANGE notification codes to its parent window.
///
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setcurfocus
TCM_SETCURFOCUS = TCM_FIRST + 48,
///
/// Sets the minimum width of items in a tab control. You can send this message explicitly or by using the
/// TabCtrl_SetMinTabWidth macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
///
/// Minimum width to be set for a tab control item. If this parameter is set to -1, the control will use the default tab width.
///
/// Returns
/// Returns an INT value that represents the previous minimum tab width.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setmintabwidth
TCM_SETMINTABWIDTH = TCM_FIRST + 49,
///
/// Resets items in a tab control, clearing any that were set to the TCIS_BUTTONPRESSED state. You can send this message
/// explicitly or by using the TabCtrl_DeselectAll macro.
/// Parameters
/// wParam
///
/// Flag that specifies the scope of the item deselection. If this parameter is set to FALSE, all tab items will be reset.
/// If it is set to TRUE, then all tab items except for the one currently selected will be reset.
///
/// lParam
/// Must be zero.
/// Returns
/// The return value for this message is not used.
///
/// This message is only meaningful if the TCS_BUTTONS style flag has been set.
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-deselectall
TCM_DESELECTALL = TCM_FIRST + 50,
///
/// Sets the highlight state of a tab item. You can send this message explicitly or by using the TabCtrl_HighlightItem macro.
/// Parameters
/// wParam
/// An INT value that specifies the zero-based index of a tab control item.
/// lParam
///
/// The LOWORD is a BOOL specifying the highlight state to be set. If this value is TRUE, the tab is
/// highlighted; if FALSE, the tab is set to its default state. The HIWORD must be zero.
///
/// Returns
/// Returns nonzero if successful, or zero otherwise.
///
/// In Comctl32.dll version 6.0, this message has no visible effect when a theme is active.
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-highlightitem
TCM_HIGHLIGHTITEM = TCM_FIRST + 51,
///
/// Sets the extended styles that the tab control will use. You can send this message explicitly or by using the
/// TabCtrl_SetExtendedStyle macro.
/// Parameters
/// wParam
///
/// A DWORD value that indicates which styles in lParam are to be affected. Only the extended styles in wParam will be
/// changed. All other styles will be maintained as they are. If this parameter is zero, then all of the styles in lParam will be affected.
///
/// lParam
/// Value specifying the extended tab control styles. This value is a combination of tab control extended styles.
/// Returns
/// Returns a DWORD value that contains the previous tab control extended styles.
///
///
///
/// The wParam parameter allows you to modify one or more extended styles without having to retrieve the existing styles first.
/// For example, if you pass TCS_EX_FLATSEPARATORS for wParam and 0 for lParam, the TCS_EX_FLATSEPARATORS style
/// will be cleared, but all other styles will remain the same.
///
/// For backward compatibility reasons, the TabCtrl_SetExtendedStyle macro has not been updated to use dwExMask.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setextendedstyle
TCM_SETEXTENDEDSTYLE = TCM_FIRST + 52, // optional wParam == mask
///
/// Retrieves the extended styles that are currently in use for the tab control. You can send this message explicitly or by using
/// the TabCtrl_GetExtendedStyle macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Must be zero.
/// Returns
///
/// Returns a DWORD value that represents the extended styles currently in use for the tab control. This value is a
/// combination of tab control extended styles.
///
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-getextendedstyle
TCM_GETEXTENDEDSTYLE = TCM_FIRST + 53,
///
/// 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. You can send this message explicitly or use the
/// TabCtrl_SetUnicodeFormat macro.
/// Parameters
/// wParam
///
/// Determines the character set that is used by the control. If this value is nonzero, the control will use Unicode characters.
/// If this value is zero, the control will use ANSI characters.
///
/// lParam
/// Must be zero.
/// Returns
/// Returns the previous Unicode format flag for the control.
///
/// See the remarks for CCM_SETUNICODEFORMAT for a discussion of this message.
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setunicodeformat
TCM_SETUNICODEFORMAT = CommonControlMessage.CCM_SETUNICODEFORMAT,
///
/// Retrieves the Unicode character format flag for the control. You can send this message explicitly or use the
/// TabCtrl_GetUnicodeFormat macro.
/// Parameters
/// wParam
/// Must be zero.
/// lParam
/// Must be zero.
/// Returns
///
/// Returns the Unicode format flag for the control. If this value is nonzero, the control is using Unicode characters. If this
/// value is zero, the control is using ANSI characters.
///
///
/// See the remarks for CCM_GETUNICODEFORMAT for a discussion of this message.
// https://docs.microsoft.com/en-us/windows/win32/controls/tcm-getunicodeformat
TCM_GETUNICODEFORMAT = CommonControlMessage.CCM_GETUNICODEFORMAT
}
/// Tab Control Notifications
[PInvokeData("Commctrl.h", MSDNShortId = "bb760813")]
public enum TabControlNotification
{
///
///
/// Notifies a tab control's parent window that a key has been pressed. This notification code is sent in the form of a
/// WM_NOTIFY message.
///
///
/// TCN_KEYDOWN pnm = (NMTCKEYDOWN*) lParam;
///
/// Parameters
/// lParam
/// Pointer to an NMTCKEYDOWN structure.
/// Returns
/// No return value.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcn-keydown
TCN_KEYDOWN = TCN_FIRST - 0,
///
///
/// Notifies a tab control's parent window that the currently selected tab has changed. This notification code is sent in the
/// form of a WM_NOTIFY message.
///
///
/// TCN_SELCHANGE lpnmhdr = (LPNMHDR) lParam;
///
/// Parameters
/// lParam
/// Pointer to an NMHDR structure that contains additional information about this notification.
/// Returns
/// No return value.
///
/// To determine the currently selected tab, use the TabCtrl_GetCurSel macro.
// https://docs.microsoft.com/en-us/windows/win32/controls/tcn-selchange
TCN_SELCHANGE = TCN_FIRST - 1,
///
///
/// Notifies a tab control's parent window that the currently selected tab is about to change. This notification code is sent in
/// the form of a WM_NOTIFY message.
///
///
/// TCN_SELCHANGING lpnmhdr = (LPNMHDR) lParam;
///
/// Parameters
/// lParam
/// Pointer to an NMHDR structure that contains additional information about this notification.
/// Returns
/// Returns TRUE to prevent the selection from changing, or FALSE to allow the selection to change.
///
/// To determine the currently selected tab, use the TabCtrl_GetCurSel macro.
// https://docs.microsoft.com/en-us/windows/win32/controls/tcn-selchanging
TCN_SELCHANGING = TCN_FIRST - 2,
///
///
/// Sent by a tab control when it has the TCS_EX_REGISTERDROP extended style and an object is dragged over a tab item in
/// the control. This notification code is sent in the form of a WM_NOTIFY message.
///
///
/// TCN_GETOBJECT lpnmon = (LPNMOBJECTNOTIFY) lParam;
///
/// Parameters
/// lParam
///
/// Pointer to an NMOBJECTNOTIFY structure that contains information about the tab item the object is dragged over and
/// receives data the application returns in response to this message.
///
/// Returns
/// The application processing this notification code must return zero.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcn-getobject
TCN_GETOBJECT = TCN_FIRST - 3,
///
///
/// Notifies a tab control's parent window that the button focus has changed. This notification code is sent in the form of a
/// WM_NOTIFY message.
///
///
/// TCN_FOCUSCHANGE lpnmh = (LPNMHDR) lParam;
///
/// Parameters
/// lParam
/// Pointer to an NMHDR structure that contains additional information about this notification.
/// Returns
/// No return value.
///
// https://docs.microsoft.com/en-us/windows/win32/controls/tcn-focuschange
TCN_FOCUSCHANGE = TCN_FIRST - 4,
}
/// This section lists supported tab control styles.
[PInvokeData("Commctrl.h", MSDNShortId = "bb760549")]
[Flags]
public enum TabControlStyles
{
/// Version 4.70. Unneeded tabs scroll to the opposite side of the control when a tab is selected.
TCS_SCROLLOPPOSITE = 0x0001,
///
/// Version 4.70. Tabs appear at the bottom of the control. This value equals TCS_RIGHT. This style is not supported if you use
/// ComCtl32.dll version 6.
///
TCS_BOTTOM = 0x0002,
///
/// Version 4.70. Tabs appear vertically on the right side of controls that use the TCS_VERTICAL style. This value equals
/// TCS_BOTTOM. This style is not supported if you use visual styles.
///
TCS_RIGHT = 0x0002,
///
/// Version 4.70. Multiple tabs can be selected by holding down the CTRL key when clicking. This style must be used with the
/// TCS_BUTTONS style.
///
TCS_MULTISELECT = 0x0004,
///
/// Version 4.71. Selected tabs appear as being indented into the background while other tabs appear as being on the same plane
/// as the background. This style only affects tab controls with the TCS_BUTTONS style.
///
TCS_FLATBUTTONS = 0x0008,
///
/// Icons are aligned with the left edge of each fixed-width tab. This style can only be used with the TCS_FIXEDWIDTH style.
///
TCS_FORCEICONLEFT = 0x0010,
///
/// Labels are aligned with the left edge of each fixed-width tab; that is, the label is displayed immediately to the right of
/// the icon instead of being centered. This style can only be used with the TCS_FIXEDWIDTH style, and it implies the
/// TCS_FORCEICONLEFT style.
///
TCS_FORCELABELLEFT = 0x0020,
///
/// Version 4.70. Items under the pointer are automatically highlighted. You can check whether hot tracking is enabled by calling SystemParametersInfo.
///
TCS_HOTTRACK = 0x0040,
///
/// Version 4.70. Tabs appear at the left side of the control, with tab text displayed vertically. This style is valid only when
/// used with the TCS_MULTILINE style. To make tabs appear on the right side of the control, also use the TCS_RIGHT style. This
/// style is not supported if you use ComCtl32.dll version 6.
///
TCS_VERTICAL = 0x0080,
/// Tabs appear as tabs, and a border is drawn around the display area. This style is the default.
TCS_TABS = 0x0000,
/// Tabs appear as buttons, and no border is drawn around the display area.
TCS_BUTTONS = 0x0100,
/// Only one row of tabs is displayed. The user can scroll to see more tabs, if necessary. This style is the default.
TCS_SINGLELINE = 0x0000,
/// Multiple rows of tabs are displayed, if necessary, so all tabs are visible at once.
TCS_MULTILINE = 0x0200,
///
/// The width of each tab is increased, if necessary, so that each row of tabs fills the entire width of the tab control. This
/// window style is ignored unless the TCS_MULTILINE style is also specified.
///
TCS_RIGHTJUSTIFY = 0x0000,
/// All tabs are the same width. This style cannot be combined with the TCS_RIGHTJUSTIFY style.
TCS_FIXEDWIDTH = 0x0400,
/// Rows of tabs will not be stretched to fill the entire width of the control. This style is the default.
TCS_RAGGEDRIGHT = 0x0800,
/// The tab control receives the input focus when clicked.
TCS_FOCUSONBUTTONDOWN = 0x1000,
/// The parent window is responsible for drawing tabs.
TCS_OWNERDRAWFIXED = 0x2000,
/// The tab control has a tooltip control associated with it.
TCS_TOOLTIPS = 0x4000,
/// The tab control does not receive the input focus when clicked.
TCS_FOCUSNEVER = 0x8000,
}
///
/// The tab control now supports extended styles. These styles are manipulated using the TCM_GETEXTENDEDSTYLE and
/// TCM_SETEXTENDEDSTYLE messages and should not be confused with extended window styles that are passed to CreateWindowEx.
///
[PInvokeData("Commctrl.h", MSDNShortId = "bb760546")]
[Flags]
public enum TabControlStylesEx
{
///
/// Version 4.71. The tab control will draw separators between the tab items. This extended style only affects tab controls that
/// have the TCS_BUTTONS and TCS_FLATBUTTONS styles. By default, creating the tab control with the TCS_FLATBUTTONS style sets
/// this extended style. If you do not require separators, you should remove this extended style after creating the control.
///
TCS_EX_FLATSEPARATORS = 0x00000001,
///
/// Version 4.71. The tab control generates TCN_GETOBJECT notification codes to request a drop target object when an object is
/// dragged over the tab items in the control. The application must call CoInitialize or OleInitialize before setting this style.
///
TCS_EX_REGISTERDROP = 0x00000002
}
/// Contains information about a hit test. This structure supersedes the TC_HITTESTINFO structure.
[PInvokeData("Commctrl.h", MSDNShortId = "bb760553")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TCHITTESTINFO
{
/// Position to hit test, in client coordinates.
public POINT pt;
/// Variable that receives the results of a hit test. The tab control sets this member to one of the following values:
public TabControlHitTestFlags flags;
}
///
/// Specifies or receives the attributes of a tab item. It is used with the TCM_INSERTITEM, TCM_GETITEM, and TCM_SETITEM messages.
/// This structure supersedes the TC_ITEM structure.
///
///
[PInvokeData("Commctrl.h", MSDNShortId = "bb760554")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public sealed class TCITEM : IDisposable
{
/// Value that specifies which members to retrieve or set.
public TabControlItemMask mask;
///
/// Version 4.70. Specifies the item's current state if information is being retrieved. If item information is being set, this
/// member contains the state value to be set for the item. For a list of valid tab control item states, see Tab Control Item
/// States. This member is ignored in the TCM_INSERTITEM message.
///
public TabControlItemStates dwState;
///
/// Version 4.70. Specifies which bits of the dwState member contain valid information. This member is ignored in the
/// TCM_INSERTITEM message.
///
public TabControlItemStates dwStateMask;
///
/// Pointer to a null-terminated string that contains the tab text when item information is being set. If item information is
/// being retrieved, this member specifies the address of the buffer that receives the tab text.
///
public StrPtrAuto pszText;
///
/// Size in TCHARs of the buffer pointed to by the pszText member. If the structure is not receiving information, this member is ignored.
///
public uint cchTextMax;
/// Index in the tab control's image list, or -1 if there is no image for the tab.
public int iImage;
///
/// Application-defined data associated with the tab control item. If more or less than 4 bytes of application-defined data exist
/// per tab, an application must define a structure and use it instead of the TCITEM structure. The first member of the
/// application-defined structure must be a TCITEMHEADER structure.
///
public IntPtr lParam;
/// Initializes a new instance of the class.
public TCITEM(TabControlItemMask itemsToGet = TabControlItemMask.TCIF_ALL, TabControlItemStates statesToGet = TabControlItemStates.TCIS_ALL)
{
if ((itemsToGet & TabControlItemMask.TCIF_TEXT) != 0)
{
pszText = new StrPtrAuto(cchTextMax = 1024);
}
}
/// Initializes a new instance of the class.
/// The text.
public TCITEM(string text) => Text = text;
/// Gets or sets the text.
/// The text.
public string Text
{
get => pszText.ToString();
set
{
pszText.Assign(value, out cchTextMax);
mask |= TabControlItemMask.TCIF_TEXT;
}
}
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
void IDisposable.Dispose()
{
pszText.Free();
cchTextMax = 0;
}
}
///
/// Specifies or receives the attributes of a tab. It is used with the TCM_INSERTITEM, TCM_GETITEM, and TCM_SETITEM messages. This
/// structure supersedes the TC_ITEMHEADER structure.
///
///
[PInvokeData("Commctrl.h", MSDNShortId = "bb760813")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public sealed class TCITEMHEADER : IDisposable
{
/// Value that specifies which members to retrieve or set.
public TabControlItemMask mask;
///
/// Version 4.70. Specifies the item's current state if information is being retrieved. If item information is being set, this
/// member contains the state value to be set for the item. For a list of valid tab control item states, see Tab Control Item
/// States. This member is ignored in the TCM_INSERTITEM message.
///
public TabControlItemStates dwState;
///
/// Version 4.70. Specifies which bits of the dwState member contain valid information. This member is ignored in the
/// TCM_INSERTITEM message.
///
public TabControlItemStates dwStateMask;
///
/// Pointer to a null-terminated string that contains the tab text when item information is being set. If item information is
/// being retrieved, this member specifies the address of the buffer that receives the tab text.
///
public StrPtrAuto pszText;
///
/// Size in TCHARs of the buffer pointed to by the pszText member. If the structure is not receiving information, this member is ignored.
///
public uint cchTextMax;
/// Index in the tab control's image list, or -1 if there is no image for the tab.
public int iImage;
/// Initializes a new instance of the class.
public TCITEMHEADER(TabControlItemMask itemsToGet = TabControlItemMask.TCIF_ALL, TabControlItemStates statesToGet = TabControlItemStates.TCIS_ALL)
{
if ((itemsToGet & TabControlItemMask.TCIF_TEXT) != 0)
{
pszText = new StrPtrAuto(cchTextMax = 1024);
}
}
/// Initializes a new instance of the class.
/// The text.
public TCITEMHEADER(string text) => Text = text;
/// Gets or sets the text.
/// The text.
public string Text
{
get => pszText.ToString();
set
{
pszText.Assign(value, out cchTextMax);
mask |= TabControlItemMask.TCIF_TEXT;
}
}
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
void IDisposable.Dispose()
{
pszText.Free();
cchTextMax = 0;
}
}
}
}