« August 2006 | Main | December 2006 »

September 25, 2006

VisualBasic2005のフォーム再描画

VisualBasic2005でフォームに描いたグラフィックスをAutoRedrawにする方法。

PictureBoxの例を参考にフォーム版に書き換えたけど・・・これで良いのかな?

一応うまく動いているけど・・・

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim g As Graphics = AutoGraphics(me)

        g.Clear(Color.Black)

        g.FillPie(Brushes.Aqua, 10, 10, 100, 100, 0, 90)

    End Sub

    Public Function AutoGraphics(ByVal f As Form) As Graphics
        If f.BackgroundImage Is Nothing Then

            f.BackgroundImage = New Bitmap(f.ClientRectangle.Width, f.ClientRectangle.Height)

        End If

        Return Graphics.FromImage(f.BackgroundImage)

    End Function

End Class

| | Comments (0) | TrackBack (0)

« August 2006 | Main | December 2006 »