private GetTBBUTTONINFO ( bool updateText, int newCommandId ) : System.Windows.Forms.NativeMethods.TBBUTTONINFO | ||
updateText | bool | |
newCommandId | int | |
return | System.Windows.Forms.NativeMethods.TBBUTTONINFO |
/// <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(); } } }
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(); } } }