More work on ComCtl32 adding header and toolbar items.

pull/10/head
David Hall 2018-06-06 11:31:53 -06:00
parent dce7e85fb6
commit ca7f14b792
3 changed files with 1648 additions and 132 deletions

View File

@ -11,6 +11,9 @@ namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
/// <summary>Window Class Name for Header control.</summary>
public const string WC_HEADER = "SysHeader";
private const int HDM_FIRST = 0x1200;
private const int HDN_FIRST = -300;
@ -198,29 +201,249 @@ namespace Vanara.PInvoke
HDM_SETUNICODEFORMAT = 0X2005, // CCM_SETUNICODEFORMAT,
}
/// <summary>Header control notifications</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "ff485940")]
public enum HeaderNotification
{
/// <summary>
/// Sent by a header control when a drag operation has begun on one of its items. This notification code is sent only by header controls that are set
/// to the <c>HDS_DRAGDROP</c> style. This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure containing information about the header item that is being dragged.</param>
/// <returns>
/// To allow the header control to automatically manage drag-and-drop operations, return <c>FALSE</c>. If the owner of the control is manually
/// performing drag-and-drop reordering, return <c>TRUE</c>.
/// </returns>
HDN_BEGINDRAG = HDN_FIRST - 10,
/// <summary>
/// Notifies a header control's parent window that a filter edit has begun. This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains additional information about the filter that is being edited.</param>
/// <returns>No return value.</returns>
HDN_BEGINFILTEREDIT = HDN_FIRST - 14,
/// <summary>
/// Notifies a header control's parent window that the user has begun dragging a divider in the control (that is, the user has pressed the left mouse
/// button while the mouse cursor is on a divider in the header control). This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider is to be dragged.
/// </param>
/// <returns>Returns <c>FALSE</c> to allow tracking of the divider, or <c>TRUE</c> to prevent tracking.</returns>
HDN_BEGINTRACK = HDN_FIRST - 26,
/// <summary>
/// Notifies a header control's parent window that the user double-clicked the divider area of the control. This notification code is sent in the
/// form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider was double-clicked.
/// </param>
/// <returns>No return value.</returns>
HDN_DIVIDERDBLCLICK = HDN_FIRST - 25,
/// <summary>
/// Sent by a header control to its parent when the drop-down arrow on the header control is clicked. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains information on the header control.</param>
/// <returns>No return value.</returns>
HDN_DROPDOWN = HDN_FIRST - 18,
/// <summary>
/// Sent by a header control when a drag operation has ended on one of its items. This notification code is sent as a <c>WM_NOTIFY</c> message. Only
/// header controls that are set to the <c>HDS_DRAGDROP</c> style send this notification code.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure containing information about the header item that was being dragged.</param>
/// <returns>
/// To allow the control to automatically place and reorder the item, return <c>FALSE</c>. To prevent the item from being placed, return <c>TRUE</c>.
/// </returns>
HDN_ENDDRAG = HDN_FIRST - 11,
/// <summary>
/// Notifies a header control's parent window that a filter edit has ended. This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains additional information about the filter that is being edited.</param>
/// <returns>No return value.</returns>
HDN_ENDFILTEREDIT = HDN_FIRST - 15,
/// <summary>
/// Notifies a header control's parent window that the user has finished dragging a divider. This notification code sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider was dragged.
/// </param>
/// <returns>No return value.</returns>
HDN_ENDTRACK = HDN_FIRST - 27,
/// <summary>
/// Notifies the header control's parent window when the filter button is clicked or in response to an <c>HDM_SETITEM</c> message. This notification
/// code sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHDFILTERBTNCLICK</c> structure that contains information about the header control and the header filter button.
/// </param>
/// <returns>
/// If you return <c>TRUE</c>, an HDN_FILTERCHANGE notification code will be sent to the header control's parent window. This notification code gives
/// the parent window an opportunity to synchronize its user interface elements. Return <c>FALSE</c> if you do not want the notification sent.
/// </returns>
HDN_FILTERBTNCLICK = HDN_FIRST - 13,
/// <summary>
/// Notifies the header control's parent window that the attributes of a header control filter are being changed or edited. This notification code
/// sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the header item, including the attributes that
/// are about to change.
/// </param>
/// <returns>No return value.</returns>
HDN_FILTERCHANGE = HDN_FIRST - 12,
/// <summary>
/// Sent to the owner of a header control when the control needs information about a callback header item. This notification code is sent as a
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHDDISPINFO</c> structure. On input, the fields of the structure specify what information is required and the item of interest.
/// </param>
/// <returns>Returns an LRESULT.</returns>
HDN_GETDISPINFO = HDN_FIRST - 29,
/// <summary>
/// Notifies a header control's parent window that the attributes of a header item have changed. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control, including the attributes that have changed.
/// </param>
/// <returns>No return value.</returns>
HDN_ITEMCHANGED = HDN_FIRST - 21,
/// <summary>
/// Notifies a header control's parent window that the attributes of a header item are about to change. This notification code is sent in the form of
/// a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the header item, including the attributes that
/// are about to change.
/// </param>
/// <returns>Returns <c>FALSE</c> to allow the changes, or <c>TRUE</c> to prevent them.</returns>
HDN_ITEMCHANGING = HDN_FIRST - 20,
/// <summary>
/// Notifies a header control's parent window that the user clicked the control. This notification code is sent in the form of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that identifies the header control and specifies the index of the header item that was clicked and the
/// mouse button used to click the item. The <c>pItem</c> member is set to <c>NULL</c>.
/// </param>
/// <returns>No return value.</returns>
HDN_ITEMCLICK = HDN_FIRST - 22,
/// <summary>
/// Notifies a header control's parent window that the user double-clicked the control. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message. Only header controls that are set to the <c>HDS_BUTTONS</c> style send this notification code.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains information about this notification code.</param>
/// <returns>No return value.</returns>
HDN_ITEMDBLCLICK = HDN_FIRST - 23,
/// <summary>
/// Notifies a header control's parent window that a key has been pressed with an item selected. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains additional information about the key that is being pressed.</param>
/// <returns>No return value.</returns>
HDN_ITEMKEYDOWN = HDN_FIRST - 17,
/// <summary>
/// Notifies a header control's parent window that the user clicked an item's state icon. This notification code is sent in the form of a
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">A pointer to an <c>NMHEADER</c> structure that contains additional information about the state icon that was clicked on.</param>
/// <returns>No return value.</returns>
HDN_ITEMSTATEICONCLICK = HDN_FIRST - 16,
/// <summary>
/// Sent by a header control to its parent when the header's overflow button is clicked. This notification code is sent in the form of an
/// <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// <para>
/// A pointer to a <c>NMHEADER</c> structure that describes the notification code. The calling process is responsible for allocating this structure,
/// including the contained <c>NMHDR</c> structure. Set the members of the <c>NMHDR</c> structure, including the code member that must be set to HDN_OVERFLOWCLICK.
/// </para>
/// <para>
/// Set the <c>iItem</c> member of the <c>NMHEADER</c> structure to the index of the first header item that is not visible and thus should be
/// displayed on an overflow.
/// </para>
/// </param>
/// <returns>No return value.</returns>
HDN_OVERFLOWCLICK = HDN_FIRST - 19,
/// <summary>
/// Notifies a header control's parent window that the user is dragging a divider in the header control. This notification code is sent in the form
/// of a <c>WM_NOTIFY</c> message.
/// </summary>
/// <param name="lParam">
/// A pointer to an <c>NMHEADER</c> structure that contains information about the header control and the item whose divider is being dragged.
/// </param>
/// <returns>Returns <c>FALSE</c> to continue tracking the divider, or <c>TRUE</c> to end tracking.</returns>
HDN_TRACK = HDN_FIRST - 28,
}
/// <summary>
/// Header controls have a number of styles, described in this section, that determine the control's appearance and behavior. You set the initial styles when you create the header control.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775241")]
[Flags]
public enum HeaderStyle
{
/// <summary>Each item in the control looks and behaves like a push button. This style is useful if an application carries out a task when the user clicks an item in the header control. For example, an application could sort information in the columns differently depending on which item the user clicks.</summary>
HDS_BUTTONS = 0x0002,
/// <summary>Allows drag-and-drop reordering of header items.</summary>
HDS_DRAGDROP = 0x0040,
/// <summary>Include a filter bar as part of the standard header control. This bar allows users to conveniently apply a filter to the display. Calls to HDM_LAYOUT will yield a new size for the control and cause the list view to update.</summary>
HDS_FILTERBAR = 0x0100,
/// <summary>Version 6.0 and later. Causes the header control to be drawn flat when the operating system is running in classic mode.
/// <note>Comctl32.dll version 6 is not redistributable but it is included in Windows. To use Comctl32.dll version 6, specify it in a manifest. For more information on manifests, see Enabling Visual Styles.</note></summary>
HDS_FLAT = 0x0200,
/// <summary>Causes the header control to display column contents even while the user resizes a column.</summary>
HDS_FULLDRAG = 0x0080,
/// <summary>Indicates a header control that is intended to be hidden. This style does not hide the control. Instead, when you send the HDM_LAYOUT message to a header control with the HDS_HIDDEN style, the control returns zero in the cy member of the WINDOWPOS structure. You would then hide the control by setting its height to zero. This can be useful when you want to use the control as an information container instead of a visual control.</summary>
HDS_HIDDEN = 0x0008,
/// <summary>Creates a header control with a horizontal orientation.</summary>
HDS_HORZ = 0x0000,
/// <summary>Enables hot tracking.</summary>
HDS_HOTTRACK = 0x0004,
/// <summary>Version 6.00 and later. Allows the placing of checkboxes on header items. For more information, see the fmt member of HDITEM.</summary>
HDS_CHECKBOXES = 0x0400,
/// <summary>Version 6.00 and later. The user cannot drag the divider on the header control.</summary>
HDS_NOSIZING = 0x0800,
/// <summary>Version 6.00 and later. A button is displayed when not all items can be displayed within the header control's rectangle. When clicked, this button sends an HDN_OVERFLOWCLICK notification.</summary>
HDS_OVERFLOW = 0x1000,
}
public static IntPtr SendMessage(HandleRef hWnd, HeaderMessage message, int wParam, [In, Out] HDITEM item) => User32_Gdi.SendMessage(hWnd, message, wParam, item);
public static IntPtr SendMessage(HandleRef hWnd, HeaderMessage message, int wParam, [In, Out] HDLAYOUT layout) => User32_Gdi.SendMessage(hWnd, message, wParam, layout);
public static IntPtr SendMessage(HandleRef hWnd, HeaderMessage message, int wParam, [In, Out] HDHITTESTINFO hittest) => User32_Gdi.SendMessage(hWnd, message, wParam, hittest);
/// <summary>Contains information about header control text filters.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775251")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct HDTEXTFILTER
{
/// <summary>A pointer to the buffer containing the filter.</summary>
public string pszText;
/// <summary>A value specifying the maximum size, in characters, for an edit control buffer.</summary>
public int cchTextMax;
/// <summary>Initializes a new instance of the <see cref="HDTEXTFILTER"/> struct.</summary>
/// <param name="filter">The filter.</param>
public HDTEXTFILTER(string filter)
{
pszText = filter;
cchTextMax = filter.Length;
}
/// <summary>Initializes a new instance of the <see cref="HDTEXTFILTER"/> struct.</summary>
/// <param name="length">The length.</param>
public HDTEXTFILTER(int length) : this(new string('\0', length))
{
}
/// <summary>Returns a <see cref="System.String"/> that represents this instance.</summary>
/// <returns>A <see cref="System.String"/> that represents this instance.</returns>
public override string ToString() => pszText;
}
/// <summary>Contains information about a hit test. This structure is used with the HDM_HITTEST message and it supersedes the HD_HITTESTINFO structure.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775245")]
[StructLayout(LayoutKind.Sequential)]
@ -329,12 +552,16 @@ namespace Vanara.PInvoke
{
case HeaderItemFilterType.HDFT_ISSTRING:
return pvFilter.ToStructure<HDTEXTFILTER>().ToString();
case HeaderItemFilterType.HDFT_ISNUMBER:
return pvFilter.ToInt32();
case HeaderItemFilterType.HDFT_ISDATE:
return pvFilter.ToStructure<SYSTEMTIME>().ToDateTime(DateTimeKind.Unspecified);
case HeaderItemFilterType.HDFT_HASNOVALUE:
return null;
default:
throw new InvalidOperationException();
}
@ -348,22 +575,27 @@ namespace Vanara.PInvoke
Marshal.FreeCoTaskMem(pvFilter);
pvFilter = IntPtr.Zero;
break;
case DateTime dt:
pvFilter = new SYSTEMTIME(dt).StructureToPtr(Marshal.AllocCoTaskMem, out int _);
type = HeaderItemFilterType.HDFT_ISDATE;
break;
case string str:
pvFilter = new HDTEXTFILTER(str).StructureToPtr(Marshal.AllocCoTaskMem, out int _);
type = HeaderItemFilterType.HDFT_ISSTRING;
break;
case int i:
pvFilter = new IntPtr(i);
type = HeaderItemFilterType.HDFT_ISNUMBER;
break;
case SYSTEMTIME st:
pvFilter = st.StructureToPtr(Marshal.AllocCoTaskMem, out int _);
type = HeaderItemFilterType.HDFT_ISDATE;
break;
default:
throw new ArgumentException("Value must be a string, integer, DateTime or SYSTEMTIME");
}
@ -519,8 +751,10 @@ namespace Vanara.PInvoke
}
}
/// <summary>Gets or sets a value indicating whether this header requests a callback message to retrieve the text.
/// <note>Setting this value to either true or false will remove any previously set value for the <see cref="Text"/> property or <see cref="pszText"/> field.</note></summary>
/// <summary>
/// Gets or sets a value indicating whether this header requests a callback message to retrieve the text. <note>Setting this value to either true or
/// false will remove any previously set value for the <see cref="Text"/> property or <see cref="pszText"/> field.</note>
/// </summary>
/// <value><c>true</c> if using text callback; otherwise, <c>false</c>.</value>
public bool UseTextCallback
{
@ -591,35 +825,6 @@ namespace Vanara.PInvoke
}
}
/// <summary>Contains information about header control text filters.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775251")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HDTEXTFILTER
{
/// <summary>A pointer to the buffer containing the filter.</summary>
[MarshalAs(UnmanagedType.LPWStr)] public string pszText;
/// <summary>A value specifying the maximum size, in characters, for an edit control buffer.</summary>
public int cchTextMax;
/// <summary>Initializes a new instance of the <see cref="HDTEXTFILTER"/> struct.</summary>
/// <param name="filter">The filter.</param>
public HDTEXTFILTER(string filter)
{
pszText = filter;
cchTextMax = filter.Length;
}
/// <summary>Initializes a new instance of the <see cref="HDTEXTFILTER"/> struct.</summary>
/// <param name="length">The length.</param>
public HDTEXTFILTER(int length) : this(new string('\0', length))
{
}
/// <summary>Returns a <see cref="System.String"/> that represents this instance.</summary>
/// <returns>A <see cref="System.String"/> that represents this instance.</returns>
public override string ToString() => pszText;
}
/// <summary>Contains information used in handling HDN_GETDISPINFO notification codes.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775253")]
[StructLayout(LayoutKind.Sequential)]
@ -695,11 +900,5 @@ namespace Vanara.PInvoke
/// </summary>
public IntPtr pItem = IntPtr.Zero;
}
public static IntPtr SendMessage(HandleRef hWnd, HeaderMessage message, int wParam, [In, Out] HDITEM item) => User32_Gdi.SendMessage(hWnd, message, wParam, item);
public static IntPtr SendMessage(HandleRef hWnd, HeaderMessage message, int wParam, [In, Out] HDLAYOUT layout) => User32_Gdi.SendMessage(hWnd, message, wParam, layout);
public static IntPtr SendMessage(HandleRef hWnd, HeaderMessage message, int wParam, [In, Out] HDHITTESTINFO hittest) => User32_Gdi.SendMessage(hWnd, message, wParam, hittest);
}
}

View File

@ -2,15 +2,19 @@ using System;
using System.Runtime.InteropServices;
using static Vanara.PInvoke.Gdi32;
using static Vanara.PInvoke.Kernel32;
using static Vanara.PInvoke.User32_Gdi;
// ReSharper disable InconsistentNaming
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
// ReSharper disable InconsistentNaming ReSharper disable FieldCanBeMadeReadOnly.Global ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
public static partial class ComCtl32
{
/// <summary>Window class name for the Toolbar control.</summary>
public const string TOOLBARCLASSNAME = "ToolbarWindow32";
private const int TBN_FIRST = -700;
/// <summary>Options for CreateMappedBitmap.</summary>
public enum CMB
{
@ -20,6 +24,34 @@ namespace Vanara.PInvoke
CMB_MASKED = 2
}
/// <summary>
/// The value your application can return depends on the current drawing stage. The <c>dwDrawStage</c> member of the associated <c>NMCUSTOMDRAW</c>
/// structure holds a value that specifies the drawing stage. You must return one of the following values.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb760492")]
public enum TBCDRF
{
/// <summary>Version 4.71. Do not draw button edges. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOEDGES = 0x00010000,
/// <summary>
/// Version 4.71. Use the clrHighlightHotTrack member of the NMTBCUSTOMDRAW structure to draw the background of hot-tracked items. This occurs when
/// dwDrawStage equals CDDS_ITEMPREPAINT.
/// </summary>
TBCDRF_HILITEHOTTRACK = 0x00020000,
/// <summary>Version 4.71. Do not offset the button when pressed. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOOFFSET = 0x00040000,
/// <summary>Do not draw default highlight of items that have the TBSTATE_MARKED. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOMARK = 0x00080000,
/// <summary>Version 4.71. Do not draw etched effect for disabled items. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOETCHEDEFFECT = 0x00100000,
/// <summary>Version 5.00. Blend the button 50 percent with the background. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_BLENDICON = 0x00200000,
/// <summary>Version 5.00. Do not draw button background. This occurs when dwDrawStage equals CDDS_ITEMPREPAINT.</summary>
TBCDRF_NOBACKGROUND = 0x00400000,
/// <summary>Version 6.00, Windows Vista only. Use custom draw colors to render text regardless of visual style.</summary>
TBCDRF_USECDCOLORS = 0x00800000,
}
[Flags]
public enum TBSTATE : byte
{
@ -41,8 +73,141 @@ namespace Vanara.PInvoke
TBSTATE_WRAP = 0x20,
}
public enum ToolbarMessage
{
TB_ENABLEBUTTON = WindowMessage.WM_USER + 1,
TB_CHECKBUTTON = WindowMessage.WM_USER + 2,
TB_PRESSBUTTON = WindowMessage.WM_USER + 3,
TB_HIDEBUTTON = WindowMessage.WM_USER + 4,
TB_INDETERMINATE = WindowMessage.WM_USER + 5,
TB_MARKBUTTON = WindowMessage.WM_USER + 6,
TB_ISBUTTONENABLED = WindowMessage.WM_USER + 9,
TB_ISBUTTONCHECKED = WindowMessage.WM_USER + 10,
TB_ISBUTTONPRESSED = WindowMessage.WM_USER + 11,
TB_ISBUTTONHIDDEN = WindowMessage.WM_USER + 12,
TB_ISBUTTONINDETERMINATE = WindowMessage.WM_USER + 13,
TB_ISBUTTONHIGHLIGHTED = WindowMessage.WM_USER + 14,
TB_SETSTATE = WindowMessage.WM_USER + 17,
TB_GETSTATE = WindowMessage.WM_USER + 18,
TB_ADDBITMAP = WindowMessage.WM_USER + 19,
TB_ADDBUTTONSA = WindowMessage.WM_USER + 20,
TB_INSERTBUTTONA = WindowMessage.WM_USER + 21,
TB_DELETEBUTTON = WindowMessage.WM_USER + 22,
TB_GETBUTTON = WindowMessage.WM_USER + 23,
TB_BUTTONCOUNT = WindowMessage.WM_USER + 24,
TB_COMMANDTOINDEX = WindowMessage.WM_USER + 25,
TB_SAVERESTOREA = WindowMessage.WM_USER + 26,
TB_SAVERESTOREW = WindowMessage.WM_USER + 76,
TB_CUSTOMIZE = WindowMessage.WM_USER + 27,
TB_ADDSTRINGA = WindowMessage.WM_USER + 28,
TB_ADDSTRINGW = WindowMessage.WM_USER + 77,
TB_GETITEMRECT = WindowMessage.WM_USER + 29,
TB_BUTTONSTRUCTSIZE = WindowMessage.WM_USER + 30,
TB_SETBUTTONSIZE = WindowMessage.WM_USER + 31,
TB_SETBITMAPSIZE = WindowMessage.WM_USER + 32,
TB_AUTOSIZE = WindowMessage.WM_USER + 33,
TB_GETTOOLTIPS = WindowMessage.WM_USER + 35,
TB_SETTOOLTIPS = WindowMessage.WM_USER + 36,
TB_SETPARENT = WindowMessage.WM_USER + 37,
TB_SETROWS = WindowMessage.WM_USER + 39,
TB_GETROWS = WindowMessage.WM_USER + 40,
TB_GETBITMAPFLAGS = WindowMessage.WM_USER + 41,
TB_SETCMDID = WindowMessage.WM_USER + 42,
TB_CHANGEBITMAP = WindowMessage.WM_USER + 43,
TB_GETBITMAP = WindowMessage.WM_USER + 44,
TB_GETBUTTONTEXTA = WindowMessage.WM_USER + 45,
TB_GETBUTTONTEXTW = WindowMessage.WM_USER + 75,
TB_REPLACEBITMAP = WindowMessage.WM_USER + 46,
TB_SETINDENT = WindowMessage.WM_USER + 47,
TB_SETIMAGELIST = WindowMessage.WM_USER + 48,
TB_GETIMAGELIST = WindowMessage.WM_USER + 49,
TB_LOADIMAGES = WindowMessage.WM_USER + 50,
TB_GETRECT = WindowMessage.WM_USER + 51,
TB_SETHOTIMAGELIST = WindowMessage.WM_USER + 52,
TB_GETHOTIMAGELIST = WindowMessage.WM_USER + 53,
TB_SETDISABLEDIMAGELIST = WindowMessage.WM_USER + 54,
TB_GETDISABLEDIMAGELIST = WindowMessage.WM_USER + 55,
TB_SETSTYLE = WindowMessage.WM_USER + 56,
TB_GETSTYLE = WindowMessage.WM_USER + 57,
TB_GETBUTTONSIZE = WindowMessage.WM_USER + 58,
TB_SETBUTTONWIDTH = WindowMessage.WM_USER + 59,
TB_SETMAXTEXTROWS = WindowMessage.WM_USER + 60,
TB_GETTEXTROWS = WindowMessage.WM_USER + 61,
TB_GETOBJECT = WindowMessage.WM_USER + 62,
TB_GETBUTTONINFOW = WindowMessage.WM_USER + 63,
TB_SETBUTTONINFOW = WindowMessage.WM_USER + 64,
TB_GETBUTTONINFOA = WindowMessage.WM_USER + 65,
TB_SETBUTTONINFOA = WindowMessage.WM_USER + 66,
TB_INSERTBUTTONW = WindowMessage.WM_USER + 67,
TB_ADDBUTTONSW = WindowMessage.WM_USER + 68,
TB_HITTEST = WindowMessage.WM_USER + 69,
TB_SETDRAWTEXTFLAGS = WindowMessage.WM_USER + 70,
TB_GETHOTITEM = WindowMessage.WM_USER + 71,
TB_SETHOTITEM = WindowMessage.WM_USER + 72,
TB_SETANCHORHIGHLIGHT = WindowMessage.WM_USER + 73,
TB_GETANCHORHIGHLIGHT = WindowMessage.WM_USER + 74,
TB_MAPACCELERATORA = WindowMessage.WM_USER + 78,
TB_GETINSERTMARK = WindowMessage.WM_USER + 79,
TB_SETINSERTMARK = WindowMessage.WM_USER + 80,
TB_INSERTMARKHITTEST = WindowMessage.WM_USER + 81,
TB_MOVEBUTTON = WindowMessage.WM_USER + 82,
TB_GETMAXSIZE = WindowMessage.WM_USER + 83,
TB_SETEXTENDEDSTYLE = WindowMessage.WM_USER + 84,
TB_GETEXTENDEDSTYLE = WindowMessage.WM_USER + 85,
TB_GETPADDING = WindowMessage.WM_USER + 86,
TB_SETPADDING = WindowMessage.WM_USER + 87,
TB_SETINSERTMARKCOLOR = WindowMessage.WM_USER + 88,
TB_GETINSERTMARKCOLOR = WindowMessage.WM_USER + 89,
TB_MAPACCELERATORW = WindowMessage.WM_USER + 90,
TB_GETSTRINGW = WindowMessage.WM_USER + 91,
TB_GETSTRINGA = WindowMessage.WM_USER + 92,
TB_SETBOUNDINGSIZE = WindowMessage.WM_USER + 93,
TB_SETHOTITEM2 = WindowMessage.WM_USER + 94,
TB_HASACCELERATOR = WindowMessage.WM_USER + 95,
TB_SETLISTGAP = WindowMessage.WM_USER + 96,
TB_GETIMAGELISTCOUNT = WindowMessage.WM_USER + 98,
TB_GETIDEALSIZE = WindowMessage.WM_USER + 99,
TB_GETMETRICS = WindowMessage.WM_USER + 101,
TB_SETMETRICS = WindowMessage.WM_USER + 102,
TB_GETITEMDROPDOWNRECT = WindowMessage.WM_USER + 103,
TB_SETPRESSEDIMAGELIST = WindowMessage.WM_USER + 104,
TB_GETPRESSEDIMAGELIST = WindowMessage.WM_USER + 105,
}
public enum ToolbarNotification
{
TBN_GETBUTTONINFOA = TBN_FIRST - 0,
TBN_BEGINDRAG = TBN_FIRST - 1,
TBN_ENDDRAG = TBN_FIRST - 2,
TBN_BEGINADJUST = TBN_FIRST - 3,
TBN_ENDADJUST = TBN_FIRST - 4,
TBN_RESET = TBN_FIRST - 5,
TBN_QUERYINSERT = TBN_FIRST - 6,
TBN_QUERYDELETE = TBN_FIRST - 7,
TBN_TOOLBARCHANGE = TBN_FIRST - 8,
TBN_CUSTHELP = TBN_FIRST - 9,
TBN_DROPDOWN = TBN_FIRST - 10,
TBN_GETOBJECT = TBN_FIRST - 12,
TBN_HOTITEMCHANGE = TBN_FIRST - 13,
TBN_DRAGOUT = TBN_FIRST - 14,
TBN_DELETINGBUTTON = TBN_FIRST - 15,
TBN_GETDISPINFOA = TBN_FIRST - 16,
TBN_GETDISPINFOW = TBN_FIRST - 17,
TBN_GETINFOTIPA = TBN_FIRST - 18,
TBN_GETINFOTIPW = TBN_FIRST - 19,
TBN_GETBUTTONINFOW = TBN_FIRST - 20,
TBN_RESTORE = TBN_FIRST - 21,
TBN_SAVE = TBN_FIRST - 22,
TBN_INITCUSTOMIZE = TBN_FIRST - 23,
TBN_WRAPHOTITEM = TBN_FIRST - 24,
TBN_DUPACCELERATOR = TBN_FIRST - 25,
TBN_WRAPACCELERATOR = TBN_FIRST - 26,
TBN_DRAGOVER = TBN_FIRST - 27,
TBN_MAPACCELERATOR = TBN_FIRST - 28,
}
[Flags]
public enum TBSTYLE : ushort
public enum ToolbarStyle : ushort
{
/// <summary>
/// Allows users to change a toolbar button's position by dragging it while holding down the ALT key. If this style is not specified, the user must
@ -95,6 +260,56 @@ namespace Vanara.PInvoke
TBSTYLE_WRAPABLE = 0x0200,
}
/// <summary>This section lists the extended styles supported by toolbar controls.</summary>
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb760430(v=vs.85).aspx
[PInvokeData("CommCtrl.h", MSDNShortId = "bb760430")]
[Flags]
public enum ToolbarStyleEx
{
/// <summary>
/// Version 4.71. This style allows buttons to have a separate dropdown arrow. Buttons that have the BTNS_DROPDOWN style will be drawn with a
/// dropdown arrow in a separate section, to the right of the button. If the arrow is clicked, only the arrow portion of the button will depress, and
/// the toolbar control will send a TBN_DROPDOWN notification code to prompt the application to display the dropdown menu. If the main part of the
/// button is clicked, the toolbar control sends a WM_COMMAND message with the button's ID. The application normally responds by launching the first
/// command on the menu. There are many situations where you may want to have only some of the dropdown buttons on a toolbar with separated arrows.
/// To do so, set the TBSTYLE_EX_DRAWDDARROWS extended style. Give those buttons that will not have separated arrows the BTNS_WHOLEDROPDOWN style.
/// Buttons with this style will have an arrow displayed next to the image. However, the arrow will not be separate and when any part of the button
/// is clicked, the toolbar control will send a TBN_DROPDOWN notification code. To prevent repainting problems, this style should be set before the
/// toolbar control becomes visible.
/// </summary>
TBSTYLE_EX_DRAWDDARROWS = 0x00000001,
/// <summary>
/// Version 5.81. This style allows you to set text for all buttons, but only display it for those buttons with the BTNS_SHOWTEXT button style. The
/// TBSTYLE_LIST style must also be set. Normally, when a button does not display text, your application must handle TBN_GETINFOTIP or
/// TTN_GETDISPINFO to display a tooltip. With the TBSTYLE_EX_MIXEDBUTTONS extended style, text that is set but not displayed on a button will
/// automatically be used as the button's tooltip text. Your application only needs to handle TBN_GETINFOTIP or or TTN_GETDISPINFO if it needs more
/// flexibility in specifying the tooltip text.
/// </summary>
TBSTYLE_EX_MIXEDBUTTONS = 0x00000008,
/// <summary>
/// Version 5.81. This style hides partially clipped buttons. The most common use of this style is for toolbars that are part of a rebar control. If
/// an adjacent band covers part of a button, the button will not be displayed. However, if the rebar band has the RBBS_USECHEVRON style, the button
/// will be displayed on the chevron's dropdown menu.
/// </summary>
TBSTYLE_EX_HIDECLIPPEDBUTTONS = 0x00000010,
/// <summary>
/// Version 5.82. Intended for internal use; not recommended for use in applications. This style gives the toolbar a vertical orientation and
/// organizes the toolbar buttons into columns. The buttons flow down vertically until a button has exceeded the bounding height of the toolbar (see
/// TB_SETBOUNDINGSIZE), and then a new column is created. The toolbar flows the buttons in this manner until all buttons are positioned. To use this
/// style, the TBSTYLE_EX_VERTICAL style must also be set.
/// </summary>
TBSTYLE_EX_MULTICOLUMN = 0x00000002,
/// <summary>
/// Version 5.82. Intended for internal use; not recommended for use in applications. This style gives the toolbar a vertical orientation. Toolbar
/// buttons flow from top to bottom instead of horizontally.
/// </summary>
TBSTYLE_EX_VERTICAL = 0x00000004,
/// <summary>
/// Version 6. This style requires the toolbar to be double buffered. Double buffering is a mechanism that detects when the toolbar has changed.
/// </summary>
TBSTYLE_EX_DOUBLEBUFFER = 0x00000080,
}
/// <summary>Creates a bitmap for use in a toolbar.</summary>
/// <param name="hInstance">
/// <para>Type: <c><c>HINSTANCE</c></c></para>
@ -157,7 +372,441 @@ namespace Vanara.PInvoke
public COLORREF to;
}
/// <summary>Contains and receives display information for a toolbar item. This structure is used with the TBN_GETDISPINFO notification code.</summary>
// typedef struct { NMHDR hdr; DWORD dwMask; int idCommand; DWORD_PTR lParam; int iImage; LPTSTR pszText; int cchText;} NMTBDISPINFO, *LPNMTBDISPINFO; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760452(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760452")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct NMTBDISPINFO
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>Set of flags that indicate which members of this structure are being requested. This can be one or more of the following values.</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>TBNF_IMAGE</term>
/// <term>The item&amp;#39;s image index is being requested. The image index must be placed in the iImage member.</term>
/// </item>
/// <item>
/// <term>TBNF_TEXT</term>
/// <term>Not currently implemented.</term>
/// </item>
/// <item>
/// <term>TBNF_DI_SETITEM</term>
/// <term>Set this flag when processing TBN_GETDISPINFO; the toolbar control will retain the supplied information and not request it again.</term>
/// </item>
/// </list>
/// </para>
/// </summary>
public uint dwMask;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Command identifier of the item for which display information is being requested. This member is filled in by the control before it sends the
/// notification code.
/// </para>
/// </summary>
public int idCommand;
/// <summary>
/// <para>Type: <c><c>DWORD_PTR</c></c></para>
/// <para>
/// Application-defined value associated with the item for which display information is being requested. This member is filled in by the control
/// before sending the notification code.
/// </para>
/// </summary>
public IntPtr lParam;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Image index for the item.</para>
/// </summary>
public int iImage;
/// <summary>
/// <para>Type: <c><c>LPTSTR</c></c></para>
/// <para>Pointer to a character buffer that receives the item's text.</para>
/// </summary>
public string pszText;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Size of the <c>pszText</c> buffer, in characters.</para>
/// </summary>
public int cchText;
}
/// <summary>Contains and receives infotip information for a toolbar item. This structure is used with the TBN_GETINFOTIP notification code.</summary>
// typedef struct tagNMTBGETINFOTIP { NMHDR hdr; LPTSTR pszText; int cchTextMax; int iItem; LPARAM lParam;} NMTBGETINFOTIP, *LPNMTBGETINFOTIP; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760454(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760454")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct NMTBGETINFOTIP
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>LPTSTR</c></c></para>
/// <para>Address of a character buffer that receives the infotip text.</para>
/// </summary>
public string pszText;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Size of the buffer, in characters, at <c>pszText</c>. In most cases, the buffer will be INFOTIPSIZE characters in size, but you should always
/// make sure that your application does not copy more than <c>cchTextMax</c> characters to the buffer at <c>pszText</c>.
/// </para>
/// </summary>
public int cchTextMax;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// The command identifier of the item for which infotip information is being requested. This member is filled in by the control before sending the
/// notification code.
/// </para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c><c>LPARAM</c></c></para>
/// <para>
/// The application-defined value associated with the item for which infotip information is being requested. This member is filled in by the control
/// before sending the notification code.
/// </para>
/// </summary>
public IntPtr lParam;
}
/// <summary>Contains information used with the TBN_HOTITEMCHANGE notification code.</summary>
// typedef struct tagNMTBHOTITEM { NMHDR hdr; int idOld; int idNew; DWORD dwFlags;} NMTBHOTITEM, *LPNMTBHOTITEM; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760456(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760456")]
[StructLayout(LayoutKind.Sequential)]
public struct NMTBHOTITEM
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Command identifier of the previously highlighted item.</para>
/// </summary>
public int idOld;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Command identifier of the item about to be highlighted.</para>
/// </summary>
public int idNew;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>Flags that indicate why the hot item has changed. This can be one or more of the following values:</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>HICF_ACCELERATOR</term>
/// <term>The change in the hot item was caused by a shortcut key.</term>
/// </item>
/// <item>
/// <term>HICF_ARROWKEYS</term>
/// <term>The change in the hot item was caused by an arrow key.</term>
/// </item>
/// <item>
/// <term>HICF_DUPACCEL</term>
/// <term>Modifies HICF_ACCELERATOR. If this flag is set, more than one item has the same shortcut key character.</term>
/// </item>
/// <item>
/// <term>HICF_ENTERING</term>
/// <term>Modifies the other reason flags. If this flag is set, there is no previous hot item and idOld does not contain valid information.</term>
/// </item>
/// <item>
/// <term>HICF_LEAVING</term>
/// <term>Modifies the other reason flags. If this flag is set, there is no new hot item and idNew does not contain valid information.</term>
/// </item>
/// <item>
/// <term>HICF_LMOUSE</term>
/// <term>The change in the hot item resulted from a left-click mouse event.</term>
/// </item>
/// <item>
/// <term>HICF_MOUSE</term>
/// <term>The change in the hot item resulted from a mouse event.</term>
/// </item>
/// <item>
/// <term>HICF_OTHER</term>
/// <term>
/// The change in the hot item resulted from an event that could not be determined. This will most often be due to a change in focus or the
/// TB_SETHOTITEM message.
/// </term>
/// </item>
/// <item>
/// <term>HICF_RESELECT</term>
/// <term>The change in the hot item resulted from the user entering the shortcut key for an item that was already hot.</term>
/// </item>
/// <item>
/// <term>HICF_TOGGLEDROPDOWN</term>
/// <term>Version 5.80. Causes the button to switch states.</term>
/// </item>
/// </list>
/// </para>
/// </summary>
public uint dwFlags; // HICF_*
}
/// <summary>
/// Allows applications to extract the information that was placed in <c>NMTBSAVE</c> when the toolbar state was saved. This structure is passed to
/// applications when they receive a TBN_RESTORE notification code.
/// </summary>
// typedef struct tagNMTBRESTORE { NMHDR nmhdr; DWORD *pData; DWORD *pCurrent; UINT cbData; int iItem; int cButtons; int cbBytesPerRecord; TBBUTTON
// tbButton;} NMTBRESTORE, *LPNMTBRESTORE; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760458(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760458")]
[StructLayout(LayoutKind.Sequential)]
public struct NMTBRESTORE
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>DWORD</c>*</c></para>
/// <para>
/// Pointer to the data stream with the stored save information. It contains Shell-defined blocks of information for each button, alternating with
/// application-defined blocks. Applications may also place a block of global data at the start of <c>pData</c>. The format and length of the
/// application-defined blocks are determined by the application.
/// </para>
/// </summary>
public IntPtr pData;
/// <summary>
/// <para>Type: <c><c>DWORD</c>*</c></para>
/// <para>
/// Pointer to the current block of application-defined data. After extracting the data, the application must advance <c>pCurrent</c> to the end of
/// the block, so it is pointing to the next block of Shell-defined data.
/// </para>
/// </summary>
public IntPtr pCurrent;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>Size of <c>pData</c>.</para>
/// </summary>
public uint cbData;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Value of -1 indicates that the restore is starting, and <c>pCurrent</c> will point to the start of the data stream. Otherwise, it is the
/// zero-based button index, and <c>pCurrent</c> will point to the current button's data.
/// </para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Estimate of the number of buttons. Because the estimate is based on the size of the data stream, it might be incorrect. The client should update
/// it as appropriate.
/// </para>
/// </summary>
public int cButtons;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Number of bytes needed to hold the data for each button. When the restore starts, <c>cbBytesPerRecord</c> will be set to the size of the
/// Shell-defined data structure. You need to increment it by the size of the structure that holds the application-defined data.
/// </para>
/// </summary>
public int cbBytesPerRecord;
/// <summary>
/// <para>Type: <c><c>TBBUTTON</c></c></para>
/// <para>
/// <c>TBBUTTON</c> structure that contains information about the button currently being restored. Applications must modify this structure as
/// necessary before returning.
/// </para>
/// </summary>
public TBBUTTON tbButton;
}
/// <summary>
/// This structure is passed to applications when they receive a TBN_SAVE notification code. It contains information about the button currently being
/// saved. Applications can modify the values of the members to save additional information.
/// </summary>
// typedef struct tagNMTBSAVE { NMHDR hdr; DWORD *pData; DWORD *pCurrent; UINT cbData; int iItem; int cButtons; TBBUTTON tbButton;} NMTBSAVE,
// *LPNMTBSAVE; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760471(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760471")]
[StructLayout(LayoutKind.Sequential)]
public struct NMTBSAVE
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para>An <c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>DWORD</c>*</c></para>
/// <para>
/// A pointer to the data stream used to store the save information. When complete, it will contain blocks of Shell-defined information for each
/// button, alternating with blocks defined by the application. Applications may also choose to place a block of global data at the start of
/// <c>pData</c>. The format and length of the application-defined blocks are determined by the application. When the save starts, the Shell will
/// pass the amount of memory it needs in <c>cbData</c>, but no memory will be allocated. You must allocate enough memory for <c>pData</c> to hold
/// your data, plus the Shell's.
/// </para>
/// </summary>
public IntPtr pData;
/// <summary>
/// <para>Type: <c><c>DWORD</c>*</c></para>
/// <para>
/// A pointer to the start of the unused portion of the data stream. You should load your data here, and then advance <c>pCurrent</c> to the start of
/// the remaining unused portion. The Shell will then load the information for the next button, advance <c>pCurrent</c>, and so on.
/// </para>
/// </summary>
public IntPtr pCurrent;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>
/// The size of the data stream. When the save starts, <c>cbData</c> will be set to the amount of data needed by the Shell. You should change it to
/// the total amount allocated.
/// </para>
/// </summary>
public uint cbData;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>This parameter is usually the zero-based index of the button currently being saved. It is set to -1 to indicate that a save is starting.</para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// An estimate of the number of buttons. Because it is based on the size of the data stream, it may be incorrect. The client should update it as appropriate.
/// </para>
/// </summary>
public int cButtons;
/// <summary>
/// <para>Type: <c><c>TBBUTTON</c></c></para>
/// <para>A <c>TBBUTTON</c> structure that contains information about the button currently being saved.</para>
/// </summary>
public TBBUTTON tbButton;
}
/// <summary>Contains information used to process toolbar notification codes. This structure supersedes the <c>TBNOTIFY</c> structure.</summary>
// typedef struct tagNMTOOLBAR { NMHDR hdr; int iItem; TBBUTTON tbButton; int cchText; LPTSTR pszText; RECT rcButton;} NMTOOLBAR, *LPNMTOOLBAR; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760473(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760473")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct NMTOOLBAR
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para><c>NMHDR</c> structure that contains additional information about the notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Command identifier of the button associated with the notification code.</para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c><c>TBBUTTON</c></c></para>
/// <para>
/// <c>TBBUTTON</c> structure that contains information about the toolbar button associated with the notification code. This member only contains
/// valid information with the TBN_QUERYINSERT and TBN_QUERYDELETE notification codes.
/// </para>
/// </summary>
public TBBUTTON tbButton;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Count of characters in the button text.</para>
/// </summary>
public int cchText;
/// <summary>
/// <para>Type: <c><c>LPTSTR</c></c></para>
/// <para>Address of a character buffer that contains the button text.</para>
/// </summary>
public string pszText;
/// <summary>
/// <para>Type: <c><c>RECT</c></c></para>
/// <para>Version 5.80. A <c>RECT</c> structure that defines the area covered by the button.</para>
/// </summary>
public RECT rcButton;
}
/// <summary>Adds a bitmap that contains button images to a toolbar.</summary>
// typedef struct { HINSTANCE hInst; UINT_PTR nID;} TBADDBITMAP, *LPTBADDBITMAP; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760475(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760475")]
[StructLayout(LayoutKind.Sequential)]
public struct TBADDBITMAP
{
/// <summary>
/// <para>Type: <c><c>HINSTANCE</c></c></para>
/// <para>
/// Handle to the module instance with the executable file that contains a bitmap resource. To use bitmap handles instead of resource IDs, set this
/// member to <c>NULL</c>.
/// </para>
/// <para>
/// You can add the system-defined button bitmaps to the list by specifying HINST_COMMCTRL as the <c>hInst</c> member and one of the following values
/// as the <c>nID</c> member.
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>IDB_STD_LARGE_COLOR</term>
/// <term>Large, color standard bitmaps.</term>
/// </item>
/// <item>
/// <term>IDB_STD_SMALL_COLOR</term>
/// <term>Small, color standard bitmaps.</term>
/// </item>
/// <item>
/// <term>IDB_VIEW_LARGE_COLOR</term>
/// <term>Small large, color view bitmaps.</term>
/// </item>
/// <item>
/// <term>IDB_VIEW_SMALL_COLOR</term>
/// <term>Small, color view bitmaps.</term>
/// </item>
/// <item>
/// <term>IDB_HIST_NORMAL</term>
/// <term>Windows Explorer travel buttons and favorites bitmaps in normal state.</term>
/// </item>
/// <item>
/// <term>IDB_HIST_HOT</term>
/// <term>Windows Explorer travel buttons and favorites bitmaps in hot state.</term>
/// </item>
/// <item>
/// <term>IDB_HIST_DISABLED</term>
/// <term>Windows Explorer travel buttons and favorites bitmaps in disabled state.</term>
/// </item>
/// <item>
/// <term>IDB_HIST_PRESSED</term>
/// <term>Windows Explorer travel buttons and favorites bitmaps in pressed state.</term>
/// </item>
/// </list>
/// </para>
/// </summary>
public IntPtr hInst;
/// <summary>
/// <para>Type: <c><c>UINT_PTR</c></c></para>
/// <para>
/// If <c>hInst</c> is <c>NULL</c>, set this member to the bitmap handle of the bitmap with the button images. Otherwise, set it to the resource
/// identifier of the bitmap with the button images.
/// </para>
/// </summary>
public IntPtr nID;
}
/// <summary>Contains information about a button in a toolbar.</summary>
// typedef struct { int iBitmap; int idCommand; BYTE fsState; BYTE fsStyle;#ifdef _WIN64 BYTE bReserved[6];#else #if defined(_WIN32) BYTE bReserved[2];#endif #endif DWORD_PTR dwData; INT_PTR iString;} TBBUTTON, *PTBBUTTON, *LPTBBUTTON;
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb760476(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760476")]
[StructLayout(LayoutKind.Sequential)]
public struct TBBUTTON
{
@ -183,7 +832,7 @@ namespace Vanara.PInvoke
public TBSTATE fsState { get => union.fsState; set => union.fsState = value; }
/// <summary>Button style.</summary>
public TBSTYLE fsStyle { get => union.fsStyle; set => union.fsStyle = value; }
public ToolbarStyle fsStyle { get => union.fsStyle; set => union.fsStyle = value; }
/// <summary>Application-defined value.</summary>
public IntPtr dwData;
@ -195,8 +844,288 @@ namespace Vanara.PInvoke
{
[FieldOffset(0)] private IntPtr bReserved;
[FieldOffset(0)] public TBSTATE fsState;
[FieldOffset(1)] public TBSTYLE fsStyle;
[FieldOffset(1)] public ToolbarStyle fsStyle;
}
}
/// <summary>Contains or receives information for a specific button in a toolbar.</summary>
// typedef struct { UINT cbSize; DWORD dwMask; int idCommand; int iImage; BYTE fsState; BYTE fsStyle; WORD cx; DWORD_PTR lParam; LPTSTR pszText; int
// cchText;} TBBUTTONINFO, *LPTBBUTTONINFO; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760478(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760478")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
public struct TBBUTTONINFO
{
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>Size of the structure, in bytes. This member must be filled in prior to sending the associated message.</para>
/// </summary>
public uint cbSize;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>
/// Set of flags that indicate which members contain valid information. This member must be filled in prior to sending the associated message. This
/// can be one or more of the following values.
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>TBIF_BYINDEX</term>
/// <term>Version 5.80. The wParam sent with a TB_GETBUTTONINFO or TB_SETBUTTONINFO message is an index, not an identifier.</term>
/// </item>
/// <item>
/// <term>TBIF_COMMAND</term>
/// <term>The idCommand member contains valid information or is being requested.</term>
/// </item>
/// <item>
/// <term>TBIF_IMAGE</term>
/// <term>The iImage member contains valid information or is being requested.</term>
/// </item>
/// <item>
/// <term>TBIF_LPARAM</term>
/// <term>The lParam member contains valid information or is being requested.</term>
/// </item>
/// <item>
/// <term>TBIF_SIZE</term>
/// <term>The cx member contains valid information or is being requested.</term>
/// </item>
/// <item>
/// <term>TBIF_STATE</term>
/// <term>The fsState member contains valid information or is being requested.</term>
/// </item>
/// <item>
/// <term>TBIF_STYLE</term>
/// <term>The fsStyle member contains valid information or is being requested.</term>
/// </item>
/// <item>
/// <term>TBIF_TEXT</term>
/// <term>The pszText member contains valid information or is being requested.</term>
/// </item>
/// </list>
/// </para>
/// </summary>
public uint dwMask;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Command identifier of the button.</para>
/// </summary>
public int idCommand;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// Image index of the button. Set this member to I_IMAGECALLBACK, and the toolbar will send the TBN_GETDISPINFO notification code to retrieve the
/// image index when it is needed.
/// </para>
/// <para>
/// Version 5.81. Set this member to I_IMAGENONE to indicate that the button does not have an image. The button layout will not include any space for
/// a bitmap, only text.
/// </para>
/// </summary>
public int iImage;
/// <summary>
/// <para>Type: <c><c>BYTE</c></c></para>
/// <para>State flags of the button. This can be one or more of the values listed in Toolbar Button States.</para>
/// </summary>
public byte fsState;
/// <summary>
/// <para>Type: <c><c>BYTE</c></c></para>
/// <para>Style flags of the button. This can be one or more of the values listed in Toolbar Control and Button Styles.</para>
/// </summary>
public byte fsStyle;
/// <summary>
/// <para>Type: <c><c>WORD</c></c></para>
/// <para>Width of the button, in pixels.</para>
/// </summary>
public ushort cx;
/// <summary>
/// <para>Type: <c><c>DWORD_PTR</c></c></para>
/// <para>Application-defined value associated with the button.</para>
/// </summary>
public IntPtr lParam;
/// <summary>
/// <para>Type: <c><c>LPTSTR</c></c></para>
/// <para>Address of a character buffer that contains or receives the button text.</para>
/// </summary>
public string pszText;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Size of the buffer at <c>pszText</c>. If the button information is being set, this member is ignored.</para>
/// </summary>
public int cchText;
}
/// <summary>Contains information on the insertion mark in a toolbar control.</summary>
// typedef struct { int iButton; DWORD dwFlags;} TBINSERTMARK, *LPTBINSERTMARK; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760480(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760480")]
[StructLayout(LayoutKind.Sequential)]
public struct TBINSERTMARK
{
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Zero-based index of the insertion mark. If this member is -1, there is no insertion mark.</para>
/// </summary>
public int iButton;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>Defines where the insertion mark is in relation to <c>iButton</c>. This can be one of the following values:</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>The insertion mark is to the left of the specified button.</term>
/// </item>
/// <item>
/// <term>TBIMHT_AFTER</term>
/// <term>The insertion mark is to the right of the specified button.</term>
/// </item>
/// <item>
/// <term>TBIMHT_BACKGROUND</term>
/// <term>The insertion mark is on the background of the toolbar. This flag is only used with the TB_INSERTMARKHITTEST message.</term>
/// </item>
/// </list>
/// </para>
/// </summary>
public uint dwFlags;
}
/// <summary>Defines the metrics of a toolbar that are used to shrink or expand toolbar items.</summary>
// typedef struct { UINT cbSize; DWORD dwMask; int cxPad; int cyPad; int cxBarPad; int cyBarPad; int cxButtonSpacing; int cyButtonSpacing;} TBMETRICS,
// *LPTBMETRICS; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760482(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760482")]
[StructLayout(LayoutKind.Sequential)]
public struct TBMETRICS
{
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>Size of the <c>TBMETRICS</c> structure.</para>
/// </summary>
public uint cbSize;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>Mask that determines the metric to retrieve. It can be any combination of the following:</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>TBMF_PAD</term>
/// <term>Retrieve the cxPad and cyPad values.</term>
/// </item>
/// <item>
/// <term>TBMF_BARPAD</term>
/// <term>Retrieve the cxBarPad and cyBarPad values.</term>
/// </item>
/// <item>
/// <term>TBMF_BUTTONSPACING</term>
/// <term>Retrieve the cxButtonSpacing and cyButtonSpacing values.</term>
/// </item>
/// </list>
/// </para>
/// </summary>
public uint dwMask;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Width of the padding inside the toolbar buttons, between the content and the edge of the button.</para>
/// </summary>
public int cxPad;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Height of the padding inside the toolbar buttons, between the content and the edge of the button.</para>
/// </summary>
public int cyPad;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Width of the toolbar. Not used.</para>
/// </summary>
public int cxBarPad;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Height of the toolbar. Not used.</para>
/// </summary>
public int cyBarPad;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Width of the space between toolbar buttons.</para>
/// </summary>
public int cxButtonSpacing;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Height of the space between toolbar buttons.</para>
/// </summary>
public int cyButtonSpacing;
}
/// <summary>Used with the <c>TB_REPLACEBITMAP</c> message to replace one toolbar bitmap with another.</summary>
// typedef struct { HINSTANCE hInstOld; UINT_PTR nIDOld; HINSTANCE hInstNew; UINT_PTR nIDNew; int nButtons;} TBREPLACEBITMAP, *LPTBREPLACEBITMAP; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760484(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760484")]
[StructLayout(LayoutKind.Sequential)]
public struct TBREPLACEBITMAP
{
/// <summary>
/// <para>Type: <c><c>HINSTANCE</c></c></para>
/// <para>Module instance handle to the bitmap resource being replaced. Set this member to <c>NULL</c> to instead use a bitmap handle.</para>
/// </summary>
public IntPtr hInstOld;
/// <summary>
/// <para>Type: <c><c>UINT_PTR</c></c></para>
/// <para>
/// If <c>hInstOld</c> is <c>NULL</c>, set this member to the bitmap handle of the bitmap that is being replaced. Otherwise, set it to the resource
/// identifier of the bitmap being replaced.
/// </para>
/// </summary>
public IntPtr nIDOld;
/// <summary>
/// <para>Type: <c><c>HINSTANCE</c></c></para>
/// <para>Module instance handle that contains the new bitmap resource. Set this member to <c>NULL</c> to instead use a bitmap handle.</para>
/// </summary>
public IntPtr hInstNew;
/// <summary>
/// <para>Type: <c><c>UINT_PTR</c></c></para>
/// <para>
/// If <c>hInstNew</c> is <c>NULL</c>, set this member to the bitmap handle of the bitmap with the new button images. Otherwise, set it to the
/// resource identifier of the bitmap with the new button images.
/// </para>
/// </summary>
public IntPtr nIDNew;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Number of button images contained in the new bitmap. The number of new images should be the same as the number of replaced images.</para>
/// </summary>
public int nButtons;
}
/// <summary>
/// Specifies the location in the registry where the <c>TB_SAVERESTORE</c> message stores and retrieves information about the state of a toolbar.
/// </summary>
// typedef struct { HKEY hkr; LPCTSTR pszSubKey; LPCTSTR pszValueName;} TBSAVEPARAMS; https://msdn.microsoft.com/en-us/library/windows/desktop/bb760486(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb760486")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct TBSAVEPARAMS
{
/// <summary>
/// <para>Type: <c><c>HKEY</c></c></para>
/// <para>Handle to the registry key.</para>
/// </summary>
public IntPtr hkr;
/// <summary>
/// <para>Type: <c><c>LPCTSTR</c></c></para>
/// <para>Subkey name.</para>
/// </summary>
public string pszSubKey;
/// <summary>
/// <para>Type: <c><c>LPCTSTR</c></c></para>
/// <para>Value name.</para>
/// </summary>
public string pszValueName;
}
}
}

View File

@ -24,9 +24,41 @@ namespace Vanara.PInvoke
[PInvokeData("Commctrl.h")]
public static readonly IntPtr LPSTR_TEXTCALLBACK = (IntPtr)(-1);
/// <summary>
/// The set of bit flags that indicate which common control classes will be loaded from the DLL when calling <see cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/>.
/// </summary>
/// <summary>Defines the prototype for the callback function used by <c>RemoveWindowSubclass</c> and <c>SetWindowSubclass</c>.</summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>The handle to the subclassed window.</para>
/// </param>
/// <param name="uMsg">
/// <para>Type: <c>UINT</c></para>
/// <para>The message being passed.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <c>WPARAM</c></para>
/// <para>Additional message information. The contents of this parameter depend on the value of uMsg.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <c>LPARAM</c></para>
/// <para>Additional message information. The contents of this parameter depend on the value of uMsg.</para>
/// </param>
/// <param name="uIdSubclass">
/// <para>Type: <c>UINT_PTR</c></para>
/// <para>The subclass ID.</para>
/// </param>
/// <param name="dwRefData">
/// <para>Type: <c>DWORD_PTR</c></para>
/// <para>The reference data provided to the <c>SetWindowSubclass</c> function. This can be used to associate the subclass instance with a "this" pointer.</para>
/// </param>
/// <returns>
/// <para>Type: <c>LRESULT</c></para>
/// <para>The return value is the result of the message processing and depends on the message sent.</para>
/// </returns>
// typedef LRESULT ( CALLBACK *SUBCLASSPROC)( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776774(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb776774")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate IntPtr SUBCLASSPROC(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, [MarshalAs(UnmanagedType.SysUInt)] uint uIdSubclass, IntPtr dwRefData);
/// <summary>The set of bit flags that indicate which common control classes will be loaded from the DLL when calling <see cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/>.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775507")]
[Flags]
public enum CommonControlClass
@ -564,6 +596,34 @@ namespace Vanara.PInvoke
HOTKEYF_EXT = 0x08,
}
/// <summary>The desired metric.</summary>
public enum LI_METRIC
{
/// <summary>Corresponds to SM_CXSMICON, the recommended pixel width of a small icon.</summary>
LIM_SMALL,
/// <summary>Corresponds toSM_CXICON, the default pixel width of an icon.</summary>
LIM_LARGE,
}
/// <summary>
/// Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time. This function calls TrackMouseEvent if
/// it exists, otherwise it emulates it.
/// </summary>
/// <param name="lpEventTrack">
/// <para>Type: <c>LPTRACKMOUSEEVENT</c></para>
/// <para>A pointer to a <c>TRACKMOUSEEVENT</c> structure that contains tracking information.</para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If the function succeeds, the return value is nonzero .</para>
/// <para>If the function fails, return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI TrackMouseEvent( _Inout_ LPTRACKMOUSEEVENT lpEventTrack); https://msdn.microsoft.com/en-us/library/windows/desktop/ms646266(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("CommCtrl.h", MSDNShortId = "ms646266")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool _TrackMouseEvent(ref User32.TRACKMOUSEEVENT lpEventTrack);
/// <summary>
/// Calls the next handler in a window's subclass chain. The last handler in the subclass chain calls the original window procedure for the window.
/// </summary>
@ -590,8 +650,7 @@ namespace Vanara.PInvoke
/// <para>Type: <c>LRESULT</c></para>
/// <para>The returned value is specific to the message sent. This value should be ignored.</para>
/// </returns>
// LRESULT DefSubclassProc( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM WPARAM, _In_ LPARAM LPARAM);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb776403(v=vs.85).aspx
// LRESULT DefSubclassProc( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM WPARAM, _In_ LPARAM LPARAM); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776403(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb776403")]
public static extern IntPtr DefSubclassProc(HandleRef hWnd, uint uMsg, IntPtr WPARAM, IntPtr LPARAM);
@ -637,11 +696,11 @@ namespace Vanara.PInvoke
/// <para>Type: <c>int</c></para>
/// <para>Returns the height of the text in logical units if the function succeeds, otherwise returns zero.</para>
/// </returns>
// int DrawShadowText( HDC hdc, LPCWSTR pszText, UINT cch, const RECT *pRect, DWORD dwFlags, COLORREF crText, COLORREF crShadow, int ixOffset, int iyOffset);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb775639(v=vs.85).aspx
// int DrawShadowText( HDC hdc, LPCWSTR pszText, UINT cch, const RECT *pRect, DWORD dwFlags, COLORREF crText, COLORREF crShadow, int ixOffset, int
// iyOffset); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775639(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775639")]
public static extern int DrawShadowText(SafeDCHandle hdc, string pszText, uint cch, ref RECT pRect, uint dwFlags, COLORREF crText, COLORREF crShadow, int ixOffset, int iyOffset);
public static extern int DrawShadowText(SafeDCHandle hdc, string pszText, uint cch, ref RECT pRect, uint dwFlags, COLORREF crText, COLORREF crShadow, int ixOffset, int iyOffset);
/// <summary>Calculates the dimensions of a rectangle in the client area that contains all the specified controls.</summary>
/// <param name="hWnd">
@ -661,8 +720,7 @@ namespace Vanara.PInvoke
/// </para>
/// </param>
/// <returns>No return value.</returns>
// void GetEffectiveClientRect( HWND hWnd, LPRECT lprc, _In_ const INT *lpInfo);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb775674(v=vs.85).aspx
// void GetEffectiveClientRect( HWND hWnd, LPRECT lprc, _In_ const INT *lpInfo); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775674(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775674")]
public static extern void GetEffectiveClientRect(HandleRef hWnd, out RECT lprc, IntPtr lpInfo);
@ -671,8 +729,7 @@ namespace Vanara.PInvoke
/// <param name="hWnd">A handle to the window that has the client area to check.</param>
/// <param name="controlIdentifiers">An array of integers that identify the control identifiers in the client area.</param>
/// <returns>The dimensions of the rectangle.</returns>
// void GetEffectiveClientRect( HWND hWnd, LPRECT lprc, _In_ const INT *lpInfo);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb775674(v=vs.85).aspx
// void GetEffectiveClientRect( HWND hWnd, LPRECT lprc, _In_ const INT *lpInfo); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775674(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775674")]
public static RECT GetEffectiveClientRect(HandleRef hWnd, int[] controlIdentifiers)
{
@ -696,50 +753,51 @@ namespace Vanara.PInvoke
/// the same process, <c>GetMUILanguage</c> returns the language-neutral LANGID, <c>MAKELANGID</c>(LANG_NEUTRAL, SUBLANG_NEUTRAL).
/// </para>
/// </returns>
// LANGID GetMUILanguage(void);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb775676(v=vs.85).aspx
// LANGID GetMUILanguage(void); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775676(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775676")]
public static extern ushort GetMUILanguage();
/// <summary>Defines the prototype for the callback function used by <c>RemoveWindowSubclass</c> and <c>SetWindowSubclass</c>.</summary>
/// <summary>Retrieves the reference data for the specified window subclass callback.</summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>The handle to the subclassed window.</para>
/// <para>The handle of the window being subclassed.</para>
/// </param>
/// <param name="uMsg">
/// <para>Type: <c>UINT</c></para>
/// <para>The message being passed.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <c>WPARAM</c></para>
/// <para>Additional message information. The contents of this parameter depend on the value of uMsg.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <c>LPARAM</c></para>
/// <para>Additional message information. The contents of this parameter depend on the value of uMsg.</para>
/// <param name="pfnSubclass">
/// <para>Type: <c><c>SUBCLASSPROC</c></c></para>
/// <para>A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback.</para>
/// </param>
/// <param name="uIdSubclass">
/// <para>Type: <c>UINT_PTR</c></para>
/// <para>The subclass ID.</para>
/// <para>
/// <c>UINT_PTR</c> subclass ID. This ID and the callback pointer uniquely identify this subclass callback. Note: On 64-bit versions of Windows this is a
/// 64-bit value.
/// </para>
/// </param>
/// <param name="dwRefData">
/// <para>Type: <c>DWORD_PTR</c></para>
/// <para>The reference data provided to the <c>SetWindowSubclass</c> function. This can be used to associate the subclass instance with a "this" pointer.</para>
/// <param name="pdwRefData">
/// <para>Type: <c>DWORD_PTR*</c></para>
/// <para>A pointer to a <c>DWORD</c> which will return the reference data. Note: On 64-bit versions of Windows, pointers are 64-bit values.</para>
/// </param>
/// <returns>
/// <para>Type: <c>LRESULT</c></para>
/// <para>The return value is the result of the message processing and depends on the message sent.</para>
/// <para>Type: <c>BOOL</c></para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>TRUE</term>
/// <term>The subclass callback was successfully installed.</term>
/// </item>
/// <item>
/// <term>FALSE</term>
/// <term>The subclass callback was not installed.</term>
/// </item>
/// </list>
/// </para>
/// </returns>
// typedef LRESULT ( CALLBACK *SUBCLASSPROC)( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb776774(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb776774")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate IntPtr SUBCLASSPROC(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, [MarshalAs(UnmanagedType.SysUInt)] uint uIdSubclass, IntPtr dwRefData);
/// <summary>Retrieves the reference data for the specified window subclass callback.</summary><param name="hWnd"><para>Type: <c>HWND</c></para><para>The handle of the window being subclassed.</para></param><param name="pfnSubclass"><para>Type: <c><c>SUBCLASSPROC</c></c></para><para>A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback.</para></param><param name="uIdSubclass"><para>Type: <c>UINT_PTR</c></para><para><c>UINT_PTR</c> subclass ID. This ID and the callback pointer uniquely identify this subclass callback. Note: On 64-bit versions of Windows this is a 64-bit value.</para></param><param name="pdwRefData"><para>Type: <c>DWORD_PTR*</c></para><para>A pointer to a <c>DWORD</c> which will return the reference data. Note: On 64-bit versions of Windows, pointers are 64-bit values.</para></param><returns><para>Type: <c>BOOL</c></para><para><list type="table"><listheader><term>Return code</term><term>Description</term></listheader><item><term>TRUE</term><term>The subclass callback was successfully installed.</term></item><item><term>FALSE</term><term>The subclass callback was not installed.</term></item></list></para></returns>
// BOOL GetWindowSubclass( _In_ HWND hWnd, _In_ SUBCLASSPROC pfnSubclass, _In_ UINT_PTR uIdSubclass, _Out_ DWORD_PTR *pdwRefData);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb776430(v=vs.85).aspx
// BOOL GetWindowSubclass( _In_ HWND hWnd, _In_ SUBCLASSPROC pfnSubclass, _In_ UINT_PTR uIdSubclass, _Out_ DWORD_PTR *pdwRefData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776430(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb776430")]
[return: MarshalAs(UnmanagedType.Bool)]
@ -775,8 +833,7 @@ namespace Vanara.PInvoke
/// <para>The language identifier of the language to be used by the common controls.</para>
/// </param>
/// <returns>None</returns>
// VOID InitMUILanguage( LANGID uiLang);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb775699(v=vs.85).aspx
// VOID InitMUILanguage( LANGID uiLang); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775699(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775699")]
public static extern void InitMUILanguage(ushort uiLang);
@ -833,69 +890,211 @@ namespace Vanara.PInvoke
/// </list>
/// </para>
/// </returns>
// HRESULT LoadIconMetric( _In_ HINSTANCE hinst, _In_ PCWSTR pszName, _In_ int lims, _Out_ HICON *phico);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb775701(v=vs.85).aspx
// HRESULT LoadIconMetric( _In_ HINSTANCE hinst, _In_ PCWSTR pszName, _In_ int lims, _Out_ HICON *phico); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775701(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775701")]
public static extern HRESULT LoadIconMetric(SafeLibraryHandle hinst, string pszName, LI_METRIC lims, out IntPtr phico);
/// <summary>The desired metric.</summary>
public enum LI_METRIC
{
/// <summary>Corresponds to SM_CXSMICON, the recommended pixel width of a small icon.</summary>
LIM_SMALL,
/// <summary>Corresponds toSM_CXICON, the default pixel width of an icon.</summary>
LIM_LARGE,
}
/// <summary>Loads an icon. If the icon is not a standard size, this function scales down a larger image instead of scaling up a smaller image.</summary><param name="hinst"><para>Type: <c><c>HINSTANCE</c></c></para><para>A handle to the module of either a DLL or executable (.exe) file that contains the icon to be loaded. For more information, see <c>GetModuleHandle</c>.</para><para>To load a predefined icon or a standalone icon file, set this parameter to <c>NULL</c>.</para></param><param name="pszName"><para>Type: <c><c>PCWSTR</c></c></para><para>A pointer to a null-terminated, Unicode buffer that contains location information about the icon to load.</para><para>If hinst is non-<c>NULL</c>, pszName specifies the icon resource either by name or ordinal. This ordinal must be packaged by using the <c>MAKEINTRESOURCE</c> macro.</para><para>If hinst is <c>NULL</c>, pszName specifies either the name of a standalone icon (.ico) file or the identifier of a predefined icon to load. The following identifiers are recognized. To pass these constants to the <c>LoadIconWithScaleDown</c> function, use the <c>MAKEINTRESOURCE</c> macro. For example, to load the IDI_ERROR icon, pass as the pszName parameter and <c>NULL</c> as the hinst parameter.</para><para><list type="table"><listheader><term>Value</term><term>Meaning</term></listheader><item><term>IDI_APPLICATION</term><term>Default application icon.</term></item><item><term>IDI_ASTERISK</term><term>Same as IDI_INFORMATION.</term></item><item><term>IDI_ERROR</term><term>Hand-shaped icon.</term></item><item><term>IDI_EXCLAMATION</term><term>Same as IDI_WARNING.</term></item><item><term>IDI_HAND</term><term>Same as IDI_ERROR. </term></item><item><term>IDI_INFORMATION</term><term>Asterisk icon.</term></item><item><term>IDI_QUESTION</term><term>Question mark icon.</term></item><item><term>IDI_WARNING</term><term>Exclamation point icon.</term></item><item><term>IDI_WINLOGO</term><term>Windows logo icon. </term></item><item><term>IDI_SHIELD</term><term>Security Shield icon.</term></item></list></para></param><param name="cx"><para>Type: <c>int</c></para><para>The desired width, in pixels, of the icon.</para></param><param name="cy"><para>Type: <c>int</c></para><para>The desired height, in pixels, of the icon.</para></param><param name="phico"><para>Type: <c><c>HICON</c>*</c></para><para>When this function returns, contains a pointer to the handle of the loaded icon.</para></param><returns><para>Type: <c><c>HRESULT</c></c></para><para>Returns S_OK if successful, or an error value otherwise, including the following:</para><para><list type="table"><listheader><term>Return code</term><term>Description</term></listheader><item><term>E_INVALIDARG</term><term>The contents of the buffer pointed to by pszName do not fit any of the expected interpretations.</term></item></list></para></returns>
// HRESULT WINAPI LoadIconWithScaleDown( _In_ HINSTANCE hinst, _In_ PCWSTR pszName, _In_ int cx, _In_ int cy, _Out_ HICON *phico);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb775703(v=vs.85).aspx
/// <summary>Loads an icon. If the icon is not a standard size, this function scales down a larger image instead of scaling up a smaller image.</summary>
/// <param name="hinst">
/// <para>Type: <c><c>HINSTANCE</c></c></para>
/// <para>A handle to the module of either a DLL or executable (.exe) file that contains the icon to be loaded. For more information, see <c>GetModuleHandle</c>.</para>
/// <para>To load a predefined icon or a standalone icon file, set this parameter to <c>NULL</c>.</para>
/// </param>
/// <param name="pszName">
/// <para>Type: <c><c>PCWSTR</c></c></para>
/// <para>A pointer to a null-terminated, Unicode buffer that contains location information about the icon to load.</para>
/// <para>
/// If hinst is non- <c>NULL</c>, pszName specifies the icon resource either by name or ordinal. This ordinal must be packaged by using the
/// <c>MAKEINTRESOURCE</c> macro.
/// </para>
/// <para>
/// If hinst is <c>NULL</c>, pszName specifies either the name of a standalone icon (.ico) file or the identifier of a predefined icon to load. The
/// following identifiers are recognized. To pass these constants to the <c>LoadIconWithScaleDown</c> function, use the <c>MAKEINTRESOURCE</c> macro. For
/// example, to load the IDI_ERROR icon, pass as the pszName parameter and <c>NULL</c> as the hinst parameter.
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>IDI_APPLICATION</term>
/// <term>Default application icon.</term>
/// </item>
/// <item>
/// <term>IDI_ASTERISK</term>
/// <term>Same as IDI_INFORMATION.</term>
/// </item>
/// <item>
/// <term>IDI_ERROR</term>
/// <term>Hand-shaped icon.</term>
/// </item>
/// <item>
/// <term>IDI_EXCLAMATION</term>
/// <term>Same as IDI_WARNING.</term>
/// </item>
/// <item>
/// <term>IDI_HAND</term>
/// <term>Same as IDI_ERROR.</term>
/// </item>
/// <item>
/// <term>IDI_INFORMATION</term>
/// <term>Asterisk icon.</term>
/// </item>
/// <item>
/// <term>IDI_QUESTION</term>
/// <term>Question mark icon.</term>
/// </item>
/// <item>
/// <term>IDI_WARNING</term>
/// <term>Exclamation point icon.</term>
/// </item>
/// <item>
/// <term>IDI_WINLOGO</term>
/// <term>Windows logo icon.</term>
/// </item>
/// <item>
/// <term>IDI_SHIELD</term>
/// <term>Security Shield icon.</term>
/// </item>
/// </list>
/// </para>
/// </param>
/// <param name="cx">
/// <para>Type: <c>int</c></para>
/// <para>The desired width, in pixels, of the icon.</para>
/// </param>
/// <param name="cy">
/// <para>Type: <c>int</c></para>
/// <para>The desired height, in pixels, of the icon.</para>
/// </param>
/// <param name="phico">
/// <para>Type: <c><c>HICON</c>*</c></para>
/// <para>When this function returns, contains a pointer to the handle of the loaded icon.</para>
/// </param>
/// <returns>
/// <para>Type: <c><c>HRESULT</c></c></para>
/// <para>Returns S_OK if successful, or an error value otherwise, including the following:</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>E_INVALIDARG</term>
/// <term>The contents of the buffer pointed to by pszName do not fit any of the expected interpretations.</term>
/// </item>
/// </list>
/// </para>
/// </returns>
// HRESULT WINAPI LoadIconWithScaleDown( _In_ HINSTANCE hinst, _In_ PCWSTR pszName, _In_ int cx, _In_ int cy, _Out_ HICON *phico); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775703(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775703")]
public static extern HRESULT LoadIconWithScaleDown(SafeLibraryHandle hinst, string pszName, int cx, int cy, out IntPtr phico);
/// <summary>Removes a subclass callback from a window.</summary><param name="hWnd"><para>Type: <c>HWND</c></para><para>The handle of the window being subclassed.</para></param><param name="pfnSubclass"><para>Type: <c><c>SUBCLASSPROC</c></c></para><para>A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. For the callback function prototype, see <c>SUBCLASSPROC</c>.</para></param><param name="uIdSubclass"><para>Type: <c>UINT_PTR</c></para><para>The <c>UINT_PTR</c> subclass ID. This ID and the callback pointer uniquely identify this subclass callback. Note: On 64-bit versions of Windows this is a 64-bit value.</para></param><returns><para>Type: <c>BOOL</c></para><para><c>TRUE</c> if the subclass callback was successfully removed; otherwise, <c>FALSE</c>.</para></returns>
// BOOL RemoveWindowSubclass( _In_ HWND hWnd, _In_ SUBCLASSPROC pfnSubclass, _In_ UINT_PTR uIdSubclass);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb762094(v=vs.85).aspx
/// <summary>Removes a subclass callback from a window.</summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>The handle of the window being subclassed.</para>
/// </param>
/// <param name="pfnSubclass">
/// <para>Type: <c><c>SUBCLASSPROC</c></c></para>
/// <para>
/// A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. For the callback function prototype, see <c>SUBCLASSPROC</c>.
/// </para>
/// </param>
/// <param name="uIdSubclass">
/// <para>Type: <c>UINT_PTR</c></para>
/// <para>
/// The <c>UINT_PTR</c> subclass ID. This ID and the callback pointer uniquely identify this subclass callback. Note: On 64-bit versions of Windows this
/// is a 64-bit value.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para><c>TRUE</c> if the subclass callback was successfully removed; otherwise, <c>FALSE</c>.</para>
/// </returns>
// BOOL RemoveWindowSubclass( _In_ HWND hWnd, _In_ SUBCLASSPROC pfnSubclass, _In_ UINT_PTR uIdSubclass); https://msdn.microsoft.com/en-us/library/windows/desktop/bb762094(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb762094")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RemoveWindowSubclass(HandleRef hWnd, SUBCLASSPROC pfnSubclass, [MarshalAs(UnmanagedType.SysUInt)] uint uIdSubclass);
/// <summary>Installs or updates a window subclass callback.</summary><param name="hWnd"><para>Type: <c>HWND</c></para><para>The handle of the window being subclassed.</para></param><param name="pfnSubclass"><para>Type: <c><c>SUBCLASSPROC</c></c></para><para>A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. For the callback function prototype, see <c>SUBCLASSPROC</c>.</para></param><param name="uIdSubclass"><para>Type: <c>UINT_PTR</c></para><para>The subclass ID. This ID together with the subclass procedure uniquely identify a subclass. To remove a subclass, pass the subclass procedure and this value to the <c>RemoveWindowSubclass</c> function. This value is passed to the subclass procedure in the uIdSubclass parameter.</para></param><param name="dwRefData"><para>Type: <c>DWORD_PTR</c></para><para><c>DWORD_PTR</c> to reference data. The meaning of this value is determined by the calling application. This value is passed to the subclass procedure in the dwRefData parameter. A different dwRefData is associated with each combination of window handle, subclass procedure and uIdSubclass.</para></param><returns><para>Type: <c>BOOL</c></para><para><c>TRUE</c> if the subclass callback was successfully installed; otherwise, <c>FALSE</c>.</para></returns>
// BOOL SetWindowSubclass( _In_ HWND hWnd, _In_ SUBCLASSPROC pfnSubclass, _In_ UINT_PTR uIdSubclass, _In_ DWORD_PTR dwRefData);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb762102(v=vs.85).aspx
/// <summary>Installs or updates a window subclass callback.</summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>The handle of the window being subclassed.</para>
/// </param>
/// <param name="pfnSubclass">
/// <para>Type: <c><c>SUBCLASSPROC</c></c></para>
/// <para>
/// A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. For the callback function prototype, see <c>SUBCLASSPROC</c>.
/// </para>
/// </param>
/// <param name="uIdSubclass">
/// <para>Type: <c>UINT_PTR</c></para>
/// <para>
/// The subclass ID. This ID together with the subclass procedure uniquely identify a subclass. To remove a subclass, pass the subclass procedure and
/// this value to the <c>RemoveWindowSubclass</c> function. This value is passed to the subclass procedure in the uIdSubclass parameter.
/// </para>
/// </param>
/// <param name="dwRefData">
/// <para>Type: <c>DWORD_PTR</c></para>
/// <para>
/// <c>DWORD_PTR</c> to reference data. The meaning of this value is determined by the calling application. This value is passed to the subclass
/// procedure in the dwRefData parameter. A different dwRefData is associated with each combination of window handle, subclass procedure and uIdSubclass.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para><c>TRUE</c> if the subclass callback was successfully installed; otherwise, <c>FALSE</c>.</para>
/// </returns>
// BOOL SetWindowSubclass( _In_ HWND hWnd, _In_ SUBCLASSPROC pfnSubclass, _In_ UINT_PTR uIdSubclass, _In_ DWORD_PTR dwRefData); https://msdn.microsoft.com/en-us/library/windows/desktop/bb762102(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb762102")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowSubclass(HandleRef hWnd, SUBCLASSPROC pfnSubclass, [MarshalAs(UnmanagedType.SysUInt)] uint uIdSubclass, IntPtr dwRefData);
/// <summary><para>[<c>ShowHideMenuCtl</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]</para><para>Sets or removes the specified menu item&#39;s check mark attribute and shows or hides the corresponding control. The function adds a check mark to the specified menu item if it does not have one and then displays the corresponding control. If the menu item already has a check mark, the function removes the check mark and hides the corresponding control.</para></summary><param name="hWnd"><para>Type: <c><c>HWND</c></c></para><para>A handle to the window that contains the menu and controls.</para></param><param name="uFlags"><para>Type: <c><c>UINT_PTR</c></c></para><para>The identifier of the menu item to receive or lose a check mark.</para></param><param name="lpInfo"><para>Type: <c><c>LPINT</c></c></para><para>A pointer to an array that contains pairs of values. The second value in the first pair must be the handle to the application&#39;s main menu. Each subsequent pair consists of a menu item identifier and a control window identifier. The function searches the array for a value that matches uFlags and, if the value is found, checks or unchecks the menu item and shows or hides the corresponding control.</para></param><returns><para>Type: <c><c>BOOL</c></c></para><para>Returns nonzero if successful, or zero otherwise.</para></returns>
// BOOL ShowHideMenuCtl( HWND hWnd, UINT_PTR uFlags, LPINT lpInfo);
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb775731(v=vs.85).aspx
/// <summary>
/// <para>
/// [ <c>ShowHideMenuCtl</c> is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in
/// subsequent versions.]
/// </para>
/// <para>
/// Sets or removes the specified menu item's check mark attribute and shows or hides the corresponding control. The function adds a check mark to the
/// specified menu item if it does not have one and then displays the corresponding control. If the menu item already has a check mark, the function
/// removes the check mark and hides the corresponding control.
/// </para>
/// </summary>
/// <param name="hWnd">
/// <para>Type: <c><c>HWND</c></c></para>
/// <para>A handle to the window that contains the menu and controls.</para>
/// </param>
/// <param name="uFlags">
/// <para>Type: <c><c>UINT_PTR</c></c></para>
/// <para>The identifier of the menu item to receive or lose a check mark.</para>
/// </param>
/// <param name="lpInfo">
/// <para>Type: <c><c>LPINT</c></c></para>
/// <para>
/// A pointer to an array that contains pairs of values. The second value in the first pair must be the handle to the application's main menu. Each
/// subsequent pair consists of a menu item identifier and a control window identifier. The function searches the array for a value that matches uFlags
/// and, if the value is found, checks or unchecks the menu item and shows or hides the corresponding control.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c><c>BOOL</c></c></para>
/// <para>Returns nonzero if successful, or zero otherwise.</para>
/// </returns>
// BOOL ShowHideMenuCtl( HWND hWnd, UINT_PTR uFlags, LPINT lpInfo); https://msdn.microsoft.com/en-us/library/windows/desktop/bb775731(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Commctrl.h", MSDNShortId = "bb775731")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShowHideMenuCtl(HandleRef hWnd, [MarshalAs(UnmanagedType.SysUInt)] uint uFlags, [In, MarshalAs(UnmanagedType.LPArray)] int[] lpInfo);
/// <summary>Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time. This function calls TrackMouseEvent if it exists, otherwise it emulates it.</summary>
/// <param name="lpEventTrack">
/// <para>Type: <c>LPTRACKMOUSEEVENT</c></para>
/// <para>A pointer to a <c>TRACKMOUSEEVENT</c> structure that contains tracking information.</para>
/// </param>
/// <returns>
/// <para>Type: <c>BOOL</c></para>
/// <para>If the function succeeds, the return value is nonzero .</para>
/// <para>If the function fails, return value is zero. To get extended error information, call <c>GetLastError</c>.</para>
/// </returns>
// BOOL WINAPI TrackMouseEvent( _Inout_ LPTRACKMOUSEEVENT lpEventTrack);
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms646266(v=vs.85).aspx
[DllImport(Lib.ComCtl32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("CommCtrl.h", MSDNShortId = "ms646266")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool _TrackMouseEvent(ref User32.TRACKMOUSEEVENT lpEventTrack);
/// <summary>Contains information for the drawing of buttons in a toolbar or rebar.</summary>
[StructLayout(LayoutKind.Sequential)]
public struct COLORSCHEME
@ -911,8 +1110,8 @@ namespace Vanara.PInvoke
}
/// <summary>
/// Carries information used to load common control classes from the dynamic-link library (DLL). This structure is used with the <see
/// cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/> function.
/// Carries information used to load common control classes from the dynamic-link library (DLL). This structure is used with the
/// <see cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/> function.
/// </summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775507")]
[StructLayout(LayoutKind.Sequential)]
@ -921,9 +1120,7 @@ namespace Vanara.PInvoke
/// <summary>The size of the structure, in bytes.</summary>
public int dwSize;
/// <summary>
/// The set of bit flags that indicate which common control classes will be loaded from the DLL when calling <see cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/>.
/// </summary>
/// <summary>The set of bit flags that indicate which common control classes will be loaded from the DLL when calling <see cref="InitCommonControlsEx(ref INITCOMMONCONTROLSEX)"/>.</summary>
public CommonControlClass dwICC;
/// <summary>Initializes a new instance of the <see cref="INITCOMMONCONTROLSEX"/> class and sets the dwICC field.</summary>
@ -935,6 +1132,34 @@ namespace Vanara.PInvoke
}
}
/// <summary>Contains information used with character notification messages.</summary>
// typedef struct tagNMCHAR { NMHDR hdr; UINT ch; DWORD dwItemPrev; DWORD dwItemNext;} NMCHAR, *LPNMCHAR; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775508(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775508")]
[StructLayout(LayoutKind.Sequential)]
public struct NMCHAR
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>The character that is being processed.</para>
/// </summary>
public uint ch;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>A 32-bit value that is determined by the control that is sending the notification.</para>
/// </summary>
public uint dwItemPrev;
/// <summary>
/// <para>Type: <c><c>DWORD</c></c></para>
/// <para>A 32-bit value that is determined by the control that is sending the notification.</para>
/// </summary>
public uint dwItemNext;
}
/// <summary>Contains information specific to an NM_CUSTOMDRAW notification code.</summary>
[PInvokeData("Commctrl.h", MSDNShortId = "bb775483")]
[StructLayout(LayoutKind.Sequential)]
@ -985,5 +1210,168 @@ namespace Vanara.PInvoke
/// <summary>A RECT structure that describes the rectangle that contains the drop-down arrow.</summary>
public RECT rcSplit;
}
/// <summary>Contains information used with custom text notification.</summary>
// typedef struct tagNMCUSTOMTEXT { NMHDR hdr; HDC hDC; LPCWSTR lpString; int nCount; LPRECT lpRect; UINT uFormat; BOOL fLink;} NMCUSTOMTEXT,
// *LPNMCUSTOMTEXT; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775512(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775512")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NMCUSTOMTEXT
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>HDC</c></c></para>
/// <para>The device context to draw to.</para>
/// </summary>
public IntPtr hDC;
/// <summary>
/// <para>Type: <c><c>LPCWSTR</c></c></para>
/// <para>The string to draw.</para>
/// </summary>
public string lpString;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>Length of lpString.</para>
/// </summary>
public int nCount;
/// <summary>
/// <para>Type: <c>LPRECT</c></para>
/// <para>The rect to draw in.</para>
/// </summary>
public IntPtr lpRect;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>
/// One or more of the DT_* flags. For more information, see the description of the uFormat parameter of the <c>DrawText</c> function. This may be <c>NULL</c>.
/// </para>
/// </summary>
public uint uFormat;
/// <summary>
/// <para>Type: <c><c>BOOL</c></c></para>
/// <para>Whether the text is a link.</para>
/// </summary>
[MarshalAs(UnmanagedType.Bool)]
public bool fLink;
}
/// <summary>Contains information used with key notification messages.</summary>
// typedef struct tagNMKEY { NMHDR hdr; UINT nVKey; UINT uFlags;} NMKEY, *LPNMKEY; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775516(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775516")]
[StructLayout(LayoutKind.Sequential)]
public struct NMKEY
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>A virtual key code of the key that caused the event.</para>
/// </summary>
public uint nVKey;
/// <summary>
/// <para>Type: <c><c>UINT</c></c></para>
/// <para>
/// Flags associated with the key. These are the same flags that are passed in the high word of the lParam parameter of the <c>WM_KEYDOWN</c> message.
/// </para>
/// </summary>
public uint uFlags;
}
/// <summary>Contains information used with mouse notification messages.</summary>
// typedef struct tagNMMOUSE { NMHDR hdr; DWORD_PTR dwItemSpec; DWORD_PTR dwItemData; POINT pt; LPARAM dwHitInfo;} NMMOUSE, *LPNMMOUSE; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775518(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775518")]
[StructLayout(LayoutKind.Sequential)]
public struct NMMOUSE
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>DWORD_PTR</c></c></para>
/// <para>A control-specific item identifier.</para>
/// </summary>
public IntPtr dwItemSpec;
/// <summary>
/// <para>Type: <c><c>DWORD_PTR</c></c></para>
/// <para>A control-specific item data.</para>
/// </summary>
public IntPtr dwItemData;
/// <summary>
/// <para>Type: <c><c>POINT</c></c></para>
/// <para>A <c>POINT</c> structure that contains the client coordinates of the mouse when the click occurred.</para>
/// </summary>
public System.Drawing.Point pt;
/// <summary>
/// <para>Type: <c><c>LPARAM</c></c></para>
/// <para>Carries information about where on the item or control the cursor is pointing.</para>
/// </summary>
public IntPtr dwHitInfo;
}
/// <summary>Contains information used with the TBN_GETOBJECT, TCN_GETOBJECT, and PSN_GETOBJECT notification codes.</summary>
// typedef struct tagNMOBJECTNOTIFY { NMHDR hdr; int iItem; IID *piid; IUnknown *pObject; HRESULT hResult;} NMOBJECTNOTIFY, *LPNMOBJECTNOTIFY; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775520(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775520")]
[StructLayout(LayoutKind.Sequential)]
public struct NMOBJECTNOTIFY
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// A control-specific item identifier. This value will comply to item identification standards for the control sending the notification. However,
/// this member is not used with the PSN_GETOBJECT notification code.
/// </para>
/// </summary>
public int iItem;
/// <summary>
/// <para>Type: <c>IID*</c></para>
/// <para>A pointer to an interface identifier of the requested object.</para>
/// </summary>
public IntPtr piid;
/// <summary>
/// <para>Type: <c><c>IUnknown</c>*</c></para>
/// <para>
/// A pointer to an object provided by the window processing the notification code. The application processing the notification code sets this member.
/// </para>
/// </summary>
public IntPtr pObject;
/// <summary>
/// <para>Type: <c><c>HRESULT</c></c></para>
/// <para>COM success or failure flags. The application processing the notification code sets this member.</para>
/// </summary>
public HRESULT hResult;
/// <summary>Undocumented</summary>
public uint dwFlags;
}
/// <summary>Contains information used with NM_TOOLTIPSCREATED notification codes.</summary>
// typedef struct tagNMTOOLTIPSCREATED { NMHDR hdr; HWND hwndToolTips;} NMTOOLTIPSCREATED, *LPNMTOOLTIPSCREATED; https://msdn.microsoft.com/en-us/library/windows/desktop/bb775522(v=vs.85).aspx
[PInvokeData("Commctrl.h", MSDNShortId = "bb775522")]
[StructLayout(LayoutKind.Sequential)]
public struct NMTOOLTIPSCREATED
{
/// <summary>
/// <para>Type: <c><c>NMHDR</c></c></para>
/// <para>An <c>NMHDR</c> structure that contains additional information about this notification.</para>
/// </summary>
public NMHDR hdr;
/// <summary>
/// <para>Type: <c><c>HWND</c></c></para>
/// <para>The window handle to the tooltip control created.</para>
/// </summary>
public IntPtr hwndToolTips;
}
}
}