Wednesday, July 10, 2013

VB6 API - Menghilangkan Border TextBox, ListBox, etc.

Mengenai cara menghilangkan border object TextBox, ListBox, dan lain sebagainya.
Option Explicit 

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

Private Const WS_EX_CLIENTEDGE = &H200
Private Const GWL_EXSTYLE = (-20)

Private Sub RemoveBorder(ctl As Control)
Dim lStyle As Long
ctl.Appearance = 1
lStyle = GetWindowLong(ctl.hwnd, GWL_EXSTYLE)
lStyle = lStyle And Not WS_EX_CLIENTEDGE
SetWindowLong ctl.hwnd, GWL_EXSTYLE, lStyle
ctl.Appearance = 0
End Sub
Contoh penggunaan:
Private Sub Command1_Click() 
Call RemoveBorder(Text1)
End Sub