Important alert: (current site time 7/16/2013 1:38:49 AM EDT)
 

VB icon

*Improved* Cool Form Close

Email
Submitted on: 5/25/1999
By: Jono Spiro  
Level: Not Given
User Rating: By 4 Users
Compatibility: VB 5.0, VB 6.0
Views: 22936
 
     '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!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' 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
'
' 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.
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1874&lngWId=1'for details.'**************************************

'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 10 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

2/26/2000 12:14:11 PMMike

another way to use this code without having forms pop-up whenever you left click just put this code in:(use the module that he gave)

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

End If
End Sub
(If this comment was disrespectful, please report it.)

 
4/14/2000 5:42:50 PMProgrammer411

What exactly does this code do? What is *Improved* Cool Form Close???
(If this comment was disrespectful, please report it.)

 
4/16/2000 11:48:21 AMtami

cool!!!!
(If this comment was disrespectful, please report it.)

 
9/23/2005 2:55:20 PMpot

this is really cool man, i wish there are a lot more coders out there like you; keep it up dud_!!!
(If this comment was disrespectful, please report it.)

 
6/16/2008 2:38:35 PMJustin

Seems like a okay .. code
(If this comment was disrespectful, please report it.)

 
12/3/2009 4:45:05 PMAveclown

great code but i have question.. if u try to hide ur form then call back again.. it can be a small size.
(If this comment was disrespectful, please report it.)

 

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.