Solved

Draw border around Usercontrol

Posted on 2004-10-05
8
979 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
[X]
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
8 Comments
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 12224695
just guess:

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

?
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12225093
Nope, that doesn't do it
0
 
LVL 7

Expert Comment

by:_agj_
ID: 12225240
why not use .Left+.Width-10 and .Top+.Height-10
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12225254
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
 
LVL 10

Accepted Solution

by:
fds_fatboy earned 125 total points
ID: 12225289
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
ID: 12225301
Thanks this is excatly what I needed
0
 
LVL 10

Expert Comment

by:fds_fatboy
ID: 12225525
Happy to help - and unexpected points too.
0
 
LVL 2

Author Comment

by:x_terminat_or_3
ID: 12225537
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 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…

690 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