掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ボタンでどうすれば? (ID:115093)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
ソースを書いたのですけれど、 楕円形のボタンが表示されません。 ========ソース====================== 'Button1の背景画像を設定 Button1.BackgroundImage = Image.FromFile("C:\test.png") 'Button1のPaintイベントハンドラを追加 AddHandler Button1.Paint, AddressOf Button1_Paint Button1.SetBounds(64, 184, 100, 50) '頂点の座標を書きます。 Dim points() As Point = _ {New Point(0, 0), _ New Point(80, 0), _ New Point(80, 30), _ New Point(0, 30)} '次に何で結ぶかを書きます。 Dim types() As Byte = _ {Drawing.Drawing2D.PathPointType.Line, _ Drawing.Drawing2D.PathPointType.Line, _ Drawing.Drawing2D.PathPointType.Line, _ Drawing.Drawing2D.PathPointType.Line} 'あとは、これで指定して完了です。 Dim path As New Drawing2D.GraphicsPath(points, types) '形を変えたいコントロール名.Region = New Region(path) 'Button1.Region = New Region(path) Button1.Region = New Region(path) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show("ボタンがクリックされました。") End Sub Private Sub Button1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Button1.Paint Dim btn As Button = CType(sender, Button) 'ボタンの背景画像をボタンの大きさに合わせて描画 e.Graphics.DrawImage(btn.BackgroundImage, btn.ClientRectangle) 'ボタンのTextを描画する準備 Dim sf As New StringFormat '文字列を真ん中に描画 sf.Alignment = StringAlignment.Center sf.LineAlignment = StringAlignment.Center '&がアンダーラインになるようにする sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show 'Brushの作成 Dim brsh = New SolidBrush(btn.ForeColor) '文字列を描画 e.Graphics.DrawString(btn.Text, btn.Font, brsh, _ RectangleF.op_Implicit(btn.ClientRectangle), sf) brsh.Dispose() End Sub ============================================================= 楕円形に作った画像をボタンに表示して、ボタンの大きさを変えたんですけれど、画像もボタンと一緒にトリムされたような表示になってしまいます。 何処が原因でしょうか? あと、上の質問もお願いします。
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.