PC Review


Reply
Thread Tools Rate Thread

Clip a child control

 
 
BradBrigade
Guest
Posts: n/a
 
      23rd Sep 2005
Hi, I created a control deriving from System.Windows.Forms.Control. In
my own OnPaint method, I can draw and set the clipping and everything
is perfect. But I also added some checkboxes by setting their parent
as my control, and I can seem to get them to clip. They just draw
themselves over anything that's under them, right up to the very edge
of the control. How do I get them to clip where I want? Do I set a
property in my control, set one of their properties, a property of the
Graphics object? I'm really confused here...

I'd appreciate any help or insight...

Thanks,
-Brad

 
Reply With Quote
 
 
 
 
Tim Wilson
Guest
Posts: n/a
 
      23rd Sep 2005
You should be able to use the "Region" property for this purpose.
http://msdn.microsoft.com/library/de...egiontopic.asp

--
Tim Wilson
..Net Compact Framework MVP

"BradBrigade" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, I created a control deriving from System.Windows.Forms.Control. In
> my own OnPaint method, I can draw and set the clipping and everything
> is perfect. But I also added some checkboxes by setting their parent
> as my control, and I can seem to get them to clip. They just draw
> themselves over anything that's under them, right up to the very edge
> of the control. How do I get them to clip where I want? Do I set a
> property in my control, set one of their properties, a property of the
> Graphics object? I'm really confused here...
>
> I'd appreciate any help or insight...
>
> Thanks,
> -Brad
>



 
Reply With Quote
 
BradBrigade
Guest
Posts: n/a
 
      23rd Sep 2005
Well, that seems to work globally, for the whole control, but I need to
be able to set different regions on different parts of the control. I
have scroll bars and if I reduce the region to where I want the
checkboxes confined, the scrollbars wont draw because they'll be
outside the region. I think the problem is I can draw my own graphics
fine, but as soon as OnPaint exits, all the scrollbars and checkboxes
draw and I don't have control over their clipping except globally with
Region. Is there a way to tell the child controls when to draw? Then
I could set the region, tell the checkboxes to draw, then increase the
region and tell the scrollbars to draw, then draw my own stuff. Is
that possible? What is the usual way to handle this situation?

Thanks,
-Brad

Tim Wilson UNDERSCORE AT PERIOD wrote:
> You should be able to use the "Region" property for this purpose.
> http://msdn.microsoft.com/library/de...egiontopic.asp
>
> --
> Tim Wilson
> .Net Compact Framework MVP


 
Reply With Quote
 
Tim Wilson
Guest
Posts: n/a
 
      24th Sep 2005
If you know the scrollbars are going to be there then you can take the
scrollbars into consideration when you paint, or size the child controls, by
using the "HorizontalScrollBarHeight" and "VerticalScrollBarWidth"
properties of the "SystemInformation" class.
http://msdn.microsoft.com/library/de...mberstopic.asp

You can assign a different region to each child control if that makes things
easier. If you need a complex region then you can create a "GraphicsPath"
object and then pass this object to one of the constructor overloads for the
"Region" class to create a region using the GraphicsPath.
http://msdn.microsoft.com/library/de...classtopic.asp

I think that you may need to use one of these techniques, or a combination
of both, to achieve what you're trying to do.

--
Tim Wilson
..Net Compact Framework MVP

"BradBrigade" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Well, that seems to work globally, for the whole control, but I need to
> be able to set different regions on different parts of the control. I
> have scroll bars and if I reduce the region to where I want the
> checkboxes confined, the scrollbars wont draw because they'll be
> outside the region. I think the problem is I can draw my own graphics
> fine, but as soon as OnPaint exits, all the scrollbars and checkboxes
> draw and I don't have control over their clipping except globally with
> Region. Is there a way to tell the child controls when to draw? Then
> I could set the region, tell the checkboxes to draw, then increase the
> region and tell the scrollbars to draw, then draw my own stuff. Is
> that possible? What is the usual way to handle this situation?
>
> Thanks,
> -Brad
>
> Tim Wilson UNDERSCORE AT PERIOD wrote:
> > You should be able to use the "Region" property for this purpose.
> >

http://msdn.microsoft.com/library/de...egiontopic.asp
> >
> > --
> > Tim Wilson
> > .Net Compact Framework MVP

>



 
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
clip child control Lloyd Dupont Microsoft Dot NET Framework Forms 0 25th Aug 2006 05:27 AM
How to clone container control (with child control inside it) like a group box harishashim@gmail.com Microsoft C# .NET 0 18th May 2006 03:59 AM
is there an event that fires when a child control is added to a parent container control (ie child panel added to a parent panel)? notu Microsoft Dot NET Compact Framework 1 19th Jul 2005 07:34 PM
Child control (in user control) regains focus when it is hidden! =?Utf-8?B?cmx0NjI0Ng==?= Microsoft Dot NET Framework Forms 0 14th Aug 2004 11:29 PM
Re: child form not clearing after control requery in parent control Bill Taylor Microsoft Access Form Coding 0 21st Apr 2004 06:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:56 PM.