• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

Raised 3D Effect for PictureBox

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
dplambert
Asked:
dplambert
  • 3
1 Solution
 
rspahitzCommented:
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
5) add this code where appropriate (I put it in form_load):

Private Sub Form_Load()
  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
  Load Line1(1)
  With Line1(1)
    .X1 = 0
    .Y1 = sglBottomEdge
    .X2 = sglRightEdge
    .Y2 = sglBottomEdge
    .Visible = True
  End With
 
  ' top edge
  Load Line1(2)
  With Line1(2)
    .X1 = 0
    .Y1 = 0
    .X2 = sglRightEdge
    .Y2 = 0
    .BorderColor = vbWhite
    .Visible = True
  End With
 
  Load Line1(3)
  With Line1(3)
    .X1 = 0
    .Y1 = 0
    .X2 = 0
    .Y2 = sglBottomEdge
    .BorderColor = vbWhite
    .Visible = True
  End With
End Sub
0
 
amebaCommented:
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
 
rspahitzCommented:
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
 
dplambertAuthor Commented:
Why isn't there a property setting for this? Something real simple?
0
 
rspahitzCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now