DrawDrop




' Label and Shape Styles

Global Const GFM_STANDARD = 0
Global Const GFM_RAISED = 1
Global Const GFM_SUNKEN = 2
' Control Shadow Styles

Global Const GFM_BACKSHADOW = 1
Global Const GFM_DROPSHADOW = 2
' Color constants

Global Const BOX_WHITE& = &HFFFFFF
Global Const BOX_LIGHTGRAY& = &HC0C0C0
Global Const BOX_DARKGRAY& = &H808080
Global Const BOX_BLACK& = &H0&
'Here is shadow routine:

Sub FormControlShadow (f As Form, C As Control, _
shadow_effect As Integer,
shadow_width As Integer, shadow_color As Long)
'This routine is used to create a Back or Drop shadow

'effect on any controls which are placed on a form.

'Simply place the control as normal and invoke the

'shadow with the code below.

'

' Parameters Type Comment

' f Form the form containing the control

' C Control the control to shadow

' shadow_effect integer GFM_DROPSHADOW or GFM_BACKSHADOW

' shadow_width integer width of the shadow in pixels

' shadow_color long color of the shadow

Dim shColor As Long
Dim shWidth As Integer
Dim oldWidth As Integer
Dim oldScale As Integer

shWidth = shadow_width
shColor = shadow_color
oldWidth = f.DrawWidth
oldScale = f.ScaleMode

f.ScaleMode = 3 'Pixels
f.DrawWidth = 1

Select Case shadow_effect
Case GFM_DROPSHADOW
f.Line (C.Left + shWidth, C.Top + shWidth)-Step(C.Width - 1, C.Height - 1),
shColor, BF
Case GFM_BACKSHADOW
f.Line (C.Left - shWidth, C.Top - shWidth)-Step(C.Width - 1, C.Height - 1),
shColor, BF
End Select

f.DrawWidth = oldWidth
f.ScaleMode = oldScale
End Sub

' Example:

' In the Form_Paint event:

FormControlShadow Me, Text1, GFM_DROPSHADOW, 2, QBColor(8)
How to draw a drop or back shadow on any control on a form.
Note:
This has only been tested with VB 3 & VB 4-16, if you convert
this for use with other versions please let me know.-Burt Abreu
Create A Back Or Drop Shadow On Controls
Declare these constants in a .BAS module










( drawdrop.html )- by Paolo Puglisi - Modifica del 17/12/2023