Solved

Draw border around Usercontrol

Posted on 2004-10-05
8
933 Views
Last Modified: 2012-06-27
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
Comment
Question by:x_terminat_or_3
8 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
just guess:

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

?
0
 
LVL 2

Author Comment

by:x_terminat_or_3
Comment Utility
Nope, that doesn't do it
0
 
LVL 7

Expert Comment

by:_agj_
Comment Utility
why not use .Left+.Width-10 and .Top+.Height-10
0
 
LVL 2

Author Comment

by:x_terminat_or_3
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Accepted Solution

by:
fds_fatboy earned 125 total points
Comment Utility
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
 
LVL 2

Author Comment

by:x_terminat_or_3
Comment Utility
Thanks this is excatly what I needed
0
 
LVL 10

Expert Comment

by:fds_fatboy
Comment Utility
Happy to help - and unexpected points too.
0
 
LVL 2

Author Comment

by:x_terminat_or_3
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now