Programming » Visual Basic 6 » Visual Basic 6 Code » Controls » ");?>
Give most controls a flatborder (a single pixel border).
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
        ByVal hWndInsertAfter As LongByVal x As LongByVal y As Long, _
        ByVal cx As LongByVal cy As LongByVal wFlags As LongAs Long

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
        (ByVal hwnd As LongByVal nIndex As LongByVal dwNewLong As LongAs Long

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
        (ByVal hwnd As LongByVal nIndex As LongAs Long

Private Const GWL_STYLE = (-16)
Private Const WS_THICKFRAME = &H40000
Private Const WS_BORDER = &H800000
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_WINDOWEDGE = &H100&
Private Const WS_EX_CLIENTEDGE = &H200&
Private Const WS_EX_STATICEDGE = &H20000

Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOOWNERZORDER = &H200
Private Const SWP_NOZORDER = &H4
Private Const SWP_FRAMECHANGED = &H20

Public Sub SetFlatBorder(hwnd As Long)
    SetWinStyle hwnd, GWL_STYLE, 0, WS_BORDER Or WS_THICKFRAME
    SetWinStyle hwnd, GWL_EXSTYLE, WS_EX_STATICEDGE, WS_EX_CLIENTEDGE Or _
            WS_EX_WINDOWEDGE
End Sub


Private Sub SetWinStyle(ByVal hwnd As LongByVal lType As Long, _
            ByVal lStyle As LongByVal lStyleNot As Long)
    Dim lS As Long
    Dim lhWnd As Long
    lhWnd = hwnd
    lS = GetWindowLong(lhWnd, lType)
    lS = lS And Not lStyleNot
    lS = lS Or lStyle
    SetWindowLong lhWnd, lType, lS
    SetWindowPos lhWnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or _
            SWP_NOOWNERZORDER Or SWP_NOZORDER Or SWP_FRAMECHANGED
End Sub