clint 2

Hi dave...and all

I am asking you this because I think you are a bit of an expert on regions and bounds...

I have a small picturebox displaying a selection of images....

I would like this picturebox to appear at random locations within the screen bounds.....and if possible

I would like the picturebox to randomly tilt left or right and straight \ \ ....l l... / /

do you think you could help with this for me)

all help appreciated


Re: Visual Basic Express Edition for dave299


I'm no expert Clint, not even a bit of one - just learning like most people here.

However have a look at this. It needs a bit of trigonometry to ensure the pictures stay fully on the screen and it cheats a bit by invalidating the whole form, not just the area that needs to be invalidated but I suspect that may be ok for you. Hopefully it will give you a start.

Public Class Form1

Dim WithEvents Tmr As New Timer

Dim Pics(2) As Image

Dim Rnd As New Random

Dim Number As Integer

Dim Angle As Integer

Dim PicLocation As New Point(200, 200)

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

WindowState = FormWindowState.Maximized

Pics(0) = Image.FromFile("d:\temp\pic1.gif")

Pics(1) = Image.FromFile("d:\temp\pic2.gif")

Pics(2) = Image.FromFile("d:\temp\pic3.gif")

Tmr.Interval = 1000


End Sub

Private Sub Tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr.Tick

Number = Rnd.Next(0, 3)

Angle = 30 * Rnd.Next(-1, 2)

PicLocation = New Point(Rnd.Next(0, Me.Width - Pics(Number).Width), Rnd.Next(0, Me.Height - Pics(Number).Height))


End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

Dim M As New Drawing2D.Matrix

M.RotateAt(Angle, PicLocation)

e.Graphics.Transform = M

e.Graphics.DrawImage(Pics(Number), PicLocation)

End Sub

End Class

Re: Visual Basic Express Edition for dave299

clint 2

cheers dave

Im gonna have a bit of fun with this......catch ya later



ok dave

I've had a play with it.....imported it to my app....BRILLIANT

it couldn't be more perfect.....EXACTLY what I asked for

thank you so very much