Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 19, 1997

Make Controls Appear 3-D

The latest trend in Windows programs is the use of a 3-D look that makes windows and controls appear to be three-dimensional. As a result, a number of tools for adding the 3-D look to VB applications are available. One of the most popular is THREED.VBX, which ships with the professional edition of VB 3.0. Adding more VBXs or DLLs to your program just to enhance your program's look, however, may seem like overkill. The Apply3D routine shows how to make a control such as a text box appear sunken or recessed. Apply3D works by painting dark gray lines along the left and top sides of the control, and light gray lines along the bottom and right sides. This gives the control the appearance of being recessed. Note that the routine does not paint inside of the control.
 Sub Apply3D (myForm As Form, myCtl As Control) 
'Make specified control "sunken" 
'This routine assumes that the mapping mode 
'for myForm is 3-pixel 

myForm.CurrentX = myCtl.Left - 1 
myForm.CurrentY = myCtl.Top + myCtl.Height 
myForm.Line -Step(0, -(myCtl.Height + 1)), _ 
RGB(92, 92, 92) 
myForm.Line -Step(myCtl.Width + 1, 0), _ 
RGB(92, 92, 92) 
myForm.Line -Step(0, myCtl.Height + 1), _ 
RGB(255, 255, 255) 
myForm.Line -Step(-(myCtl.Width + 1), 0), _ 
RGB(255, 255, 255) 
End Sub 
You'll need to set the form's BackColor to gray (&H00C0C0C0&) and set the ScaleMode property to 3--Pixel. To use the Apply3D routine, call it from the form's Paint event. For example, this code shows what the Paint event would look like if you had two text boxes (Text1 and Text2) that you want to show in 3-D:
 Sub Form_Paint () 
Call Apply3D(Me, Text1) Call Apply3D(Me, Text2) 
End Sub 
Jonathan Wood
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date