[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1004
  • Last Modified:

Draw border around Usercontrol

Hi all

I'm trying to draw a custom border around a usercontrol.

In the paint event I have this:

If Border = True Then
  UserControl.Line (1, 1)-(UserControl.ScaleWidth - 10, UserControl.ScaleHeight - 10), BorderColor, B
End If

But sometimes only top and left borders are displayed.

Anybody knows how to address the last visible pixel on x and y?


With kind regards


Ramses (x_terminat_or_3)
0
x_terminat_or_3
Asked:
x_terminat_or_3
1 Solution
 
Ryan ChongCommented:
just guess:

UserControl.Line (10, 10)-(UserControl.ScaleWidth + 10, UserControl.ScaleHeight + 10), BorderColor, B

?
0
 
x_terminat_or_3Author Commented:
Nope, that doesn't do it
0
 
_agj_Commented:
why not use .Left+.Width-10 and .Top+.Height-10
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
x_terminat_or_3Author Commented:
Stop the presses, I found what was going on

The border was partially hidden because of a label.  I've set the label's backstyle to transparent and that did the trick.

Stupid me!  


Thanks for your input
0
 
fds_fatboyCommented:
Just a little extra bit. Are you drawing 1 pixel in from the edge?

If so,instead of this:

  UserControl.Line (1, 1)-(UserControl.ScaleWidth - 10, UserControl.ScaleHeight - 10), BorderColor, B

It is better and safer to convert all coordinates to/from pixels like this:

  UserControl.Line (ScaleX(1, vbPixels, Scalemode) , ScaleY(1, vbPixels, Scalemode))-(UserControl.ScaleWidth - ScaleX(1, vbPixels, Scalemode), UserControl.ScaleHeight - ScaleY(1, vbPixels, Scalemode)), BorderColor, B

0
 
x_terminat_or_3Author Commented:
Thanks this is excatly what I needed
0
 
fds_fatboyCommented:
Happy to help - and unexpected points too.
0
 
x_terminat_or_3Author Commented:
I've given them since it was the exact answer to the question

"Anybody knows how to address the last visible pixel on x and y?"


With kind regards



Ramses (x_terminat_or_3)
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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