Solved

# Raised 3D Effect for PictureBox

Posted on 2002-05-02
313 Views
Probably my final question for a while in this topic area...

For a PictureBox control, how can I give it a "raised" 3D effect? If you make it 3D instead of Flat for Appearance, it's always "sunken" into the form. There has to be an easy way to do this.
0
Question by:dplambert
• 3

LVL 22

Accepted Solution

rspahitz earned 50 total points
ID: 6986495
Try this:
1) add a picturebox named Picture1
2) set the picturebox borderstyle=none
3) add a line control INTO the picturebox, named Line1
4) set the line's index=0

Dim sglRightEdge As Single
Dim sglBottomEdge As Single

sglRightEdge = Picture1.ScaleWidth - Line1(0).BorderWidth - 10
sglBottomEdge = Picture1.ScaleHeight - Line1(0).BorderWidth - 10
' right edge
With Line1(0)
.X1 = sglRightEdge
.Y1 = 0
.X2 = sglRightEdge
.Y2 = sglBottomEdge
End With

' bottom edge
With Line1(1)
.X1 = 0
.Y1 = sglBottomEdge
.X2 = sglRightEdge
.Y2 = sglBottomEdge
.Visible = True
End With

' top edge
With Line1(2)
.X1 = 0
.Y1 = 0
.X2 = sglRightEdge
.Y2 = 0
.BorderColor = vbWhite
.Visible = True
End With

With Line1(3)
.X1 = 0
.Y1 = 0
.X2 = 0
.Y2 = sglBottomEdge
.BorderColor = vbWhite
.Visible = True
End With
End Sub
0

LVL 15

Expert Comment

ID: 6986882
It is also possible to use DrawEdge API in Paint event of the Form.  Let me know if you want code sample (uses DrawEdge, InflateRect, GetDC).
0

LVL 22

Expert Comment

ID: 6986992
Good point, Ameba.

This should work better (without the API):

Private Sub Form_Paint()
Picture1.Line (0, 0)-(Picture1.ScaleWidth, Picture1.ScaleHeight), vbWhite, B
Picture1.Line (-10, -10)-(Picture1.ScaleWidth - 10, Picture1.ScaleHeight - 10), vbBlack, B
End Sub

(Make sure that the picturebox has the autoredraw property set to True.)
0

LVL 3

Author Comment

ID: 6987478
Why isn't there a property setting for this? Something real simple?
0

LVL 22

Expert Comment

ID: 6987484
The reason is because it was not part of the original design.

If you want, you can simply create your own picturebox to support such a property by creating a new user control and adding more styles to the borderstyle setting...then you can call it a DPLPictureBox!
0

## Featured Post

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…