コード例 #1
0
        internal System.Windows.Forms.NativeMethods.TBBUTTONINFO GetTBBUTTONINFO(bool updateText, int newCommandId)
        {
            System.Windows.Forms.NativeMethods.TBBUTTONINFO tbbuttoninfo = new System.Windows.Forms.NativeMethods.TBBUTTONINFO {
                cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TBBUTTONINFO)),
                dwMask = 13
            };
            if (updateText)
            {
                tbbuttoninfo.dwMask |= 2;
            }
            tbbuttoninfo.iImage = this.ImageIndexer.ActualIndex;
            if (newCommandId != this.commandId)
            {
                this.commandId         = newCommandId;
                tbbuttoninfo.idCommand = newCommandId;
                tbbuttoninfo.dwMask   |= 0x20;
            }
            tbbuttoninfo.fsState = 0;
            if (this.enabled)
            {
                tbbuttoninfo.fsState = (byte)(tbbuttoninfo.fsState | 4);
            }
            if (this.partialPush && (this.style == ToolBarButtonStyle.ToggleButton))
            {
                tbbuttoninfo.fsState = (byte)(tbbuttoninfo.fsState | 0x10);
            }
            if (this.pushed)
            {
                tbbuttoninfo.fsState = (byte)(tbbuttoninfo.fsState | 1);
            }
            if (!this.visible)
            {
                tbbuttoninfo.fsState = (byte)(tbbuttoninfo.fsState | 8);
            }
            switch (this.style)
            {
            case ToolBarButtonStyle.PushButton:
                tbbuttoninfo.fsStyle = 0;
                break;

            case ToolBarButtonStyle.ToggleButton:
                tbbuttoninfo.fsStyle = 2;
                break;

            case ToolBarButtonStyle.Separator:
                tbbuttoninfo.fsStyle = 1;
                break;
            }
            if (this.text == null)
            {
                tbbuttoninfo.pszText = Marshal.StringToHGlobalAuto("\0\0");
                return(tbbuttoninfo);
            }
            string text = this.text;

            this.PrefixAmpersands(ref text);
            tbbuttoninfo.pszText = Marshal.StringToHGlobalAuto(text);
            return(tbbuttoninfo);
        }
コード例 #2
0
 internal int GetButtonWidth()
 {
     int width = this.Parent.ButtonSize.Width;
     System.Windows.Forms.NativeMethods.TBBUTTONINFO lParam = new System.Windows.Forms.NativeMethods.TBBUTTONINFO {
         cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TBBUTTONINFO)),
         dwMask = 0x40
     };
     int num2 = (int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.Parent, this.Parent.Handle), System.Windows.Forms.NativeMethods.TB_GETBUTTONINFO, this.commandId, ref lParam);
     if (num2 != -1)
     {
         width = lParam.cx;
     }
     return width;
 }
コード例 #3
0
        internal int GetButtonWidth()
        {
            int width = this.Parent.ButtonSize.Width;

            System.Windows.Forms.NativeMethods.TBBUTTONINFO lParam = new System.Windows.Forms.NativeMethods.TBBUTTONINFO {
                cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TBBUTTONINFO)),
                dwMask = 0x40
            };
            int num2 = (int)System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.Parent, this.Parent.Handle), System.Windows.Forms.NativeMethods.TB_GETBUTTONINFO, this.commandId, ref lParam);

            if (num2 != -1)
            {
                width = lParam.cx;
            }
            return(width);
        }
コード例 #4
0
 private void ForceButtonWidths()
 {
     if (((this.buttons != null) && this.buttonSize.IsEmpty) && base.IsHandleCreated)
     {
         this.maxWidth = -1;
         for (int i = 0; i < this.buttonCount; i++)
         {
             System.Windows.Forms.NativeMethods.TBBUTTONINFO lParam = new System.Windows.Forms.NativeMethods.TBBUTTONINFO {
                 cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TBBUTTONINFO)),
                 cx = this.buttons[i].Width
             };
             if (lParam.cx > this.maxWidth)
             {
                 this.maxWidth = lParam.cx;
             }
             lParam.dwMask = 0x40;
             System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), System.Windows.Forms.NativeMethods.TB_SETBUTTONINFO, i, ref lParam);
         }
     }
 }
コード例 #5
0
        internal System.Windows.Forms.NativeMethods.TBBUTTONINFO GetTBBUTTONINFO(bool updateText, int newCommandId)
        {
            System.Windows.Forms.NativeMethods.TBBUTTONINFO tbbuttoninfo = new System.Windows.Forms.NativeMethods.TBBUTTONINFO {
                cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TBBUTTONINFO)),
                dwMask = 13
            };
            if (updateText)
            {
                tbbuttoninfo.dwMask |= 2;
            }
            tbbuttoninfo.iImage = this.ImageIndexer.ActualIndex;
            if (newCommandId != this.commandId)
            {
                this.commandId = newCommandId;
                tbbuttoninfo.idCommand = newCommandId;
                tbbuttoninfo.dwMask |= 0x20;
            }
            tbbuttoninfo.fsState = 0;
            if (this.enabled)
            {
                tbbuttoninfo.fsState = (byte) (tbbuttoninfo.fsState | 4);
            }
            if (this.partialPush && (this.style == ToolBarButtonStyle.ToggleButton))
            {
                tbbuttoninfo.fsState = (byte) (tbbuttoninfo.fsState | 0x10);
            }
            if (this.pushed)
            {
                tbbuttoninfo.fsState = (byte) (tbbuttoninfo.fsState | 1);
            }
            if (!this.visible)
            {
                tbbuttoninfo.fsState = (byte) (tbbuttoninfo.fsState | 8);
            }
            switch (this.style)
            {
                case ToolBarButtonStyle.PushButton:
                    tbbuttoninfo.fsStyle = 0;
                    break;

                case ToolBarButtonStyle.ToggleButton:
                    tbbuttoninfo.fsStyle = 2;
                    break;

                case ToolBarButtonStyle.Separator:
                    tbbuttoninfo.fsStyle = 1;
                    break;
            }
            if (this.text == null)
            {
                tbbuttoninfo.pszText = Marshal.StringToHGlobalAuto("\0\0");
                return tbbuttoninfo;
            }
            string text = this.text;
            this.PrefixAmpersands(ref text);
            tbbuttoninfo.pszText = Marshal.StringToHGlobalAuto(text);
            return tbbuttoninfo;
        }