Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Raised 3D Effect for PictureBox

Posted on 2002-05-02
5
327 Views
Last Modified: 2008-02-01
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
Comment
Question by:dplambert
  • 3
5 Comments
 
LVL 22

Accepted Solution

by:
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
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
 
LVL 15

Expert Comment

by:ameba
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

by:rspahitz
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

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

Expert Comment

by:rspahitz
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Determine Range to Select 5 52
VBA/SQL - Connect to SQL server and pull data 4 118
How does CurrentUser work? 10 38
Visual Studio search word table and return Cell index 8 68
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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question