PC Review


Reply
Thread Tools Rate Thread

Why do buttons have a black outline?

 
 
seguso
Guest
Posts: n/a
 
      12th Jul 2007
Hello,

In my application, I am drawing some pushbuttons with
VisualStyleRenderer, but the buttons appear with a black outline.
Could someone please tell me why?

Here is a picture of the black outline:

http://picasaweb.google.com/maurizio...49187839415826

Additional informations:

I am using Visual Studio 2005. The code I am using to draw buttons is

Dim renderer_normal As VisualStyleRenderer
renderer_normal = New
VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)
[..]
renderer_normal.DrawBackground(gr, rect) ' gr is a Graphics object
and rect is a Rectangle

I am drawing on a backbuffer (double buffering). I am clearing the
backbuffer with white before drawing the buttons, but the black
outline appears nevertheless.

Also, when I draw disabled buttons, they don't have a black outline
(see picture).

Thanks for any help

Maurizio

 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      12th Jul 2007

"seguso" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> In my application, I am drawing some pushbuttons with
> VisualStyleRenderer, but the buttons appear with a black outline.
> Could someone please tell me why?


Maybe, because black is a neutral color and is more easy to see, by some
users.

>
> Also, when I draw disabled buttons, they don't have a black outline


Because that's an indication that the button is disabled, which again is a
neutral color of gray, so that it's easy to see by some users.

 
Reply With Quote
 
 
 
 
seguso
Guest
Posts: n/a
 
      12th Jul 2007
On 12 Lug, 13:33, "Mr. Arnold" <MR. (E-Mail Removed)> wrote:
> "seguso" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> > Hello,

>
> > In my application, I am drawing some pushbuttons with
> > VisualStyleRenderer, but the buttons appear with a black outline.
> > Could someone please tell me why?

>
> Maybe, because black is a neutral color and is more easy to see, by some
> users.


Then why do ordinary buttons in Windows Forms not have such an
outline?


> > Also, when I draw disabled buttons, they don't have a black outline

>
> Because that's an indication that the button is disabled, which again is a
> neutral color of gray, so that it's easy to see by some users.


So there is no way to remove the outline?

Thanks

Maurizio


 
Reply With Quote
 
Mick Doherty
Guest
Posts: n/a
 
      12th Jul 2007
Use the VisualStylesRenderers DrawParentBackground() method before the
DrawBackground() method.

Although if you are clearing with white before drawing the button, then you
should have a white border and not a black one.

Where do you get the Graphics Object from?

--
Mick Doherty
http://www.dotnetrix.co.uk/nothing.html


"seguso" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> In my application, I am drawing some pushbuttons with
> VisualStyleRenderer, but the buttons appear with a black outline.
> Could someone please tell me why?
>
> Here is a picture of the black outline:
>
>
> http://picasaweb.google.com/maurizio...49187839415826
>
> Additional informations:
>
> I am using Visual Studio 2005. The code I am using to draw buttons is
>
> Dim renderer_normal As VisualStyleRenderer
> renderer_normal = New
> VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)
> [..]
> renderer_normal.DrawBackground(gr, rect) ' gr is a Graphics object
> and rect is a Rectangle
>
> I am drawing on a backbuffer (double buffering). I am clearing the
> backbuffer with white before drawing the buttons, but the black
> outline appears nevertheless.
>
> Also, when I draw disabled buttons, they don't have a black outline
> (see picture).
>
> Thanks for any help
>
> Maurizio
>



 
Reply With Quote
 
seguso
Guest
Posts: n/a
 
      12th Jul 2007
On 12 Lug, 15:54, "Mick Doherty"
<EXCHANGE#(E-Mail Removed).[mdaudi100#ntlworld.com]>
wrote:
> Use the VisualStylesRenderers DrawParentBackground() method before the
> DrawBackground() method.


Interesting though, as you say, I am clearing with white.

> Where do you get the Graphics Object from?


Thank you very much Mick. Here is the relevant part of the code. I am
using double buffer. I am overriding onPaint and onPaintBackground().
I am leaving onPaintBackground empty, and I am doing all the drawing
in onPaint.


Private Sub drawMe()

_backBuffer = New Bitmap(Me.Width, Me.Height)

Dim gr As Graphics = Graphics.FromImage(_backBuffer)

Dim renderer_normal As VisualStyleRenderer
renderer_normal = New
VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)

' fill with white
gr.FillRectangle(New
SolidBrush(Color.FromKnownColor(KnownColor.White)), New Rectangle(0,
0, Me.Width, Me.Height))

' [..] set up the rectangle, etc.

renderer_normal.DrawBackground(gr, r)

' [..]

gr.Dispose()
Me.CreateGraphics.DrawImageUnscaled(_backBuffer, 0, 0)


End Sub


private _backBuffer as Bitmap

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
drawMe()

End Sub

Protected Overrides Sub OnPaintBackground(ByVal pevent As
System.Windows.Forms.PaintEventArgs)
' empty
End Sub


 
Reply With Quote
 
seguso
Guest
Posts: n/a
 
      12th Jul 2007
Never mind! I solved by using a newer technique for double buffering
(see below). Thank you very much!


private sub drawMe()

Dim currentContext As BufferedGraphicsContext
Dim myBuffer As BufferedGraphics

currentContext = BufferedGraphicsManager.Current
myBuffer = currentContext.Allocate(Me.CreateGraphics,
Me.DisplayRectangle)

Dim gr As Graphics
gr = myBuffer.Graphics

gr.FillRectangle(New
SolidBrush(Color.FromKnownColor(KnownColor.ControlLightLight)), New
Rectangle(0, 0, Me.Width, Me.Height))

Dim renderer_normal As VisualStyleRenderer
renderer_normal = New
VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)

renderer_normal.DrawBackground(gr, r_top)

myBuffer.Render()

end sub

 
Reply With Quote
 
pz pz
Guest
Posts: n/a
 
      1st Jan 2011
Change fore color propery of button and see outline of it


> On Thursday, July 12, 2007 6:11 AM seguso wrote:


> Hello,
>
> In my application, I am drawing some pushbuttons with
> VisualStyleRenderer, but the buttons appear with a black outline.
> Could someone please tell me why?
>
> Here is a picture of the black outline:
>
> http://picasaweb.google.com/maurizio...49187839415826
>
> Additional informations:
>
> I am using Visual Studio 2005. The code I am using to draw buttons is
>
> Dim renderer_normal As VisualStyleRenderer
> renderer_normal = New
> VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)
> [..]
> renderer_normal.DrawBackground(gr, rect) ' gr is a Graphics object
> and rect is a Rectangle
>
> I am drawing on a backbuffer (double buffering). I am clearing the
> backbuffer with white before drawing the buttons, but the black
> outline appears nevertheless.
>
> Also, when I draw disabled buttons, they don't have a black outline
> (see picture).
>
> Thanks for any help
>
> Maurizio



>> On Thursday, July 12, 2007 7:33 AM Mr. Arnold wrote:


>> "seguso" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>
>> Maybe, because black is a neutral color and is more easy to see, by some
>> users.
>>
>>
>> Because that's an indication that the button is disabled, which again is a
>> neutral color of gray, so that it's easy to see by some users.



>>> On Thursday, July 12, 2007 8:30 AM seguso wrote:


>>> Then why do ordinary buttons in Windows Forms not have such an
>>> outline?
>>>
>>>
>>>
>>> So there is no way to remove the outline?
>>>
>>> Thanks
>>>
>>> Maurizio



>>>> On Thursday, July 12, 2007 9:54 AM Mick Doherty wrote:


>>>> Use the VisualStylesRenderers DrawParentBackground() method before the
>>>> DrawBackground() method.
>>>>
>>>> Although if you are clearing with white before drawing the button, then you
>>>> should have a white border and not a black one.
>>>>
>>>> Where do you get the Graphics Object from?
>>>>
>>>> --
>>>> Mick Doherty
>>>> http://www.dotnetrix.co.uk/nothing.html
>>>>
>>>>
>>>> "seguso" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...



>>>>> On Thursday, July 12, 2007 10:07 AM seguso wrote:


>>>>> On 12 Lug, 15:54, "Mick Doherty"
>>>>> <EXCHANGE#(E-Mail Removed).[mdaudi100#ntlworld.com]>
>>>>> wrote:
>>>>>
>>>>> Interesting though, as you say, I am clearing with white.
>>>>>
>>>>>
>>>>> Thank you very much Mick. Here is the relevant part of the code. I am
>>>>> using double buffer. I am overriding onPaint and onPaintBackground().
>>>>> I am leaving onPaintBackground empty, and I am doing all the drawing
>>>>> in onPaint.
>>>>>
>>>>>
>>>>> Private Sub drawMe()
>>>>>
>>>>> _backBuffer = New Bitmap(Me.Width, Me.Height)
>>>>>
>>>>> Dim gr As Graphics = Graphics.FromImage(_backBuffer)
>>>>>
>>>>> Dim renderer_normal As VisualStyleRenderer
>>>>> renderer_normal = New
>>>>> VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)
>>>>>
>>>>> ' fill with white
>>>>> gr.FillRectangle(New
>>>>> SolidBrush(Color.FromKnownColor(KnownColor.White)), New Rectangle(0,
>>>>> 0, Me.Width, Me.Height))
>>>>>
>>>>> ' [..] set up the rectangle, etc.
>>>>>
>>>>> renderer_normal.DrawBackground(gr, r)
>>>>>
>>>>> ' [..]
>>>>>
>>>>> gr.Dispose()
>>>>> Me.CreateGraphics.DrawImageUnscaled(_backBuffer, 0, 0)
>>>>>
>>>>>
>>>>> End Sub
>>>>>
>>>>>
>>>>> private _backBuffer as Bitmap
>>>>>
>>>>> Protected Overrides Sub OnPaint(ByVal e As
>>>>> System.Windows.Forms.PaintEventArgs)
>>>>> drawMe()
>>>>>
>>>>> End Sub
>>>>>
>>>>> Protected Overrides Sub OnPaintBackground(ByVal pevent As
>>>>> System.Windows.Forms.PaintEventArgs)
>>>>> ' empty
>>>>> End Sub



>>>>>> On Thursday, July 12, 2007 10:41 AM seguso wrote:


>>>>>> Never mind! I solved by using a newer technique for double buffering
>>>>>> (see below). Thank you very much!
>>>>>>
>>>>>>
>>>>>> private sub drawMe()
>>>>>>
>>>>>> Dim currentContext As BufferedGraphicsContext
>>>>>> Dim myBuffer As BufferedGraphics
>>>>>>
>>>>>> currentContext = BufferedGraphicsManager.Current
>>>>>> myBuffer = currentContext.Allocate(Me.CreateGraphics,
>>>>>> Me.DisplayRectangle)
>>>>>>
>>>>>> Dim gr As Graphics
>>>>>> gr = myBuffer.Graphics
>>>>>>
>>>>>> gr.FillRectangle(New
>>>>>> SolidBrush(Color.FromKnownColor(KnownColor.ControlLightLight)), New
>>>>>> Rectangle(0, 0, Me.Width, Me.Height))
>>>>>>
>>>>>> Dim renderer_normal As VisualStyleRenderer
>>>>>> renderer_normal = New
>>>>>> VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)
>>>>>>
>>>>>> renderer_normal.DrawBackground(gr, r_top)
>>>>>>
>>>>>> myBuffer.Render()
>>>>>>
>>>>>> end sub



>>>>>> Submitted via EggHeadCafe
>>>>>> Microsoft SQL Server DBA For Beginners
>>>>>> http://www.eggheadcafe.com/training-...erver-DBA.aspx

 
Reply With Quote
 
pz pz
Guest
Posts: n/a
 
      1st Jan 2011
Change fore color property of button and see outline of button

> On Thursday, July 12, 2007 6:11 AM seguso wrote:


> Hello,
>
> In my application, I am drawing some pushbuttons with
> VisualStyleRenderer, but the buttons appear with a black outline.
> Could someone please tell me why?
>
> Here is a picture of the black outline:
>
> http://picasaweb.google.com/maurizio...49187839415826
>
> Additional informations:
>
> I am using Visual Studio 2005. The code I am using to draw buttons is
>
> Dim renderer_normal As VisualStyleRenderer
> renderer_normal = New
> VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)
> [..]
> renderer_normal.DrawBackground(gr, rect) ' gr is a Graphics object
> and rect is a Rectangle
>
> I am drawing on a backbuffer (double buffering). I am clearing the
> backbuffer with white before drawing the buttons, but the black
> outline appears nevertheless.
>
> Also, when I draw disabled buttons, they don't have a black outline
> (see picture).
>
> Thanks for any help
>
> Maurizio



>> On Thursday, July 12, 2007 7:33 AM Mr. Arnold wrote:


>> "seguso" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>
>> Maybe, because black is a neutral color and is more easy to see, by some
>> users.
>>
>>
>> Because that's an indication that the button is disabled, which again is a
>> neutral color of gray, so that it's easy to see by some users.



>>> On Thursday, July 12, 2007 8:30 AM seguso wrote:


>>> Then why do ordinary buttons in Windows Forms not have such an
>>> outline?
>>>
>>>
>>>
>>> So there is no way to remove the outline?
>>>
>>> Thanks
>>>
>>> Maurizio



>>>> On Thursday, July 12, 2007 9:54 AM Mick Doherty wrote:


>>>> Use the VisualStylesRenderers DrawParentBackground() method before the
>>>> DrawBackground() method.
>>>>
>>>> Although if you are clearing with white before drawing the button, then you
>>>> should have a white border and not a black one.
>>>>
>>>> Where do you get the Graphics Object from?
>>>>
>>>> --
>>>> Mick Doherty
>>>> http://www.dotnetrix.co.uk/nothing.html
>>>>
>>>>
>>>> "seguso" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...



>>>>> On Thursday, July 12, 2007 10:07 AM seguso wrote:


>>>>> On 12 Lug, 15:54, "Mick Doherty"
>>>>> <EXCHANGE#(E-Mail Removed).[mdaudi100#ntlworld.com]>
>>>>> wrote:
>>>>>
>>>>> Interesting though, as you say, I am clearing with white.
>>>>>
>>>>>
>>>>> Thank you very much Mick. Here is the relevant part of the code. I am
>>>>> using double buffer. I am overriding onPaint and onPaintBackground().
>>>>> I am leaving onPaintBackground empty, and I am doing all the drawing
>>>>> in onPaint.
>>>>>
>>>>>
>>>>> Private Sub drawMe()
>>>>>
>>>>> _backBuffer = New Bitmap(Me.Width, Me.Height)
>>>>>
>>>>> Dim gr As Graphics = Graphics.FromImage(_backBuffer)
>>>>>
>>>>> Dim renderer_normal As VisualStyleRenderer
>>>>> renderer_normal = New
>>>>> VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)
>>>>>
>>>>> ' fill with white
>>>>> gr.FillRectangle(New
>>>>> SolidBrush(Color.FromKnownColor(KnownColor.White)), New Rectangle(0,
>>>>> 0, Me.Width, Me.Height))
>>>>>
>>>>> ' [..] set up the rectangle, etc.
>>>>>
>>>>> renderer_normal.DrawBackground(gr, r)
>>>>>
>>>>> ' [..]
>>>>>
>>>>> gr.Dispose()
>>>>> Me.CreateGraphics.DrawImageUnscaled(_backBuffer, 0, 0)
>>>>>
>>>>>
>>>>> End Sub
>>>>>
>>>>>
>>>>> private _backBuffer as Bitmap
>>>>>
>>>>> Protected Overrides Sub OnPaint(ByVal e As
>>>>> System.Windows.Forms.PaintEventArgs)
>>>>> drawMe()
>>>>>
>>>>> End Sub
>>>>>
>>>>> Protected Overrides Sub OnPaintBackground(ByVal pevent As
>>>>> System.Windows.Forms.PaintEventArgs)
>>>>> ' empty
>>>>> End Sub



>>>>>> On Thursday, July 12, 2007 10:41 AM seguso wrote:


>>>>>> Never mind! I solved by using a newer technique for double buffering
>>>>>> (see below). Thank you very much!
>>>>>>
>>>>>>
>>>>>> private sub drawMe()
>>>>>>
>>>>>> Dim currentContext As BufferedGraphicsContext
>>>>>> Dim myBuffer As BufferedGraphics
>>>>>>
>>>>>> currentContext = BufferedGraphicsManager.Current
>>>>>> myBuffer = currentContext.Allocate(Me.CreateGraphics,
>>>>>> Me.DisplayRectangle)
>>>>>>
>>>>>> Dim gr As Graphics
>>>>>> gr = myBuffer.Graphics
>>>>>>
>>>>>> gr.FillRectangle(New
>>>>>> SolidBrush(Color.FromKnownColor(KnownColor.ControlLightLight)), New
>>>>>> Rectangle(0, 0, Me.Width, Me.Height))
>>>>>>
>>>>>> Dim renderer_normal As VisualStyleRenderer
>>>>>> renderer_normal = New
>>>>>> VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal)
>>>>>>
>>>>>> renderer_normal.DrawBackground(gr, r_top)
>>>>>>
>>>>>> myBuffer.Render()
>>>>>>
>>>>>> end sub



>>>>>>> On Saturday, January 01, 2011 3:34 AM pz pz wrote:


>>>>>>> Change fore color propery of button and see outline of it
>>>>>>>
>>>>>>>



>>>>>>> Submitted via EggHeadCafe
>>>>>>> Microsoft Silverlight For Beginners
>>>>>>> http://www.eggheadcafe.com/training-...lverlight.aspx

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Black is no longer black -- Why? The Hun Microsoft Outlook 4 23rd Feb 2009 04:48 AM
why why why why why Mr. SweatyFinger Microsoft ASP .NET 4 21st Dec 2006 02:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger Microsoft ASP .NET 2 2nd Dec 2006 04:46 PM
How do I make my black text single color black not 4 color black? =?Utf-8?B?TGFyYSBHbw==?= Microsoft Word Document Management 2 25th Aug 2006 07:01 PM
Buttons Buttons Buttons DaveB Microsoft Access Getting Started 1 21st Nov 2003 09:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:55 PM.