diff --git a/src/Common/src/Interop/ComCtl32/Interop.NMTOOLBARW.cs b/src/Common/src/Interop/ComCtl32/Interop.NMTOOLBARW.cs new file mode 100644 index 00000000000..d5980c781ab --- /dev/null +++ b/src/Common/src/Interop/ComCtl32/Interop.NMTOOLBARW.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class ComCtl32 + { + public unsafe struct NMTOOLBARW + { + public User32.NMHDR hdr; + public int iItem; + public TBBUTTON tbButton; + public int cchText; + public char* pszText; + public RECT rcButton; + } + } +} diff --git a/src/Common/src/Interop/ComCtl32/Interop.TB.cs b/src/Common/src/Interop/ComCtl32/Interop.TB.cs new file mode 100644 index 00000000000..d468b92238f --- /dev/null +++ b/src/Common/src/Interop/ComCtl32/Interop.TB.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static partial class Interop +{ + internal static partial class ComCtl32 + { + public enum TB : int + { + FIRST = 0x1000, + GETBUTTONINFOW = FIRST + 63, + SETBUTTONINFOW = FIRST + 64, + INSERTBUTTONW = FIRST + 67, + } + } +} diff --git a/src/Common/src/Interop/ComCtl32/Interop.TBBUTTON.cs b/src/Common/src/Interop/ComCtl32/Interop.TBBUTTON.cs new file mode 100644 index 00000000000..490042e79b0 --- /dev/null +++ b/src/Common/src/Interop/ComCtl32/Interop.TBBUTTON.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class ComCtl32 + { + public struct TBBUTTON + { + public int iBitmap; + public int idCommand; + public TBSTATE fsState; + public byte fsStyle; + public byte bReserved0; + public byte bReserved1; + public IntPtr dwData; + public IntPtr iString; + } + } +} diff --git a/src/Common/src/Interop/ComCtl32/Interop.TBBUTTONINFOW.cs b/src/Common/src/Interop/ComCtl32/Interop.TBBUTTONINFOW.cs new file mode 100644 index 00000000000..0b02f5e406c --- /dev/null +++ b/src/Common/src/Interop/ComCtl32/Interop.TBBUTTONINFOW.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class ComCtl32 + { + public struct TBBUTTONINFOW + { + public uint cbSize; + public TBIF dwMask; + public int idCommand; + public int iImage; + public TBSTATE fsState; + public byte fsStyle; + public ushort cx; + public IntPtr lParam; + public IntPtr pszText; + public int cchTest; + } + } +} diff --git a/src/Common/src/Interop/ComCtl32/Interop.TBIF.cs b/src/Common/src/Interop/ComCtl32/Interop.TBIF.cs new file mode 100644 index 00000000000..66d780b6f1c --- /dev/null +++ b/src/Common/src/Interop/ComCtl32/Interop.TBIF.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class ComCtl32 + { + [Flags] + public enum TBIF : uint + { + IMAGE = 0x00000001, + TEXT = 0x00000002, + STATE = 0x00000004, + STYLE = 0x00000008, + LPARAM = 0x00000010, + COMMAND = 0x00000020, + SIZE = 0x00000040, + BYINDEX = 0x80000000, + } + } +} diff --git a/src/Common/src/Interop/ComCtl32/Interop.TBSTATE.cs b/src/Common/src/Interop/ComCtl32/Interop.TBSTATE.cs new file mode 100644 index 00000000000..13bff64c4b8 --- /dev/null +++ b/src/Common/src/Interop/ComCtl32/Interop.TBSTATE.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class ComCtl32 + { + [Flags] + public enum TBSTATE : byte + { + CHECKED = 0x01, + PRESSED = 0x02, + ENABLED = 0x04, + HIDDEN = 0x08, + INDETERMINATE = 0x10, + WRAP = 0x20, + ELLIPSES = 0x40, + MARKED = 0x80, + } + } +} diff --git a/src/Common/src/Interop/ComCtl32/Interop.TBSTYLE.cs b/src/Common/src/Interop/ComCtl32/Interop.TBSTYLE.cs new file mode 100644 index 00000000000..d8f6f48af5f --- /dev/null +++ b/src/Common/src/Interop/ComCtl32/Interop.TBSTYLE.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class ComCtl32 + { + [Flags] + public enum TBSTYLE : int + { + BUTTON = 0x0000, + SEP = 0x0001, + CHECK = 0x0002, + GROUP = 0x0004, + CHECKGROUP = GROUP, + DROPDOWN = 0x0008, + AUTOSIZE = 0x0010, + NOPREFIX = 0x0020, + TOOLTIPS = 0x0100, + WRAPABLE = 0x0200, + ALTDRAG = 0x0400, + FLAT = 0x0800, + LIST = 0x1000, + CUSTOMERASE = 0x2000, + REGISTERDROP = 0x4000, + TRANSPARENT = 0x800, + EX_DRAWDDARROWS = 0x00000001, + EX_MIXEDBUTTONS = 0x00000008, + EX_HIDECLIPPEDBUTTONS = 0x00000010, + EX_MULTICOLUMN = 0x00000002, + EX_VERTICAL = 0x00000004, + EX_DOUBLEBUFFER = 0x00000080, + } + } +} diff --git a/src/Common/src/NativeMethods.cs b/src/Common/src/NativeMethods.cs index 480d3277691..b7f0794b5b5 100644 --- a/src/Common/src/NativeMethods.cs +++ b/src/Common/src/NativeMethods.cs @@ -889,23 +889,10 @@ public const int TPM_RIGHTALIGN = 0x0008, TPM_VERTICAL = 0x0040, TV_FIRST = 0x1100, - TBSTATE_CHECKED = 0x01, - TBSTATE_ENABLED = 0x04, - TBSTATE_HIDDEN = 0x08, - TBSTATE_INDETERMINATE = 0x10, - TBSTYLE_BUTTON = 0x00, - TBSTYLE_SEP = 0x01, - TBSTYLE_CHECK = 0x02, - TBSTYLE_DROPDOWN = 0x08, - TBSTYLE_TOOLTIPS = 0x0100, - TBSTYLE_FLAT = 0x0800, - TBSTYLE_LIST = 0x1000, - TBSTYLE_EX_DRAWDDARROWS = 0x00000001, TB_ENABLEBUTTON = (0x0400 + 1), TB_ISBUTTONCHECKED = (0x0400 + 10), TB_ISBUTTONINDETERMINATE = (0x0400 + 13), TB_ADDBUTTONS = (0x0400 + 68), - TB_INSERTBUTTON = (0x0400 + 67), TB_DELETEBUTTON = (0x0400 + 22), TB_GETBUTTON = (0x0400 + 23), TB_SAVERESTORE = (0x0400 + 76), @@ -918,18 +905,10 @@ public const int TB_SETIMAGELIST = (0x0400 + 48), TB_GETRECT = (0x0400 + 51), TB_GETBUTTONSIZE = (0x0400 + 58), - TB_GETBUTTONINFO = (0x0400 + 63), - TB_SETBUTTONINFO = (0x0400 + 64), TB_SETEXTENDEDSTYLE = (0x0400 + 84), TB_MAPACCELERATOR = (0x0400 + 90), TB_GETTOOLTIPS = (0x0400 + 35), TB_SETTOOLTIPS = (0x0400 + 36), - TBIF_IMAGE = 0x00000001, - TBIF_TEXT = 0x00000002, - TBIF_STATE = 0x00000004, - TBIF_STYLE = 0x00000008, - TBIF_COMMAND = 0x00000020, - TBIF_SIZE = 0x00000040, TBN_GETBUTTONINFO = ((0 - 700) - 20), TBN_QUERYINSERT = ((0 - 700) - 6), TBN_DROPDOWN = ((0 - 700) - 10), @@ -1058,7 +1037,6 @@ public const int TCM_SETTOOLTIPS = (0x1300 + 46), TCN_SELCHANGE = ((0 - 550) - 1), TCN_SELCHANGING = ((0 - 550) - 2), - TBSTYLE_WRAPPABLE = 0x0200, TVM_SETBKCOLOR = (TV_FIRST + 29), TVM_SETTEXTCOLOR = (TV_FIRST + 30), TYMED_NULL = 0, @@ -2108,29 +2086,6 @@ public struct tagVARDESC public /*NativeMethods.tagVARKIND*/ int varkind; } - [StructLayout(LayoutKind.Sequential)] - public struct NMTOOLBAR - { - public User32.NMHDR hdr; - public int iItem; - public TBBUTTON tbButton; - public int cchText; - public IntPtr pszText; - } - - [StructLayout(LayoutKind.Sequential)] - public struct TBBUTTON - { - public int iBitmap; - public int idCommand; - public byte fsState; - public byte fsStyle; - public byte bReserved0; - public byte bReserved1; - public IntPtr dwData; - public IntPtr iString; - } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public class TOOLTIPTEXT { @@ -2163,21 +2118,6 @@ public class HDITEM2 public IntPtr pvFilter = IntPtr.Zero; } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - public struct TBBUTTONINFO - { - public int cbSize; - public int dwMask; - public int idCommand; - public int iImage; - public byte fsState; - public byte fsStyle; - public short cx; - public IntPtr lParam; - public IntPtr pszText; - public int cchTest; - } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public class TV_HITTESTINFO { diff --git a/src/Common/src/UnsafeNativeMethods.cs b/src/Common/src/UnsafeNativeMethods.cs index ad6024e875a..0bc0e561044 100644 --- a/src/Common/src/UnsafeNativeMethods.cs +++ b/src/Common/src/UnsafeNativeMethods.cs @@ -279,12 +279,6 @@ public static StringBuilder GetModuleFileNameLongPath(HandleRef hModule) [DllImport(ExternDll.User32, CharSet = CharSet.Auto)] public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, StringBuilder lParam); - [DllImport(ExternDll.User32, CharSet = CharSet.Auto)] - public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, ref NativeMethods.TBBUTTON lParam); - - [DllImport(ExternDll.User32, CharSet = CharSet.Auto)] - public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, ref NativeMethods.TBBUTTONINFO lParam); - [DllImport(ExternDll.User32, CharSet = CharSet.Auto)] public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, NativeMethods.TV_HITTESTINFO lParam); diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolBar.cs index 1049133dff5..42f309fbeba 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolBar.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolBar.cs @@ -396,12 +396,12 @@ protected override CreateParams CreateParams if (Wrappable) { - cp.Style |= NativeMethods.TBSTYLE_WRAPPABLE; + cp.Style |= (int)ComCtl32.TBSTYLE.WRAPABLE; } if (ShowToolTips && !DesignMode) { - cp.Style |= NativeMethods.TBSTYLE_TOOLTIPS; + cp.Style |= (int)ComCtl32.TBSTYLE.TOOLTIPS; } cp.ExStyle &= (~NativeMethods.WS_EX_CLIENTEDGE); @@ -421,7 +421,7 @@ protected override CreateParams CreateParams case ToolBarAppearance.Normal: break; case ToolBarAppearance.Flat: - cp.Style |= NativeMethods.TBSTYLE_FLAT; + cp.Style |= (int)ComCtl32.TBSTYLE.FLAT; break; } @@ -430,7 +430,7 @@ protected override CreateParams CreateParams case ToolBarTextAlign.Underneath: break; case ToolBarTextAlign.Right: - cp.Style |= NativeMethods.TBSTYLE_LIST; + cp.Style |= (int)ComCtl32.TBSTYLE.LIST; break; } @@ -1139,11 +1139,10 @@ private void ForceButtonWidths() for (int x = 0; x < buttonCount; x++) { - - NativeMethods.TBBUTTONINFO tbbi = new NativeMethods.TBBUTTONINFO + var tbbi = new ComCtl32.TBBUTTONINFOW { - cbSize = Marshal.SizeOf(), - cx = buttons[x].Width + cbSize = (uint)Marshal.SizeOf(), + cx = (ushort)buttons[x].Width }; if (tbbi.cx > maxWidth) @@ -1151,8 +1150,8 @@ private void ForceButtonWidths() maxWidth = tbbi.cx; } - tbbi.dwMask = NativeMethods.TBIF_SIZE; - UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TB_SETBUTTONINFO, x, ref tbbi); + tbbi.dwMask = ComCtl32.TBIF.SIZE; + User32.SendMessageW(this, (User32.WindowMessage)ComCtl32.TB.SETBUTTONINFOW, (IntPtr)x, ref tbbi); } } } @@ -1210,8 +1209,8 @@ private void InsertButton(int index, ToolBarButton value) Insert(index, value); if (IsHandleCreated) { - NativeMethods.TBBUTTON tbbutton = value.GetTBBUTTON(index); - UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TB_INSERTBUTTON, index, ref tbbutton); + ComCtl32.TBBUTTON tbbutton = value.GetTBBUTTON(index); + User32.SendMessageW(this, (User32.WindowMessage)ComCtl32.TB.INSERTBUTTONW, (IntPtr)index, ref tbbutton); } UpdateButtons(); } @@ -1248,12 +1247,12 @@ internal void InternalSetButton(int index, ToolBarButton value, bool recreate, b if (IsHandleCreated) { - NativeMethods.TBBUTTONINFO tbbi = value.GetTBBUTTONINFO(updateText, index); - UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TB_SETBUTTONINFO, index, ref tbbi); + ComCtl32.TBBUTTONINFOW tbbi = value.GetTBBUTTONINFO(updateText, index); + User32.SendMessageW(this, (User32.WindowMessage)ComCtl32.TB.SETBUTTONINFOW, (IntPtr)index, ref tbbi); - if (tbbi.pszText != IntPtr.Zero) + if (tbbi.pszText != null) { - Marshal.FreeHGlobal(tbbi.pszText); + Marshal.FreeHGlobal((IntPtr)tbbi.pszText); } if (recreate) @@ -1302,13 +1301,13 @@ protected override void OnHandleCreated(EventArgs e) // we have to set the button struct size, because they don't. // - SendMessage(NativeMethods.TB_BUTTONSTRUCTSIZE, Marshal.SizeOf(), 0); + SendMessage(NativeMethods.TB_BUTTONSTRUCTSIZE, Marshal.SizeOf(), 0); // set up some extra goo // if (DropDownArrows) { - SendMessage(NativeMethods.TB_SETEXTENDEDSTYLE, 0, NativeMethods.TBSTYLE_EX_DRAWDDARROWS); + SendMessage(NativeMethods.TB_SETEXTENDEDSTYLE, 0, (int)ComCtl32.TBSTYLE.EX_DRAWDDARROWS); } // if we have an imagelist, add it in now. @@ -1396,15 +1395,13 @@ private void RealizeButtons() } // insert the buttons and set their parent pointers - // - int cb = Marshal.SizeOf(); + int cb = Marshal.SizeOf(); int count = buttonCount; ptbbuttons = Marshal.AllocHGlobal(checked(cb * count)); for (int x = 0; x < count; x++) { - - NativeMethods.TBBUTTON tbbutton = buttons[x].GetTBBUTTON(x); + ComCtl32.TBBUTTON tbbutton = buttons[x].GetTBBUTTON(x); Marshal.StructureToPtr(tbbutton, (IntPtr)(checked((long)ptbbuttons + (cb * x))), true); buttons[x].parent = this; } @@ -1571,11 +1568,11 @@ internal void UpdateButtons() /// The button clicked was a dropdown button. If it has a menu specified, /// show it now. Otherwise, fire an onButtonDropDown event. /// - private void WmNotifyDropDown(ref Message m) + private unsafe void WmNotifyDropDown(ref Message m) { - NativeMethods.NMTOOLBAR nmTB = (NativeMethods.NMTOOLBAR)m.GetLParam(typeof(NativeMethods.NMTOOLBAR)); + ComCtl32.NMTOOLBARW* nmTB = (ComCtl32.NMTOOLBARW*)m.LParam; - ToolBarButton tbb = (ToolBarButton)buttons[nmTB.iItem]; + ToolBarButton tbb = (ToolBarButton)buttons[nmTB->iItem]; if (tbb == null) { throw new InvalidOperationException(SR.ToolBarButtonNotFound); @@ -1589,7 +1586,7 @@ private void WmNotifyDropDown(ref Message m) RECT rc = new RECT(); NativeMethods.TPMPARAMS tpm = new NativeMethods.TPMPARAMS(); - SendMessage(NativeMethods.TB_GETRECT, nmTB.iItem, ref rc); + SendMessage(NativeMethods.TB_GETRECT, nmTB->iItem, ref rc); if ((menu.GetType()).IsAssignableFrom(typeof(ContextMenu))) { @@ -1603,7 +1600,7 @@ private void WmNotifyDropDown(ref Message m) main.ProcessInitMenuPopup(menu.Handle); } - UnsafeNativeMethods.MapWindowPoints(new HandleRef(nmTB.hdr, nmTB.hdr.hwndFrom), NativeMethods.NullHandleRef, ref rc, 2); + UnsafeNativeMethods.MapWindowPoints(new HandleRef(nmTB->hdr, nmTB->hdr.hwndFrom), NativeMethods.NullHandleRef, ref rc, 2); tpm.rcExclude_left = rc.left; tpm.rcExclude_top = rc.top; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ToolBarButton.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ToolBarButton.cs index 07c27b49eb1..644a24de800 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/ToolBarButton.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/ToolBarButton.cs @@ -610,13 +610,13 @@ internal int GetButtonWidth() // Assume that this button is the same width as the parent's ButtonSize's Width int buttonWidth = Parent.ButtonSize.Width; - NativeMethods.TBBUTTONINFO button = new NativeMethods.TBBUTTONINFO + var button = new ComCtl32.TBBUTTONINFOW { - cbSize = Marshal.SizeOf(), - dwMask = NativeMethods.TBIF_SIZE + cbSize = (uint)Marshal.SizeOf(), + dwMask = ComCtl32.TBIF.SIZE }; - int buttonID = (int)UnsafeNativeMethods.SendMessage(new HandleRef(Parent, Parent.Handle), NativeMethods.TB_GETBUTTONINFO, commandId, ref button); + int buttonID = (int)User32.SendMessageW(Parent, (User32.WindowMessage)ComCtl32.TB.GETBUTTONINFOW, (IntPtr)commandId, ref button); if (buttonID != -1) { buttonWidth = button.cx; @@ -642,51 +642,48 @@ private bool GetPushedState() /// /// Returns a TBBUTTON object that represents this ToolBarButton. /// - internal NativeMethods.TBBUTTON GetTBBUTTON(int commandId) + internal ComCtl32.TBBUTTON GetTBBUTTON(int commandId) { - NativeMethods.TBBUTTON button = new NativeMethods.TBBUTTON + // Set up the state of the button + var button = new ComCtl32.TBBUTTON { iBitmap = ImageIndexer.ActualIndex, - - // set up the state of the button - // fsState = 0 }; if (enabled) { - button.fsState |= NativeMethods.TBSTATE_ENABLED; + button.fsState |= ComCtl32.TBSTATE.ENABLED; } if (partialPush && style == ToolBarButtonStyle.ToggleButton) { - button.fsState |= NativeMethods.TBSTATE_INDETERMINATE; + button.fsState |= ComCtl32.TBSTATE.INDETERMINATE; } if (pushed) { - button.fsState |= NativeMethods.TBSTATE_CHECKED; + button.fsState |= ComCtl32.TBSTATE.CHECKED; } if (!visible) { - button.fsState |= NativeMethods.TBSTATE_HIDDEN; + button.fsState |= ComCtl32.TBSTATE.HIDDEN; } // set the button style - // switch (style) { case ToolBarButtonStyle.PushButton: - button.fsStyle = NativeMethods.TBSTYLE_BUTTON; + button.fsStyle = (byte)ComCtl32.TBSTYLE.BUTTON; break; case ToolBarButtonStyle.ToggleButton: - button.fsStyle = NativeMethods.TBSTYLE_CHECK; + button.fsStyle = (byte)ComCtl32.TBSTYLE.CHECK; break; case ToolBarButtonStyle.Separator: - button.fsStyle = NativeMethods.TBSTYLE_SEP; + button.fsStyle = (byte)ComCtl32.TBSTYLE.SEP; break; case ToolBarButtonStyle.DropDownButton: - button.fsStyle = NativeMethods.TBSTYLE_DROPDOWN; + button.fsStyle = (byte)ComCtl32.TBSTYLE.DROPDOWN; break; } @@ -700,15 +697,14 @@ internal NativeMethods.TBBUTTON GetTBBUTTON(int commandId) } /// - /// Returns a TBBUTTONINFO object that represents this ToolBarButton. + /// Returns a TBBUTTONINFOW object that represents this ToolBarButton. /// - internal NativeMethods.TBBUTTONINFO GetTBBUTTONINFO(bool updateText, int newCommandId) + internal ComCtl32.TBBUTTONINFOW GetTBBUTTONINFO(bool updateText, int newCommandId) { - NativeMethods.TBBUTTONINFO button = new NativeMethods.TBBUTTONINFO + var button = new ComCtl32.TBBUTTONINFOW { - cbSize = Marshal.SizeOf(), - dwMask = NativeMethods.TBIF_IMAGE - | NativeMethods.TBIF_STATE | NativeMethods.TBIF_STYLE + cbSize = (uint)Marshal.SizeOf(), + dwMask = ComCtl32.TBIF.IMAGE | ComCtl32.TBIF.STATE | ComCtl32.TBIF.STYLE }; // Older platforms interpret null strings as empty, which forces the button to @@ -716,7 +712,7 @@ internal NativeMethods.TBBUTTONINFO GetTBBUTTONINFO(bool updateText, int newComm // The only workaround is to avoid having comctl update the text. if (updateText) { - button.dwMask |= NativeMethods.TBIF_TEXT; + button.dwMask |= ComCtl32.TBIF.TEXT; } button.iImage = ImageIndexer.ActualIndex; @@ -725,44 +721,42 @@ internal NativeMethods.TBBUTTONINFO GetTBBUTTONINFO(bool updateText, int newComm { commandId = newCommandId; button.idCommand = newCommandId; - button.dwMask |= NativeMethods.TBIF_COMMAND; + button.dwMask |= ComCtl32.TBIF.COMMAND; } // set up the state of the button - // button.fsState = 0; if (enabled) { - button.fsState |= NativeMethods.TBSTATE_ENABLED; + button.fsState |= ComCtl32.TBSTATE.ENABLED; } if (partialPush && style == ToolBarButtonStyle.ToggleButton) { - button.fsState |= NativeMethods.TBSTATE_INDETERMINATE; + button.fsState |= ComCtl32.TBSTATE.INDETERMINATE; } if (pushed) { - button.fsState |= NativeMethods.TBSTATE_CHECKED; + button.fsState |= ComCtl32.TBSTATE.CHECKED; } if (!visible) { - button.fsState |= NativeMethods.TBSTATE_HIDDEN; + button.fsState |= ComCtl32.TBSTATE.HIDDEN; } // set the button style - // switch (style) { case ToolBarButtonStyle.PushButton: - button.fsStyle = NativeMethods.TBSTYLE_BUTTON; + button.fsStyle = (byte)ComCtl32.TBSTYLE.BUTTON; break; case ToolBarButtonStyle.ToggleButton: - button.fsStyle = NativeMethods.TBSTYLE_CHECK; + button.fsStyle = (byte)ComCtl32.TBSTYLE.CHECK; break; case ToolBarButtonStyle.Separator: - button.fsStyle = NativeMethods.TBSTYLE_SEP; + button.fsStyle = (byte)ComCtl32.TBSTYLE.SEP; break; }