Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi experts,

I'm trying to give some buttons a nice look. In fact, I got the look from some designers as .png image and am now trying to get them to work on those buttons.

The images do not completely fill a rectangular space. Instead, the corners are left transparent.

I subclassed a button with new properties:


  • NormalBackgroundImage
  • MouseoverBackgroundImage
  • DepressedBackgroundImage


I also created a Windows Form with one such button on top and set the button's properties to:


  • Backcolor = Transparent
  • Flatstyle = Flat
  • Flatappearence.Bordersize = 0


Now the button seems invisible. This is by intention.
The button loads its images correctly, depending on mouse and pressed states.

But there is one thing I don't like nor understand yet: When the mouse pointer enters the button area, its outline is drawn in gray without respect to the underlying form's background colour.

That way, the button looks rectangular, instead of looking the way it's MouseoverBackgroundImage was designed.

I already tested the image for transparency. The corners lose their transparent look when the mouse is within the button's rectangle.

How can I fix this?
Posted
Updated 8-Oct-10 3:44am
v2
Comments
Toli Cuturicu 8-Oct-10 14:36pm    
Good question! You got my 5!

1 solution

Solved.

The whole image thing has nothing to do with the gray background colour. It's button-inherent. So I subclassed my own button from System.Drawing.Label and am happy with it.
 
Share this answer
 
Comments
Dalek Dave 11-Oct-10 6:54am    
Sometimes merely explaining the problem allows you to solve it.
This, apparently, was one of those times.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900