Re: Why must I paint the form background for an owner-draw control?
From: Mick Doherty (EXCHANGE#WITH_at_AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com)
Date: 10/08/04
- Next message: Tim Crews: "Re: Why must I paint the form background for an owner-draw control?"
- Previous message: Mick Doherty: "Re: Why must I paint the form background for an owner-draw control?"
- In reply to: Tim Crews: "Re: Why must I paint the form background for an owner-draw control?"
- Next in thread: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Why must I paint the form background for an owner-draw control?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 8 Oct 2004 17:50:38 +0100
I was just explaining why you get the Black Background in Button and not in
Control. There is no need to derive from Control, just set Opaque to false
in the constructor of your Button class.
You get the nasty button borders if you call the default OnPaint(). There is
no need to call it.
Inherit from Control if you don't need Button behaviour, otherwise Inherit
from Button and fix the problems as you encounter them.
My DrawParentBackground method was used mainly to show how to interrogate
the poperty of another control if that property exists. You don't need it.
What color should be used for the Background if you are using the BackColor
to change the buttonface?
See post above for solution.
-- Mick Doherty http://dotnetrix.co.uk/nothing.html "Tim Crews" <tim-junk@crews-family.org> wrote in message news:MPG.1bd06cd5d943e64a989686@news.cox.net... > In article <ObxDt$UrEHA.3416@TK2MSFTNGP15.phx.gbl>, > EXCHANGE#WITH@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com] says... >> His problem stems from the fact that the button base Class has >> ControlStyles.Opaque set to true by default so his setting it to true >> makes >> no difference. This problem does not appear in a class based upon Control >> because in a Control/UserControl ControlStyles.Opaque is false by >> default. >> This is the only modification that is necessary to cure the black >> background. >> > > Wouldn't it be easier just to change Opaque to false in my constructor, > rather > than choosing a different base class that defaults it to false? Maybe I'm > missing what you intended here. (I think Stoitcho recommended the > different > base class not only because of the Opaque property, but because I could > then > suppress some of the button adornments like 3d edges and focus > indicators.) If > I change the base class of my FancyButton to Control, of course I have > lots of > forms that _do_ expect FancyButton to have various Button-specific > properties > that are no longer available if I subclass it from Control. > >> OnPaintBackground() is called to draw the controls parent in any non >> opaque >> regions of the control. If the control is fully opaque then this method >> is >> not called, that is why there is a black background. >> > > But if I change the Button style to non-opaque, my black background > changes to > the background color of the Button, instead of the background of the > parent > form. > >> I have created a button derived from button and have not set the region >> of >> the control, doing so causes nasty jagged edges around curves. By not >> setting the region you can set the Graphics.SmoothingMode to High and see >> nice smooth edges around the button. >> > > But I think not setting the region is the reason that I get the Button's > background color instead of the form's background color around my button. > > So, as you say, the only other approach is to explicitly fill in the > entire > background area with the parent form's color or image (as you do in > DrawParentBackground in your example code) before drawing the button. And > this > gets me right back to my performance problem. > > I was unaware of the issue with nasty jagged edges around curves. I was > willing to try setting the region, but if the result is going to look > terrible, > I guess I will save myself the time I would have spent on this experiment. > > >> Without Doublebuffer, AllPaintingInWMPaint does not need to be set. >> > > Yes, I agree. I have removed it from my constructor. > >> > > Thank you again, everyone. > > Tim Crews > GECO, Inc. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
- Next message: Tim Crews: "Re: Why must I paint the form background for an owner-draw control?"
- Previous message: Mick Doherty: "Re: Why must I paint the form background for an owner-draw control?"
- In reply to: Tim Crews: "Re: Why must I paint the form background for an owner-draw control?"
- Next in thread: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Why must I paint the form background for an owner-draw control?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|