Form border

myblueocean

Well-known member
Joined
Jun 29, 2007
Messages
161
Location
England
Programming Experience
Beginner
Can anyone give me a clue as to how to have a border around a certain piece of a form?

So nothing can pass from one part to another, like an invisible wall:D
 
I didn't just copy all the code.
:eek: Why on earth not?! That's exactly what you were supposed to do. Please go back to that post, read it properly and do what it says. Once you've seen what the code does and read the code properly it should be more apparent how it works.

As for the ClientSize property, read the MSDN documentation for that property if you don't know what it does. Any type or member that you don't understand, read the documentation first, then ask if you still don't understand.
 
Well I wanted to type it in myself?

As for the increment word, I have a book and it talks about animation but only the picture box.

I did try the code out, it isn't as if I just copied it in or typed it in and didn't try it out.

As for the documentation I have checked that out, F1. And I have only peeked into the MSDN a little.
 
The whole point of post #14 was that you would follow the instructions provided, see the end result, then go back and read the code and relate that to what you saw.
 
"
VB.NET:
Public Class Form1
    Private rect As New Rectangle(0, 0, 15, 15)
    Private xincrement As Integer = 5
    Private yincrement As Integer = 0


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Timer1.Start()
    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        'Draw the Rectangle.
        e.Graphics.DrawRectangle(Pens.White, Me.rect)
        'Fill the rectangle.
        e.Graphics.FillRectangle(Brushes.White, Me.rect)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        'Mark the old rectangle to be erased.
        Me.Invalidate(Rectangle.Inflate(Me.rect, 1, 1))

        'Shift the rectangle.
        Me.rect.Offset(Me.xincrement, Me.yincrement)

        'Mark the new rectangle to be drawn.
        Me.Invalidate(Rectangle.Inflate(Me.rect, 1, 1))

        'Do the drawing.
        Me.Update()

        'Change the direction of movement if a boundary has been reached.
        If Me.xincrement = 1 AndAlso Me.rect.Right >= Me.ClientSize.Width - 1 Then
            Me.xincrement = 0
            Me.yincrement = 1
        ElseIf Me.yincrement = 1 AndAlso Me.rect.Bottom >= Me.ClientSize.Height - 1 Then
            Me.xincrement = -1
            Me.yincrement = 0
        End If
    End Sub
End Class
"
 
Last edited by a moderator:
Back
Top