VB icon

*Improved* Cool Form Close

Email
Submitted on: 1/2/2015 7:14:00 AM
By: Jono Spiro (from psc cd)  
Level: Not Given
User Rating: By 4 Users
Compatibility: VB 5.0, VB 6.0
Views: 1848
 
     'This is a much improved version of the cool form close code submitted by Jas Batra. It shrinks the First of all, it is in function form, second it is a 'lot' faster and smoother. Code is fully documented for beginners.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :*Improved* Cool Form Close
'**************************************
'None
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: *Improved* Cool Form Close
' Description:'This is a much improved version of the cool form close code submitted by Jas Batra. It shrinks the First of all, it is in function form, second it is a 'lot' faster and smoother. Code is fully documented for beginners.
' By: Jono Spiro (from psc cd)
'
' Inputs:'Inputs are:
' coolCloseForm closeForm,speed
'closeform is the form to close
'speed is anything from 1 to about 100 or more...
'
' Returns:'Nothing
'
' Assumes:'Completely documented for beginners.
'
' Side Effects:'None so far, make sure that no data will be lost, because when this code runs, it unloads the form.
'**************************************

'If you want to try this code in action:
' make a new project and add a module
'double click on the form and add the following code:
Private Sub Form_Load()
 Form1.Height = 6400
 Form1.Width = 10000
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
 If Button = vbRightButton Then
 coolCloseForm Me, 20
 Else
 Dim a As New Form1
 a.Height = a.Height / 2
 a.Width = a.Width / 2
 a.Show
 End If
End Sub
'Then add the coolCloseForm code to the module
'Now run the program, left click a few times to add new forms to screen, and then right click on them to make them go away.
'END OF EXAMPLE CODE
'
'
'
'ALL CODE BELOW TO THE BOTTOM IS THE ACTUAL MODULE CODE, ABOVE CODE IS ALL OPTIONAL!!
'
Public Function coolCloseForm(closeForm As Form, speed As Integer)
 'make sure speed is more than 1
 If speed = 0 Then
 MsgBox "Speed cannot zero"
 Exit Function
 End If
 'closeform is the form to close
 'speed is anything from 1 to about 100
 On Error Resume Next
 'set the scalemode to twips so that the do statements will work
 closeForm.ScaleMode = 1
 'so the code wont crash
 closeForm.WindowState = 0
 'do until the height is the minimum possible
 Do Until closeForm.Height <= 405
 'let the computer process
 DoEvents
 'make the form shorter by the speed * 10
 closeForm.Height = closeForm.Height - speed * 10
 'make the top of the form lower by the speed * 5
 closeForm.Top = closeForm.Top + speed * 5
 Loop
 'do until the width is the minimum possible
 Do Until closeForm.Width <= 1680
 'let the computer process
 DoEvents
 'make the form less wide by the speed * 10
 closeForm.Width = closeForm.Width - speed * 10
 'make the left of the form farther to the righ by the speed * 5
 closeForm.Left = closeForm.Left + speed * 5
 Loop
 'when its all done, unload the form
 Unload closeForm
End Function


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.