Exit or Close Button With Effect [VB 6.0]

Lesson 5 - How To make Exit / Close Button Vb v6.0

Today, We will create one component Close or Exit Form button / Programs.

In this tutorial, we will make the Button Exit / Close, so do not use the default form, Close, Maximize, minimize,

And also we will add a little effect on the form when the program at the Close / exit, will look like exploding.





Ok guys, this for the Tutorials, just Follow Step by Step,


STEP:
1. Component Needed :
   - Form1
   - One Button ( Button1 )
   - Coding + Module
   - or some component you can add ^_^

2.

FORM PROPERTIES :
   Border Style    = None

COMPONENT PROPERTIES :
   Button : - Caption = X
                - Font = Bold



 


CODING :

3. Double Click Form1, or Right Click > View Code.
   add this code into Form1:

Private Sub Command1_Click()
'Replace all the '500' below with the Speed of the Explode\Implode Effect.
Call ImplodeForm(Me, 500)
End
Set Form1 = Nothing
End Sub

Private Sub Form_Load()
Call ExplodeForm(Me, 500)
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call ImplodeForm(Me, 500)
End Sub


4. add Module ( Module1 )


Option Explicit

#If Win16 Then
Type RECT
Left As Integer
Top As Integer
Right As Integer
Bottom As Integer
End Type
#Else
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
#End If

#If Win16 Then
Declare Sub GetWindowRect Lib "User" (ByVal hwnd As Integer, lpRect As RECT)
Declare Function GetDC Lib "User" (ByVal hwnd As Integer) As Integer
Declare Function ReleaseDC Lib "User" (ByVal hwnd As Integer, ByVal hdc As _
Integer) As Integer
Declare Sub SetBkColor Lib "GDI" (ByVal hdc As Integer, ByVal crColor As Long)
Declare Sub Rectangle Lib "GDI" (ByVal hdc As Integer, ByVal X1 As Integer, _
ByVal Y1 As Integer, ByVal X2 As Integer, ByVal Y2 As Integer)
Declare Function CreateSolidBrush Lib "GDI" (ByVal crColor As Long) As Integer
Declare Function SelectObject Lib "GDI" (ByVal hdc As Integer, ByVal hObject _
As Integer) As Integer
Declare Sub DeleteObject Lib "GDI" (ByVal hObject As Integer)
#Else
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal _
hdc As Long) As Long
Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal _
crColor As Long) As Long
Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, _
ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Declare Function SelectObject Lib "user32" (ByVal hdc As Long, ByVal hObject _
As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
#End If

Sub ExplodeForm(f As Form, Movement As Integer)
Dim myRect As RECT
Dim formWidth%, formHeight%, i%, X%, Y%, Cx%, Cy%
Dim TheScreen As Long
Dim Brush As Long
GetWindowRect f.hwnd, myRect
formWidth = (myRect.Right - myRect.Left)
formHeight = myRect.Bottom - myRect.Top
TheScreen = GetDC(0)
Brush = CreateSolidBrush(f.BackColor)
For i = 1 To Movement
Cx = formWidth * (i / Movement)
Cy = formHeight * (i / Movement)
X = myRect.Left + (formWidth - Cx) / 2
Y = myRect.Top + (formHeight - Cy) / 2
Rectangle TheScreen, X, Y, X + Cx, Y + Cy
Next i
X = ReleaseDC(0, TheScreen)
DeleteObject (Brush)
End Sub

Public Sub ImplodeForm(f As Form, Movement As Integer)
Dim myRect As RECT
Dim formWidth%, formHeight%, i%, X%, Y%, Cx%, Cy%
Dim TheScreen As Long
Dim Brush As Long
GetWindowRect f.hwnd, myRect
formWidth = (myRect.Right - myRect.Left)
formHeight = myRect.Bottom - myRect.Top
TheScreen = GetDC(0)
Brush = CreateSolidBrush(f.BackColor)
For i = Movement To 1 Step -1
Cx = formWidth * (i / Movement)
Cy = formHeight * (i / Movement)
X = myRect.Left + (formWidth - Cx) / 2
Y = myRect.Top + (formHeight - Cy) / 2
Rectangle TheScreen, X, Y, X + Cx, Y + Cy
Next i
X = ReleaseDC(0, TheScreen)
DeleteObject (Brush)
End Sub


4. Hit F5 to Preview,
You are done,.. and you can add the information Project, and make the exe. files

5. Enjoy.




You can Download The Project Files,


File name :[VB6] L5-Exit_Close Button (VbRoom).rar
File Type : .rar [ .vbp]
Size :  119 Kb

You can Follow The Step By Watch Video ^_^

[ Uploaded :P ]



download note
Link download in a picture Download button.

     * You Will be redirected to the site adf.ly
     wait 5 seconds until there is written SKIP AD at the top right of your monitor.
     click > SKIP AD < to continue.


Thanks For Read and Visit, Best Wishes ................... DindaPhobia.
Good Job.


Tags : Exit, Close, Button, how to make Exit Button on VB, Visual Basic 6.0, cara membuat exit layout dengan Visual Basic 6.0, bagaimana membuat exit button dengan efek meledak, Visual basic 6.0, Source Code, kode exit dan close pada VB 6.0, Studio.



Related Post



0 comments:

Post a Comment

Enter Your Comment For This Post.
Please Do not SPAM!