Problems overriding the OnDraw method on Controls
-
I'm attempting to make an application with a custom GUI. I have several reasons for doing this. I've looked at various documents, but found that this one seemed to be the most directed at what I wanted to do. Others just suggested removing Form borders and using Panels in creative ways to create a custom form. That's all well and good, and I'd actually figured that much out on my own. What I want to do is completely customize the look of the application. This is where things have gone wrong and I'm not sure what I'm doing wrong. I'm using an MDI Form to make sure that all windows stay within the parent form. I then removed all the menus and borders from the parent form, made the background black, and made the entire application full screen. I thought I had the drawing working for the Forms, but it turns out that I was still seeing the original Forms, just colored whatever color I specified. Not good. I need it to not draw the originals. That's the point of overriding, isn't it? Isn't that what that guide to creating custom graphics was about? I've tried everything I can think of. When I override the event on a custom text box like so...
protected override void OnPaint(PaintEventArgs e) { //base.OnPaint(e); e.Graphics.DrawLine(Pens.Black, new Point(Location.X, Location.Y + Size.Height), new Point(Location.X + Size.Width, Location.Y + Size.Height)); }
...I get the original text box control with a line drawn under it. I thought commenting out the call to base would make it stop displaying the box, but it doesn't. A similar call in a custom combo box that looks like this...
protected override void OnPaint(PaintEventArgs e) { Pen p = new Pen(new SolidBrush(Color.Brown)); Rectangle R = new Rectangle(Location, Size); Region Reg = new Region(R); e.Graphics.Clip = Reg; e.Graphics.Clear(p.Color); e.Graphics.FillRectangle(p.Brush, R); }
...yields no results at all. Absolutely nothing. You can see from this code that I've tried everything from blasting the graphics off the screen (Graphics.Clear) to trying to just draw over them (Graphics.FillRectangle). It's like there's something way back in the inheritance chain that is overruling me. Could that be it, or am I just forget