devxlogo

Make Controls Appear 3-D

Make Controls Appear 3-D

The latest trend in Windows programs is the use of a 3-D look thatmakes 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 professionaledition of VB 3.0. Adding more VBXs or DLLs to your program just to enhance your program’slook, however, may seem like overkill. The Apply3D routine shows how tomake a control such as a text box appear sunken or recessed. Apply3D worksby 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 controlthe appearance of being recessed. Note that the routine does not paintinside 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 whatthe 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 

devx-admin

Share the Post: