Custom Search

fungsi form jadi flat  

Option Explicit
Const GWL_EXSTYLE = (-20)
Const WS_EX_CLIENTEDGE = &H200
Const WS_EX_STATICEDGE = &H20000
Const SWP_FRAMECHANGED = &H20
Const SWP_NOZORDER = &H4

Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40

Private Declare Sub SetWindowPos Lib "user32" (ByVal HWND As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As _
Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal HWND As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal HWND As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long


Public Sub FlatStyle(ByVal HWND As Long)
Dim oStyle As Long
oStyle = GetWindowLong(HWND, GWL_EXSTYLE)
oStyle = oStyle And Not WS_EX_CLIENTEDGE Or WS_EX_STATICEDGE
SetWindowLong HWND, GWL_EXSTYLE, oStyle
SetWindowPos HWND, 0, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOZORDER Or _
SWP_FRAMECHANGED Or SWP_NOSIZE Or SWP_NOMOVE
End Sub

Private Sub Form_Load()
'Sediakan beberapa objek spt (Picture1,List1,Text1,Command1, dll...)
'Panggil fungsi seperti ini dengan parameter HWND setiap objek

FlatStyle Form1.HWND
FlatStyle Command1.HWND
FlatStyle List1.HWND
FlatStyle Picture1.HWND
FlatStyle Text1.HWND

'apabila ingin otomatis untuk semua objek di form
'bisa pake fungsi berikut:

On Error Resume Next
Dim cc As Control
For Each cc In Me.Controls
FlatStyle cc.HWND
Next

'dsb....
'Gampang kan....selamat mencoba
End Sub

AddThis Social Bookmark Button
Email this post

1 komentar: to “ fungsi form jadi flat