Click here to Skip to main content
15,887,135 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Non-rectangular client area Pin
Nelek10-Oct-07 20:39
protectorNelek10-Oct-07 20:39 
AnswerRe: Non-rectangular client area Pin
eli1502197910-Oct-07 0:02
eli1502197910-Oct-07 0:02 
GeneralRe: Non-rectangular client area Pin
Nishad S10-Oct-07 0:10
Nishad S10-Oct-07 0:10 
AnswerRe: Non-rectangular client area Pin
Mark Salsbery10-Oct-07 6:14
Mark Salsbery10-Oct-07 6:14 
GeneralRe: Non-rectangular client area Pin
Nishad S10-Oct-07 17:45
Nishad S10-Oct-07 17:45 
AnswerRe: Non-rectangular client area Pin
David Crow11-Oct-07 2:58
David Crow11-Oct-07 2:58 
GeneralRe: Non-rectangular client area Pin
Nishad S11-Oct-07 18:48
Nishad S11-Oct-07 18:48 
AnswerRe: Non-rectangular client area [modified] Pin
rnendel1-Feb-10 6:06
rnendel1-Feb-10 6:06 
Yes, I just did it.   The concept is fairly easy to implement if you are managing your own custom container control ( which I'm fairly certain is what you are doing based on the thread ).

To implement this; however, you need to use only custom child controls or child controls that have OnPaint() overridden so that you can interject a clipping region prior to the child control being rendered.

1. In your custom container control, in the OnPaint() event, calculate the desired client area GraphicsPath.   Save that path as a public member for later use by chlid controls, let's name it 'ClientAreaPath' for fun.

2. For any control that can be added to your custom container, define the control as a custom control, or at least inherit and override the OnPaint() event.

3. In your child controls, in the OnPaint() override, determine if the control is a child of your custom container and, if so, then transform and apply the ClientAreaPath that was calculated and saved in step #1 above.   Viola - non-rectangular clipping Smile | :)

Here's a rough c# outline of the child control OnPaint() operations.

public override void OnPaint( PaintEventArgs e )
{
   // determine if this control is parented and if the parent can supply a ClientAreaPath
   try
   {
         // attempt to cast, will cause exception if nothing else
         MyCustomContainer parentContainer = ( MyCustomContainer )Parent;

         // get a copy of the custom client path
         GraphicsPath p = new GraphicsPath(parentContainer.ChildPath.PathPoints, parentContainer.ChildPath.PathTypes);

         // transfrom the path to be relative to the client (critical step here)
         // all paths are "zero-relative" so the client needs to see this path expressed
         // not as zero-relative, but client-location relative instead
         Matrix translateMatrix = new Matrix();
         translateMatrix.Translate(-(Location.X), -(Location.Y));
         p.Transform(translateMatrix);

         // now apply a nice clipping region to the control's graphics object so that
         // all subsequent render related operations will clip appropritely
         e.Graphics.SetClip( p );
   }
   catch( <bleh> )
   {
   }

   // ******* now render your control using whatever means you want, just make sure that
   // you do not reset the clipping path - if you need to clip additional client-relative
   // areas, use a clipping combine mode of compliment ( or whatever that option is )
}

Hope this helps Smile | :)    Of course, based on the date of the post ( 3 years ago ), probably not LOL.

modified on Monday, February 1, 2010 12:32 PM

GeneralRe: Non-rectangular client area Pin
Nishad S1-Feb-10 13:36
Nishad S1-Feb-10 13:36 
Questionrequest time out Pin
neha.agarwal279-Oct-07 22:20
neha.agarwal279-Oct-07 22:20 
AnswerRe: request time out Pin
Nelek9-Oct-07 22:24
protectorNelek9-Oct-07 22:24 
GeneralRe: request time out Pin
neha.agarwal2710-Oct-07 23:50
neha.agarwal2710-Oct-07 23:50 
GeneralRe: request time out Pin
Nelek29-Oct-07 22:15
protectorNelek29-Oct-07 22:15 
QuestionDLL Information Pin
Sunil Bhaskar9-Oct-07 21:56
Sunil Bhaskar9-Oct-07 21:56 
QuestionDesktop Changed Information Pin
ashishbhatt9-Oct-07 21:50
ashishbhatt9-Oct-07 21:50 
AnswerRe: Desktop Changed Information Pin
David Crow11-Oct-07 2:56
David Crow11-Oct-07 2:56 
QuestionWhy the type conversion is needed? Pin
LiYS9-Oct-07 21:37
LiYS9-Oct-07 21:37 
AnswerRe: Why the type conversion is needed? Pin
Cedric Moonen9-Oct-07 21:44
Cedric Moonen9-Oct-07 21:44 
GeneralRe: Why the type conversion is needed? Pin
LiYS9-Oct-07 22:06
LiYS9-Oct-07 22:06 
AnswerRe: Why the type conversion is needed? Pin
Naveen9-Oct-07 21:48
Naveen9-Oct-07 21:48 
GeneralRe: Why the type conversion is needed? Pin
LiYS9-Oct-07 22:06
LiYS9-Oct-07 22:06 
QuestionInternetFindNextFile function falis Pin
onlyjaypatel9-Oct-07 19:50
onlyjaypatel9-Oct-07 19:50 
QuestionRe: InternetFindNextFile function falis Pin
David Crow10-Oct-07 2:57
David Crow10-Oct-07 2:57 
AnswerRe: InternetFindNextFile function falis Pin
onlyjaypatel10-Oct-07 19:11
onlyjaypatel10-Oct-07 19:11 
GeneralRe: InternetFindNextFile function falis Pin
David Crow11-Oct-07 2:52
David Crow11-Oct-07 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.