AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Shadow Control

Would you like to place shadows on your controls?
Would you like to give your forms a 3D appearance?
The here we go......

 

'coding starts here

Option Explicit

Public Sub Shadow(f As Form, c As Control, clr As Long)
'This SubRoutine draws a shadow below and to the
'the right of a control. It's quite a simple example
'of drawing in form !

'Example : Shadow Me,Text1,vbBlack

Const shWidth = 3 'Width of the shadow
Dim oldWidth As Integer 'Save old DrawWidth
Dim oldScale As Integer 'Save old ScaleMode

f.AutoRedraw = True 'optional, but otherwise
'shadow won't remain when form is repainted
'or call from the Form_Paint() sub


oldWidth = f.DrawWidth 'Remember current DrawWidth
oldScale = f.ScaleMode 'Remember current ScaleMode

f.ScaleMode = 3 'Set to pixel scaling
f.DrawWidth = 1 '1 pixel width lines

'Draws the shadow by drawing a box behind the control
f.Line (c.Left + shWidth, c.Top + shWidth)- _
Step(c.Width - 1, c.Height - 1), clr, BF


f.DrawWidth = oldWidth 'Restore old DrawWidth
f.ScaleMode = oldScale 'Restore old ScaleMode

End Sub

Private Sub Command1_Click()
End

End Sub


Private Sub Form_Load()
Shadow Me, Label1, vbBlack
Shadow Me, Text1, vbBlack
Shadow Me, Command1, vbBlack
Shadow Me, Command2, vbBlack
End Sub

'coding ends here


Download source coding here.

 
The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website