本文整理汇总了C#中System.Windows.Forms.ToolBarButton.GetTBBUTTONINFO方法的典型用法代码示例。如果您正苦于以下问题:C# ToolBarButton.GetTBBUTTONINFO方法的具体用法?C# ToolBarButton.GetTBBUTTONINFO怎么用?C# ToolBarButton.GetTBBUTTONINFO使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolBarButton
的用法示例。
在下文中一共展示了ToolBarButton.GetTBBUTTONINFO方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalSetButton
/// <include file='doc\ToolBar.uex' path='docs/doc[@for="ToolBar.InternalSetButton"]/*' />
/// <devdoc>
/// Changes the data for a button in the ToolBar, and then does the appropriate
/// work to update the ToolBar control.
/// </devdoc>
/// <internalonly/>
internal void InternalSetButton(int index, ToolBarButton value, bool recreate, bool updateText) {
// tragically, there doesn't appear to be a way to remove the
// string for the button if it has one, so we just have to leave
// it in there.
//
buttons[index].parent = null;
buttons[index].stringIndex = (IntPtr)(-1);
buttons[index] = value;
buttons[index].parent = this;
if (IsHandleCreated) {
NativeMethods.TBBUTTONINFO tbbi = value.GetTBBUTTONINFO(updateText, index);
UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TB_SETBUTTONINFO, index, ref tbbi);
if (tbbi.pszText != IntPtr.Zero) {
Marshal.FreeHGlobal(tbbi.pszText);
}
if (recreate) {
UpdateButtons();
}
else {
// after doing anything with the comctl ToolBar control, this
// appears to be a good idea.
//
SendMessage(NativeMethods.TB_AUTOSIZE, 0, 0);
ForceButtonWidths();
this.Invalidate();
}
}
}
示例2: InternalSetButton
internal void InternalSetButton(int index, ToolBarButton value, bool recreate, bool updateText)
{
this.buttons[index].parent = null;
this.buttons[index].stringIndex = (IntPtr) (-1);
this.buttons[index] = value;
this.buttons[index].parent = this;
if (base.IsHandleCreated)
{
System.Windows.Forms.NativeMethods.TBBUTTONINFO tBBUTTONINFO = value.GetTBBUTTONINFO(updateText, index);
System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), System.Windows.Forms.NativeMethods.TB_SETBUTTONINFO, index, ref tBBUTTONINFO);
if (tBBUTTONINFO.pszText != IntPtr.Zero)
{
Marshal.FreeHGlobal(tBBUTTONINFO.pszText);
}
if (recreate)
{
this.UpdateButtons();
}
else
{
base.SendMessage(0x421, 0, 0);
this.ForceButtonWidths();
base.Invalidate();
}
}
}