Paint a control in 3d


Sub Ctl3d (ctrlTarget As Control)
    Dim CTop As Integer, CLeft As Integer, CRight As Integer, CBottom As Integer
    Dim PixelX As Integer, PixelY As Integer, AddX As Integer, AddY As Integer
    Dim i As Integer

COLOR_DARK_GRAY = QBColor(8)
COLOR_LIGHT_GRAY = QBColor(7)
COLOR_WHITE = QBColor(15)
bInset = True
nBevel = 1
nSpace = 0

    If InStr(UCase(ctrlTarget.Tag), "NO 3D") = 0 Then
        PixelX = screen.TwipsPerPixelX
        PixelY = screen.TwipsPerPixelY
        CTop = ctrlTarget.Top - PixelY
        CLeft = ctrlTarget.Left - PixelX
        CRight = ctrlTarget.Left + ctrlTarget.Width
        CBottom = ctrlTarget.Top + ctrlTarget.Height
        If bInset Then          ' Border in
            For i = nSpace To (nBevel + nSpace - 1)
                AddX = i * PixelX: AddY = i * PixelY
                ctrlTarget.Parent.Line (CLeft - AddX, CTop - AddY)-(CRight + AddX, CTop - AddY), COLOR_DARK_GRAY
                ctrlTarget.Parent.Line (CLeft - AddX, CTop - AddY)-(CLeft - AddX, CBottom + AddY), COLOR_DARK_GRAY
                ctrlTarget.Parent.Line (CLeft - AddX, CBottom + AddY)-(CRight + AddX + PixelX, CBottom + AddY), COLOR_WHITE
                ctrlTarget.Parent.Line (CRight + AddX, CTop - AddY)-(CRight + AddX, CBottom + AddY), COLOR_WHITE
            Next i
        Else                    ' Border ut
            For i = nSpace To (nBevel + nSpace - 1)
                AddX = i * PixelX: AddY = i * PixelY
                ctrlTarget.Parent.Line (CRight + AddX, CBottom + AddY)-(CRight + AddX, CTop - AddY), COLOR_DARK_GRAY
                ctrlTarget.Parent.Line (CRight + AddX, CBottom + AddY)-(CLeft - AddX, CBottom + AddY), COLOR_DARK_GRAY
                ctrlTarget.Parent.Line (CRight + AddX, CTop - AddY)-(CLeft - AddX - PixelX, CTop - AddY), COLOR_WHITE
                ctrlTarget.Parent.Line (CLeft - AddX, CBottom + AddY)-(CLeft - AddX, CTop - AddY), COLOR_WHITE
            Next i
        End If
    End If

End Sub



Mail to Daniel Wiman <daniel@wimania.com>
Online since June 1996, updated 980315
<- The VB home
<- Daniels homepage