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

GetTBBUTTON() private method

private GetTBBUTTON ( int commandId ) : System.Windows.Forms.NativeMethods.TBBUTTON
commandId int
return System.Windows.Forms.NativeMethods.TBBUTTON
        internal NativeMethods.TBBUTTON GetTBBUTTON(int commandId) {

            NativeMethods.TBBUTTON button = new NativeMethods.TBBUTTON();

            button.iBitmap = ImageIndexer.ActualIndex;

            // set up the state of the button
            //
            button.fsState = 0;
            if (enabled) button.fsState |= NativeMethods.TBSTATE_ENABLED;
            if (partialPush && style == ToolBarButtonStyle.ToggleButton) button.fsState |= NativeMethods.TBSTATE_INDETERMINATE;
            if (pushed) button.fsState |= NativeMethods.TBSTATE_CHECKED;
            if (!visible) button.fsState |= NativeMethods.TBSTATE_HIDDEN;

            // set the button style
            //
            switch (style) {
                case ToolBarButtonStyle.PushButton:
                    button.fsStyle = NativeMethods.TBSTYLE_BUTTON;
                    break;
                case ToolBarButtonStyle.ToggleButton:
                    button.fsStyle = NativeMethods.TBSTYLE_CHECK;
                    break;
                case ToolBarButtonStyle.Separator:
                    button.fsStyle = NativeMethods.TBSTYLE_SEP;
                    break;
                case ToolBarButtonStyle.DropDownButton:
                    button.fsStyle = NativeMethods.TBSTYLE_DROPDOWN;
                    break;

            }

            button.dwData = (IntPtr)0;
            button.iString = this.stringIndex;
            this.commandId = commandId;
            button.idCommand = commandId;

            return button;
        }

Usage Example

Example #1
0
        /// <include file='doc\ToolBar.uex' path='docs/doc[@for="ToolBar.InsertButton"]/*' />
        /// <devdoc>
        ///    <para>Inserts a button at a given location on the toolbar control.</para>
        /// </devdoc>
        private void InsertButton(int index, ToolBarButton value) {

            if (value == null)
                throw new ArgumentNullException("value");
            if (index < 0 || ((buttons != null) && (index > buttonCount)))
                throw new ArgumentOutOfRangeException("index", SR.GetString(SR.InvalidArgument, "index", index.ToString(CultureInfo.CurrentCulture)));

            // insert the button into our local array, and then into the
            // real windows ToolBar control
            //
            Insert(index, value);
            if (IsHandleCreated) {
                NativeMethods.TBBUTTON tbbutton = value.GetTBBUTTON(index);
                UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TB_INSERTBUTTON, index, ref tbbutton);
            }
            UpdateButtons();
        }
All Usage Examples Of System.Windows.Forms.ToolBarButton::GetTBBUTTON