この文書の現在のバージョンと選択したバージョンの差分を表示します。
両方とも前のリビジョン 前のリビジョン | |||
toolstrip上のアイテムを引き延ばす [2009/02/03 07:51] admin 削除 |
— (現在) | ||
---|---|---|---|
ライン 1: | ライン 1: | ||
- | ====== ToolStrip上のアイテムを引き延ばす ====== | ||
- | |||
- | ブラウザのアドレスバーの様に1つのアイテムをその幅いっぱいまで引き伸ばすコードです。あんまり深く検証してませんので、実際使うときはよく確かめてから使ってください。 | ||
- | |||
- | <code cpp> | ||
- | void stretchToolItem(ToolStrip^ bar, ToolStripItem^ itemstretch) | ||
- | { | ||
- | int all = bar->Size.Width; | ||
- | |||
- | int other = 0; | ||
- | other += bar->Margin.Left; | ||
- | other += bar->Margin.Right; | ||
- | other += bar->GripRectangle.Width; | ||
- | other += bar->GripMargin.Left + bar->GripMargin.Right; | ||
- | |||
- | for each( ToolStripItem^ item in bar->Items ) | ||
- | { | ||
- | if ( item != itemstretch ) | ||
- | { | ||
- | other += item->Size.Width; | ||
- | other += (item->Margin.Left + item->Margin.Right); | ||
- | other += (item->Padding.Left + item->Padding.Right); | ||
- | } | ||
- | } | ||
- | |||
- | itemstretch->Size = ::Size(all - other, itemstretch->Size.Height); | ||
- | itemstretch->Visible = false; | ||
- | itemstretch->Visible = true; | ||
- | } | ||
- | </code> | ||
- | barがToolStripでitemstretchが引き延ばすアイテムです。最後にVisibleを設定し直してますが、なぜか引き延ばしたアイテムが表示されなくなるときがあるので付けています。 |