Monday

Designing Your Own Display Applications in vb



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
Change the properties of these controls is as indicated in Table 1.

Kontrol
Properti
Nilai
Label1BackStyle0 - Transparent
(Name)lblTitle
CaptionJendela buatanku
ForeColor&H00FFFFFF&
Picture1BackColor&H000080FF&
BorderStyle0 - None
Width6735
Height375
(Name)PicTitleBar
Picture2BackColor&H00008000&
BorderStyle0 - None
Width255
Height255
(Name)PicMinimize
ToolTipTextMinimize
Picture3BackColor&H00800000&
BorderStyle0 - None
Width255
Height255
(Name)PicMaximize
ToolTipTextMaximize
Picture4BackColor&H00000080&
BorderStyle0 - None
Width255
Height255
(Name)PicExit
ToolTipTextExit
Picture5BackColor&H000080FF&
BorderStyle0 - None
Width6735
Height135
(Name)PicFootBar
Form1CaptionJENDELA BUATANKU
BorderStyle0 - None
ShowInTaskbarTrue
StartUpPosition2 - CenterScreen
Width6720
Height4440
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!

Listing 1

CODE:

  1. Private Sub PicTitleBar_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

  2. ‘Jika tampilan dalam keadaan Maximize, Jendela tidak akan pernah dapat digeser-geser

  3. If Me.WindowState <> 2 Then

  4. GeserJendela Me

  5. End If

  6. End Sub
Listing 2

CODE:

  1. Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _

  2. (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lparam _

  3. As Any) As Long

  4. Declare Sub ReleaseCapture Lib "user32" ()


  5. Public Sub GeserJendela(TheForm As Form)

  6. ReleaseCapture

  7. Call SendMessage(TheForm.hWnd, &HA1, 2, 0&)

  8. End Sub
Listing 3

CODE:

  1. Private Sub PicMinimize_Click()

  2. Me.WindowState = 1

  3. Me.PicMinimize.BackColor = &H8000&

  4. End Sub
Listing 4

CODE:

  1. Private Sub PicMaximize_Click()

  2. AksiMaximize

  3. Me.PicMaximize.BackColor = &H800000

  4. End Sub


  5. Private Sub PicTitleBar_DblClick()

  6. AksiMaximize

  7. End Sub


  8. Private Sub lblTitle_DblClick()

  9. AksiMaximize

  10. End Sub


  11. Private Sub lblTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

  12. geser

  13. End Sub
Listing 5

CODE:

  1. Sub AksiMaximize()

  2. If Me.WindowState = 2 Then

  3. Me.WindowState = 0

  4. Me.PicMinimize.Left = 5640

  5. Me.PicMaximize.Left = 6000

  6. Me.PicExit.Left = 6360

  7. Me.PicMaximize.ToolTipText = "Maximize"

  8. Me.PicFootBar.Top = 4320

  9. Else

  10. Me.WindowState = 2

  11. Me.PicTitleBar.Width = 15400

  12. Me.PicMinimize.Left = 14200

  13. Me.PicMaximize.Left = 14600

  14. Me.PicExit.Left = 15000

  15. Me.PicMaximize.ToolTipText = "Restore Down"

  16. Me.PicFootBar.Width = 16000

  17. Me.PicFootBar.Top = 11400

  18. End If

  19. End Sub
Listing 6

CODE:

  1. Private Sub PicTitleBar_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

  2. Me.PicExit.BackColor = &H80&

  3. Me.PicMaximize.BackColor = &H800000

  4. Me.PicMinimize.BackColor = &H8000&

  5. End Sub


  6. Private Sub PicMaximize_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

  7. Me.PicMaximize.BackColor = &HFF0000

  8. End Sub


  9. Private Sub PicMinimize_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

  10. Me.PicMinimize.BackColor = &HFF00&

  11. End Sub
Listing 7

CODE:

  1. Private Sub PicExit_Click()

  2. End

  3. End Sub

Sourch : dhinata.com

 

No comments:

Post a Comment

Related Posts with Thumbnails