Results 1 to 30 of 30

Thread: [2005] Size Up ^^^^

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    [2005] Size Up ^^^^

    I have added the following codefor a form to spring in at loading time:
    VB Code:
    1. 'Original size reminder 423,384
    2.         Do While Me.Size.Height = 357 & Me.Size.Width = 391
    3.             Me.Refresh()
    4.             Me.Height = 423
    5.             Me.Width = 384
    But it does'nt work.
    What am I doing wrong?
    As always,any advice given would be much appreciated
    Last edited by Louix; Oct 5th, 2006 at 01:58 PM.

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] Size Up ^^^^

    Quote Originally Posted by Louix
    I have added the following codefor a form to spring in at loading time:
    VB Code:
    1. 'Original size reminder 423,384
    2.         Do While Me.Size.Height = 357 & Me.Size.Width = 391
    3.             Me.Refresh()
    4.             Me.Height = 423
    5.             Me.Width = 384
    But it does'nt work.
    What am I doing wrong?
    As always,any advice given would be much appreciated
    Hi,

    You could try to do it like this;

    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         If Me.Size = New Size(200, 150) Then
    3.             Me.Size = New Size(423, 384)
    4.         End if
    5.  
    6.     End Sub

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    thanks sparrow 1
    but i can't see any different sizes so somewhere there'd need to be a form refresh.
    I'm trying to give the form,when it opens,a zoom effect.
    ;-)

  4. #4
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] Size Up ^^^^

    Quote Originally Posted by Louix
    thanks sparrow 1
    but i can't see any different sizes so somewhere there'd need to be a form refresh.
    I'm trying to give the form,when it opens,a zoom effect.
    ;-)
    Hi,

    Sorry forgot to tell you to set the size of your Form in design time to
    Width = 200, height = 100, then you'll see the difference.

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  5. #5
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [2005] Size Up ^^^^

    The most likely cause of the issue is that the form is being resized before you actually see it. Try moving the code into the FormActivated event. Also you should use an if statment like sparrows example, instead of a loop, unless you plan on looping.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    It still dosen't work.
    could you paste code so i could see what i was doing wrong?
    Thx,
    Louix:-)

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    anyone?

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Size Up ^^^^

    What exactly are you trying to achieve? Your code doesn't make any sense because you're using a Do loop yet it can't possibly make more than one iteration. Also, where have you placed that code? You can't refresh a form that isn't displayed so it can't be of any use whatsoever if it is executed before the Shown event is raised.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9
    Banned
    Join Date
    May 2006
    Posts
    161

    Re: [2005] Size Up ^^^^

    The code seems a bit off...
    You will need to provide what sort of output or input you are looking for.
    For instance, what is the reasoning behind the refresh and the do while loop.

    Also you may want to use AND or ANDAlso why are you using & ?

  10. #10
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] Size Up ^^^^

    Quote Originally Posted by Louix
    It still dosen't work.
    could you paste code so i could see what i was doing wrong?
    Thx,
    Louix:-)
    Hi,

    I found another way to do it, set in designtime your form size to 200,100 then use this code;

    VB Code:
    1. Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
    2.         If Me.Size = New Size(200, 100) Then
    3.             Me.Size = New Size(423, 384)
    4.         End If
    5.     End Sub

    I found that er is a Method named as ' Resize ' what you can use for your form.

    Wkr,

    sparrow1
    Last edited by sparrow1; Oct 6th, 2006 at 05:25 AM.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    Thanks again,sparrow,but it still dosen't work
    :-(
    It's either doing it to quickly or it's just sizing itself secretly.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    For JAKsupport,I was using that based on the opacity thing and i thought it would work but it didn't.

  13. #13
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] Size Up ^^^^

    Simply changing from ONE size to another wouldnt give you any zoom effect at all.

    You should use the Do Until Loop. A good thing would be to put the code in its own thread.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    I don't understand :-|

  15. #15
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] Size Up ^^^^

    give your form a new size like this:

    VB Code:
    1. Me.Size = New Size(X,X)

    if you want it to grow from small to big do like this:

    VB Code:
    1. Me.Size= New Size(1,1)
    2. Do Until Me.Width=500
    3.      Me.Width += 1
    4.      Me.Height += 1
    5. Loop

    But the second code should be threaded, and preferably have a pause in it to make it noticeable.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  16. #16
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [2005] Size Up ^^^^

    Quote Originally Posted by Atheist
    give your form a new size like this:

    VB Code:
    1. Me.Size = New Size(X,X)

    if you want it to grow from small to big do like this:

    VB Code:
    1. Me.Size= New Size(1,1)
    2. Do Until Me.Width=500
    3.      Me.Width += 1
    4.      Me.Height += 1
    5. Loop

    But the second code should be threaded, and preferably have a pause in it to make it noticeable.

    This is on the right track...But it's still not going to work. This is goign to increment the form size so quickly that you still won't see a change. You need to use a timer. In the formload start the timer then in the timers tick event do this
    VB Code:
    1. If Me.Width < 500
    2.   Me.Width += 1
    3.   Me.Height += 1
    4. Else
    5.   timer1.Enabled = False
    6. End If

    Then using this you would just play with the interval of the timer to get teh desired speed for the form to grow.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  17. #17
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [2005] Size Up ^^^^

    In the formload
    And read this about the timer to learn what the properties expext.

    I also said the resizing of the form goes in the timer's event. Not the Form Resize event.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    This is what i've done:

    VB Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Timer1.Start()
    5.         Timer1.Interval = 1.5
    6.     End Sub
    7.     Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    8.         If Me.Width < 500 Then
    9.             Me.Width += 1
    10.             Me.Height += 1
    11.         Else
    12.             Timer1.Enabled = False
    13.         End If
    14.  
    15.     End Sub
    16. End Class
    but the form just keeps on sizing it's self.
    Paste code so i can do this right.
    P.S I want the whole form to size instead of the right-hand side.
    but we are on the right track.
    :-)

  19. #19
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,521

    Re: [2005] Size Up ^^^^

    The interval should be set before you start the timer. Also The interval is set in milliseconds. Also the interval is an integer, so it can't be a partial millisecond. That is why I gave you the link.

    Are you sure the form is reaching 500? Add a label to the form and in the timer's event put
    VB Code:
    1. label1.Text = me.Width.ToString 'assuming the new label is called label1
    This will tell if the form is going past the requested hieght.

    If you want the form to look centered when the size is increasing you are also going to have to change the location of the form every time you change the size.
    Visual Studio Team Edition 2005
    GDI+ Links: Bob Powell VB.Net Heaven
    API Links: All API Pinvoke.Net
    VB6 to VB.Net: Visual Basic 6 to .NET Function Equivalents (Thread)

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    Sorry,I missed that part.I'll read it now.

  21. #21
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] Size Up ^^^^

    Try this:
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, _
    2.             ByVal e As System.EventArgs) Handles MyBase.Load
    3.         Timer1.Interval = 5
    4.         Timer1.Enabled = True
    5.     End Sub
    6.  
    7. Private Sub Timer1_Tick(ByVal sender As Object, _
    8.                         ByVal e As System.EventArgs) Handles Timer1.Tick
    9.         Dim iWidth As Integer = Me.Width
    10.         Dim iHeight As Integer = Me.Height
    11.         Dim pt As Point = Me.Location
    12.         If iWidth < 800 And iHeight < 600 Then
    13.             Me.Width += 4
    14.             Me.Height += 4
    15.             Me.Location = New Point(pt.X - 2, pt.Y - 2)
    16.         Else
    17.             Timer1.Enabled = False
    18.         End If
    19.     End Sub
    Last edited by stanav; Oct 6th, 2006 at 02:12 PM.

  22. #22
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Size Up ^^^^

    Can I just confirm exactly what you're trying to do here? You're trying to make the form appear using a transition effect, correct? If so then there is an AnimateWindow API that provides several effects without any code other than declaring the function and calling it. Two lines of code and you get access to four different effects. One fades in and out, one slides the form in and out from one edge, one rolls the form in and out form one edge and the lasts rolls the form in and out from the centre. I've posted code in the CodeBank that wraps this API in a manged class, so you can just add an instance of the class to your form and call the appropriate method.

    http://www.vbforums.com/showthread.php?t=351757
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    Thanks JM
    :-)

  24. #24

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    Although it dosent really work when i try to get the toas form this comes up:
    Attached Images Attached Images  

  25. #25
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2005] Size Up ^^^^

    I would think not, you are naming a variable to the same name as a class type. Try naming a variable as Integer:

    Dim integer as integer

    This will also fail.

    You define the variable ToastForm, but what type is that?
    My usual boring signature: Nothing

  26. #26

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: [2005] Size Up ^^^^

    I don't know as i just copied and pasted it from here

  27. #27
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2005] Size Up ^^^^

    What's under that tooltip? I can see this much:

    Dim toastForm as

    Then the tooltip covers up the rest. There's certainly an error in that code. If toastForm was an actual type, two things would happen:

    1) Dim toastForm as would be an error, no matter what type it was.
    2) You would not be getting the error you are getting on the line you are getting it.
    My usual boring signature: Nothing

  28. #28
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2005] Size Up ^^^^

    I looked over that link, and I don't see quite the code you posted. Is that one of the downloads?
    My usual boring signature: Nothing

  29. #29
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] Size Up ^^^^

    If i understood this right, there should be a class named ToastForm. From what I can see it is not in your project. You should add it.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  30. #30
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Size Up ^^^^

    OK, my left eye is twitching. Did you read through the first post in that thread? It explains what the FormAnimator class is and it explains what the ToastForm class is. A code file for each class is attached to the post. If the ToastForm class isn't defined in your project then that means that you haven't downloaded the ToastForm code file and added it to your project.

    Apart from that, you shouldn't be using the ToastForm class anyway. It's a demo of how you can use the FormAnimator class. It's specifically designed as a form that will popup and back down just above the system tray. That's not what you want. You should be using just the FormAnimator class. Simply create an instance in your form and pass the appropriate values to the constructor for the effect you want, EXACTLY as I explained in that post.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width