Whats wrong with my Picturebox set on a timer

TALSOFT

Active member
Joined
Feb 23, 2012
Messages
34
Programming Experience
5-10
So I want this picture box to grow when the user clicks on it, to the size of the screen. Because at first it appears to be a button, when clicked it grows the size of lets just say Form1 (which is full screen, and for the sake of conversation lets say 1024 X 768 for simplicity).

Here is the code I have written (whereas SimpleShellMenu is the picturebox and logoutmenu is a timer set to 10ms

Private Sub logoutmenu_Tick(sender As Object, e As EventArgs) Handles logoutmenu.Tick
Dim YMG As Integer = SimpleShellMenu.Size.Width
Dim XMG As Integer = SimpleShellMenu.Size.Height
If XMG < Me.Size.Width Then
With SimpleShellMenu
.SizeMode = PictureBoxSizeMode.StretchImage
.Size = New Size(XMG, YMG)
XMG += 16
End With
End If
If YMG < Me.Size.Height Then
With SimpleShellMenu
.SizeMode = PictureBoxSizeMode.StretchImage
.Size = New Size(XMG, YMG)
YMG += 9
End With
End If


End Sub


What ends up happening is when I click the picturebox the timer starts, performing this simple math it appears to work at first but then it stops growing on the Width and starts jumping width wize its kind of creepy. Regardless it works for the most part, just does not fill the screen on the Width.

Any ideas what I am doing wrong?
 
Size Constructor (Int32, Int32) (System.Drawing)
Look closer to constructor parameters, what is actually the order?
Also what's the point of incrementing XMG/YMG after you have set Size, these variables lose scope each time method ends.
Further, you only need to set Size once in that method. Check/add both values and then set size.
 
Size Constructor (Int32, Int32) (System.Drawing)
Look closer to constructor parameters, what is actually the order?
Also what's the point of incrementing XMG/YMG after you have set Size, these variables lose scope each time method ends.
Further, you only need to set Size once in that method. Check/add both values and then set size.


The point is to create the illusion that it is filling the screen. Am I not using the best methood to achieve this? As this is the only way I can think to make a picturebox slowly fill the screen...
 
The point is to create the illusion that it is filling the screen. Am I not using the best methood to achieve this? As this is the only way I can think to make a picturebox slowly fill the screen...
Yes, but you have to fix your code that is now wrong. Read my reply again, it was intended to help you fix the problems in code you posted.
 
Back
Top