Friday, June 8, 2012

Effect Bayangan (Shadow) Pada Form Menggunakan VB6

Mengenai cara menambahkan effect bayangan (shadow effect) pada form - effect bayangan (shadow effect) ini akan terlihat bagus terutama pada form tanpa border (property BorderStyle = 0 - none). Bagaimana kode mengenai shadow effect ini?
Option Explicit 

Private Declare Function
GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function
SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const
CS_DROPSHADOW As Long = &H20000
Private Const GCL_STYLE As Long = -26

Private Sub
DropShadow(ByVal hWnd As Long)
Call SetClassLong(hWnd, GCL_STYLE, GetClassLong(hWnd, GCL_STYLE) Or CS_DROPSHADOW)
End Sub

Private Sub
Form_Load()
DropShadow Me.hWnd
End Sub

Catatan: Effect bayangan (shadow effect) akan bekerja pada saat Show shadow under menus dicheck (default). Show shadow under menus terdapat pada start >> Settings >> Control Panel >> System >> Advanced >> Settings >> Show shadow under menus.