System.Windows.Forms.ToolBarButton.GetButtonWidth C# (CSharp) Method

GetButtonWidth() private method

private GetButtonWidth ( ) : int
return int
        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();
            button.cbSize = Marshal.SizeOf(typeof(NativeMethods.TBBUTTONINFO));
            button.dwMask = NativeMethods.TBIF_SIZE;
            
            int buttonID = (int)UnsafeNativeMethods.SendMessage(new HandleRef(Parent, Parent.Handle), NativeMethods.TB_GETBUTTONINFO, commandId, ref button);
            if (buttonID != -1) {
                buttonWidth = button.cx;
            }
            
            return buttonWidth;
        }