Often in making an application in Visual Basic environment, we have been presented with a shape similar to the display window. What if we want to create a form of display windows according to our tastes? Can, because this tutorial we will create a form window with the Titlebar, Minimize button, Maximize and Exit own style at once simple and very easy in manufacture. Can not wait? Then we go straight to the first step ie,
Make a form to design view the application window as shown in Figure 1. The added controls on the form are:- A fruit label- 5 pieces PictureBox
Make a form to design view the application window as shown in Figure 1. The added controls on the form are:- A fruit label- 5 pieces PictureBox
Change the properties of these controls is as indicated in Table 1.
Kontrol | Properti | Nilai |
Label1 | BackStyle | 0 - Transparent |
(Name) | lblTitle | |
Caption | Jendela buatanku | |
ForeColor | &H00FFFFFF& | |
Picture1 | BackColor | &H000080FF& |
BorderStyle | 0 - None | |
Width | 6735 | |
Height | 375 | |
(Name) | PicTitleBar | |
Picture2 | BackColor | &H00008000& |
BorderStyle | 0 - None | |
Width | 255 | |
Height | 255 | |
(Name) | PicMinimize | |
ToolTipText | Minimize | |
Picture3 | BackColor | &H00800000& |
BorderStyle | 0 - None | |
Width | 255 | |
Height | 255 | |
(Name) | PicMaximize | |
ToolTipText | Maximize | |
Picture4 | BackColor | &H00000080& |
BorderStyle | 0 - None | |
Width | 255 | |
Height | 255 | |
(Name) | PicExit | |
ToolTipText | Exit | |
Picture5 | BackColor | &H000080FF& |
BorderStyle | 0 - None | |
Width | 6735 | |
Height | 135 | |
(Name) | PicFootBar | |
Form1 | Caption | JENDELA BUATANKU |
BorderStyle | 0 - None | |
ShowInTaskbar | True | |
StartUpPosition | 2 - CenterScreen | |
Width | 6720 | |
Height | 4440 |
Tabel 1.
For details, the small colored boxes on the form each have different functions. Green boxes will be given a function Minimize the window, instead of blue boxes will we give Maximize window functions, and then a red box as a function to close the window or exit. As is generally the application window, the window must be easily removable parts usually started dragging the Titlebar.
So on PicTitleBar, we will enter a program code that can shift the window as shown in Listing 1. Now create a Module and then fill with the program code in Listing 2 to declare the functions needed to drag the window. Code found in Listing 3 courses for PicMinimize so when we click the green box, the display window in a minimized state. Now how to set the display to Maximize? The contents of the program code and PicTitleBar PicMaximize as shown in Listing 4.
To activate Maximize we need to set both width and height of the window or maximize under normal circumstances, such as in Listing 5. Measures are in Listing 5 is only valid if the window we make is on the monitor screen berresolusi 1024x768 pixels. Outside the resolution was the result of the display window will look messy. And if that happens, we can customize it by adjusting the width and height return values that we make the application window.
As the program code shown in Listing 5, we set the time window under normal circumstances, the tooltip on PicMaximize display the article "Maximize". Maximize the time display in the state, the tooltip displays the words "Restore Down". The last step, the PicExit we enter the program code which serves to close the application as shown in Listing 6. To be more interesting view, we can also import images on each PictureBox control. The next tutorial we will try memeberikan trasparan effect on the application window we make. Good luck!
So on PicTitleBar, we will enter a program code that can shift the window as shown in Listing 1. Now create a Module and then fill with the program code in Listing 2 to declare the functions needed to drag the window. Code found in Listing 3 courses for PicMinimize so when we click the green box, the display window in a minimized state. Now how to set the display to Maximize? The contents of the program code and PicTitleBar PicMaximize as shown in Listing 4.
To activate Maximize we need to set both width and height of the window or maximize under normal circumstances, such as in Listing 5. Measures are in Listing 5 is only valid if the window we make is on the monitor screen berresolusi 1024x768 pixels. Outside the resolution was the result of the display window will look messy. And if that happens, we can customize it by adjusting the width and height return values that we make the application window.
As the program code shown in Listing 5, we set the time window under normal circumstances, the tooltip on PicMaximize display the article "Maximize". Maximize the time display in the state, the tooltip displays the words "Restore Down". The last step, the PicExit we enter the program code which serves to close the application as shown in Listing 6. To be more interesting view, we can also import images on each PictureBox control. The next tutorial we will try memeberikan trasparan effect on the application window we make. Good luck!
Listing 1
CODE:
Listing 2
Private Sub PicTitleBar_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
‘Jika tampilan dalam keadaan Maximize, Jendela tidak akan pernah dapat digeser-geser
If Me.WindowState <> 2 Then
GeserJendela Me
End If
End Sub
CODE:
Listing 3
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lparam _
As Any) As Long
Declare Sub ReleaseCapture Lib "user32" ()
Public Sub GeserJendela(TheForm As Form)
ReleaseCapture
Call SendMessage(TheForm.hWnd, &HA1, 2, 0&)
End Sub
CODE:
Listing 4
Private Sub PicMinimize_Click()
Me.WindowState = 1
Me.PicMinimize.BackColor = &H8000&
End Sub
CODE:
Listing 5
Private Sub PicMaximize_Click()
AksiMaximize
Me.PicMaximize.BackColor = &H800000
End Sub
Private Sub PicTitleBar_DblClick()
AksiMaximize
End Sub
Private Sub lblTitle_DblClick()
AksiMaximize
End Sub
Private Sub lblTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
geser
End Sub
CODE:
Listing 6
Sub AksiMaximize()
If Me.WindowState = 2 Then
Me.WindowState = 0
Me.PicMinimize.Left = 5640
Me.PicMaximize.Left = 6000
Me.PicExit.Left = 6360
Me.PicMaximize.ToolTipText = "Maximize"
Me.PicFootBar.Top = 4320
Else
Me.WindowState = 2
Me.PicTitleBar.Width = 15400
Me.PicMinimize.Left = 14200
Me.PicMaximize.Left = 14600
Me.PicExit.Left = 15000
Me.PicMaximize.ToolTipText = "Restore Down"
Me.PicFootBar.Width = 16000
Me.PicFootBar.Top = 11400
End If
End Sub
CODE:
Listing 7
Private Sub PicTitleBar_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.PicExit.BackColor = &H80&
Me.PicMaximize.BackColor = &H800000
Me.PicMinimize.BackColor = &H8000&
End Sub
Private Sub PicMaximize_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.PicMaximize.BackColor = &HFF0000
End Sub
Private Sub PicMinimize_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.PicMinimize.BackColor = &HFF00&
End Sub
CODE:
Private Sub PicExit_Click()
End
End Sub
No comments:
Post a Comment