help please

novena88
05-11-2006, 09:12 AM
ok so i have to create the back ground of a form and make it a drawing surfaceand the direction for this i dont get....how would this be done? this isnt the main part of the project im just wondering what the code would look like for this....i dont understand where you would put these things...heres the directions so u can get the idea

Visual Basic .NET includes the Graphics class with methods for creating circles, lines, rectangles, and other shapes on a drawing surface. A drawing surface can be the surface of a form or the surface of other objects like buttons. To declare a surface on a particular form or button, use the following format:

Dim FormSurface As Graphics = Me.CreateGraphics

Dim ButtonSurface As Graphics = Me.btn1.CreateGraphics

However, to draw a shape on a drawing surface requires a Pen object. The pen name, pen color, and line thickness are all declared in the same statement, as in the following:

Dim ThinRedPen As New Pen(Color.Red, 1)

Dim ThickBlackPen As New Pen(Color.Black, 5)

To draw a filled shape on a drawing surface requires a Brush object. The brush name and brush color are declared in the same statement, as in the following:

Dim BlueBrush As New SolidBrush(Color.Blue)


the assinments after this...i just cant figure out how to get the drawing surface to work...PLEASE HELP

jwakeman
05-13-2006, 02:37 PM
OK, check out my first drawing ever! Paste this code into the Form1 class and check out my smiley face. It even resizes with the form. Thanks for the question novena88, I have been meaning to learn to use the drawing and graphics stuff in .net.

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim FormSurface As Graphics = Me.CreateGraphics
Dim ThickBlackPen As New Pen(Color.Black, 5)
Dim YellowBrush As New SolidBrush(Color.Yellow)
Dim BlackBrush As New SolidBrush(Color.Black)
Dim points As Point() = { _
New Point(Convert.ToSingle(Me.Width / 4), Convert.ToSingle(Me.Height * (3 / 4))), _
New Point(Convert.ToSingle(Me.Width / 2), Convert.ToSingle(Me.Height * (8 / 10))), _
New Point(Convert.ToSingle(Me.Width * (3 / 4)), Convert.ToSingle(Me.Height * (3 / 4))) _
}

FormSurface.Clear(Color.LightGray)

FormSurface.FillEllipse(YellowBrush, Convert.ToSingle((Me.Width / 30)), Convert.ToSingle((Me.Height / 30)), Convert.ToSingle(Me.Width - (Me.Width / 10)), Convert.ToSingle(Me.Height - (Me.Height / 10)))
FormSurface.FillEllipse(BlackBrush, Convert.ToSingle((Me.Width / 4)), Convert.ToSingle((Me.Height / 4)), Convert.ToSingle(Me.Width / 10), 2 * Convert.ToSingle(Me.Width / 10))
FormSurface.FillEllipse(BlackBrush, Convert.ToSingle((Me.Width * (3 / 4))) - Convert.ToSingle(Me.Width / 10), Convert.ToSingle((Me.Height / 4)), Convert.ToSingle(Me.Width / 10), 2 * Convert.ToSingle(Me.Width / 10))
FormSurface.DrawCurve(ThickBlackPen, points)

End Sub

Private Sub Form1_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeEnd
Me.Refresh()
End Sub

Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
Me.Refresh()
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum