Пример #1
0
 internal void NativeUpdateButtonAt(ToolBoxButton button, int index)
 {
     if (IsHandleCreated)
     {
         button.owner   = this;
         buttons[index] = button;
         NativeMethods.TBBUTTONINFO btnINFO = button.GetTBBUTTONINFO(index);
         UnsafeNativeMethods.SendMessage(new HandleRef(this, this.Handle), NativeMethods.TB_SETBUTTONINFO, index, ref btnINFO);
     }
 }
Пример #2
0
 internal void NativeInsert(ToolBoxButton value, int index)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (IsHandleCreated)
     {
         if ((value.Appearance & TBBAppearance.Separator) != 0)
         {
             value.Width = 0;
         }
         else
         {
             Size edge = SystemInformation.Border3DSize;
             Size size = Size.Empty;
             if (!string.IsNullOrEmpty(value.Text))
             {
                 using (Graphics g = Graphics.FromHwnd(Handle))
                 {
                     if (!string.IsNullOrEmpty(value.Text))
                     {
                         size        = Size.Ceiling(g.MeasureString(value.Text, Font));
                         size.Width += 10;
                     }
                 }
             }
             if ((appearance & TBAppearance.List) != 0)//如果有List属性
             {
                 value.Width = size.Width + ImageSize.Width + edge.Width * 3;
             }
             else
             {
                 value.Width = size.Width > ImageSize.Width ? size.Width + edge.Width * 4 : ImageSize.Width + edge.Width * 4;
             }
             if ((value.Appearance & TBBAppearance.DropDown) != 0)
             {
                 value.Width += 16;
             }
             if ((value.Appearance & TBBAppearance.WholeDropDown) != 0)
             {
                 value.Width += 8;
             }
         }
         NativeMethods.TBBUTTON tbbutton = value.GetTBBUTTON(index);
         UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TB_INSERTBUTTON, index, ref tbbutton);
         NativeMethods.TBBUTTONINFO tbbuttonINFO = value.GetTBBUTTONINFO(index);
         UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TB_SETBUTTONINFO, index, ref tbbuttonINFO);
     }
 }