Creating a new form

hendrikbez

Active member
Joined
Nov 24, 2005
Messages
35
Location
South Afica
Programming Experience
1-3
I am new to vb.net, and I want to make a customize winsows form for my sine-in form, it will be a cross, how do I Use the graphics in vb.net 2003.:eek:

Thanks
 
Ok, this is the next step, You have used a pen to draw the path, now you are going to use a brush to fill the path. SO we need to instantiate a new brush.
[Dim MyBrush As New SolidBrush(Color.red)]
Then fill the path with our new red brush...
[e.Graphics.FillPath(Mybrush,MygraphicsPath)
Thats all there is to it, mind you that is a very simple example. There are a couple of ohter types of brushes available in GDI+ i.e

LinearGradientBrush
PathGradientBrush
TextureBrushes

These are all much more fun that the standard solid brush. Check out MSDN for some tutorials on how to use them.


 
They will have some visual basic.net examples. Try searching for 'Create a graphicspath - VB.Net' add the vb.net at the end of all your searches and you should get what you want. A couple of sites that are pretty good are..


www.thecodeproject.com
www.learnvb.net.com
 
The System.Drawing.Bitmap.MakeTransparent method may help simplify your code.
Also your code to move the form jumps a bit at first. This is code that I use:
VB.NET:
Dim myX As Integer, myY As Integer

Private Sub Form_MouseMove(ByVal sender As Object, _
  ByVal e As System.Windows.Forms.MouseEventArgs) _
  Handles MyBase.MouseMove
    If e.Button = MouseButtons.Left Then
        Me.Location = New Point(Me.Left + (e.X - myX), _
                                Me.Top + (e.Y - myY))
    End If
End Sub

Private Sub Form_MouseDown(ByVal sender As Object, _
  ByVal e As System.Windows.Forms.MouseEventArgs) _
  Handles MyBase.MouseDown
    myX = e.X
    myY = e.Y
End Sub
No need for a boolean variable to keep track of mouseDown, just check the MouseButtons. It can be simplified more using a Point instead of two Integers but I'm lazy :).
 
Glad you got everything sorted, and kulrom is quite right, using images made in photoshop and other image editing programs can save you time and in some cases produce better visual effects, however since you have started on the road down GDI+, i urge not to neglect it. As it is possible to create some cracking effects with the brushes in there. And remember using bitmaps does have some limitiations unless you want to start getting really complicated.
 
Back
Top