Solved

Draw border around Usercontrol

Posted on 2004-10-05
8
958 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 50

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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 …
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 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…

809 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