Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

How to get control clipping region?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Julie - 15 Apr 2005 18:26 GMT
How do you retrieve the visible clipping region for a control?

I have a control where I do some on-screen drawing (specifically
ControlPaint.DrawReversibleLine()), however I need to clip the line to the
visible bounds of my control.

Obviously, the client rect is simple enough to retrieve, but what I need to do
is to clip the line segment to only that portion of the control that is
visible, which may _not_ correspond to the client rect if there is some other
application window partially obscuring my control.

In my tests, Control.CreateGraphics().ClipBounds() is returning an 'infinite'
rectangle.

Anyone have any pointers on how to do what I want in .Net?
Bob Powell [MVP] - 15 Apr 2005 20:49 GMT
DrawReversibleLine is horrible because it draws on the desktop. If you can
do an alpha-blended selection as is recommended by GDI+ you also have much
better control over the clipping region.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> How do you retrieve the visible clipping region for a control?
>
[quoted text clipped - 11 lines]
>
> Anyone have any pointers on how to do what I want in .Net?
Julie - 15 Apr 2005 21:57 GMT
> DrawReversibleLine is horrible because it draws on the desktop. If you can
> do an alpha-blended selection as is recommended by GDI+ you also have much
> better control over the clipping region.

I ended up just disassembling DrawReversibleLine and (re)implementing the same
technique, drawing to the control's graphics port instead.  Works as needed.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.