Results 1 to 4 of 4

Thread: small to big forms

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    small to big forms

    This is my aim: when a button is clicked, a form should should appear, but it should be really small and it should grow to a size of the screen, and then it should be slightly transparent (enough so u can read it but the form behind is visible).
    How can i do this?

    I know how to do the opacity bit. Thats no problem. Its making the screen grow from small to big.

  2. #2
    Member McBain2's Avatar
    Join Date
    Sep 2003
    Location
    UK, Glos.
    Posts
    60
    Something like this (using a Timer on the form).... ?
    VB Code:
    1. Imports System.Windows.Forms, System.Windows.Forms.SystemInformation
    2.  
    3. Public Class Form1
    4.    Inherits System.Windows.Forms.Form
    5.  
    6.    Const nSteps As Integer = 50
    7.    Private stepX As Integer = WorkingArea.Width \ (nSteps - 1)
    8.    Private stepY As Integer = WorkingArea.Height \ (nSteps - 1)
    9.  
    10.    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    11.       Timer1.Enabled = True
    12.    End Sub
    13.  
    14.    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    15.       Static counter As Integer
    16.       If counter < nSteps Then
    17.          Width += stepX
    18.          Height += stepY
    19.          Me.CenterToScreen()
    20.          counter += 1
    21.       Else
    22.          counter = Nothing
    23.          Timer1.Enabled = False
    24.          WindowState = FormWindowState.Maximized
    25.          Opacity = 0.75
    26.       End If
    27.    End Sub
    28.  
    29. End Class
    Needs some tweaking... but seems a bit slow for me, but with nSteps lower seems jerky. Prolly a better way of doing it but that's my 2 minute answer!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509
    Thats fine for me. I set the nsteps to 25 and its looks pretty good.
    I have a problem though. The components within the form stay at the same size. How can i make these grow aswell relevant to the screen size and my original size?

    I was thinking of just adding the components on after wards. Which would be teh best way of doing it: adding the components on afterwards or having the components grow?

    I tried a couple of things to make the components grow but it crashes.

  4. #4
    Member McBain2's Avatar
    Join Date
    Sep 2003
    Location
    UK, Glos.
    Posts
    60
    Add everything on afterwards!

    Trying to make all the controls on the form grow as well would require a lot of coding and probably slow things up quite badly.

    Clever use of panels and the dock & anchor properties may get you somewhere near the desired effect - but its a lot off effort for something that is unkiley to look that good.

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