Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Non-rectangular client area

Non-rectangular client area

Scheduled Pinned Locked Moved C / C++ / MFC
question
14 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Nishad S

    Hi, Is it possible to make the client area of a window as non-rectangular? If yes how? Thanks in advance.

    - NS -

    E Offline
    E Offline
    eli15021979
    wrote on last edited by
    #4

    You can create a region using a bitmap. Here is one example :http://www.codeproject.com/dialog/cdialogsk.asp[^] Eli

    N 1 Reply Last reply
    0
    • E eli15021979

      You can create a region using a bitmap. Here is one example :http://www.codeproject.com/dialog/cdialogsk.asp[^] Eli

      N Offline
      N Offline
      Nishad S
      wrote on last edited by
      #5

      Sorry. This is not what I am looking for.

      - NS -

      1 Reply Last reply
      0
      • N Nishad S

        Thank you for the replay. But are you sure that it says about creating the client area as round? Or simply the window? Anyway I dont know Spanish :( But if you kindly send it I may try by using any translators :)

        - NS -

        N Offline
        N Offline
        Nelek
        wrote on last edited by
        #6

        Now that you say it... it is a round window (I read it too quick). So it problably won't be usefull at all. :^) But... it is a bit difficult to see the concept, if the window is not round... why to stablish a round client area? and an innocent try... have you thought about masking the squared client area with a user defined region and avoiding all what is outside the limits of the region?

        Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

        N 1 Reply Last reply
        0
        • N Nelek

          Now that you say it... it is a round window (I read it too quick). So it problably won't be usefull at all. :^) But... it is a bit difficult to see the concept, if the window is not round... why to stablish a round client area? and an innocent try... have you thought about masking the squared client area with a user defined region and avoiding all what is outside the limits of the region?

          Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

          N Offline
          N Offline
          Nishad S
          wrote on last edited by
          #7

          Let me say an example. Suppose my window has a round shape. And it has child controls. And my requirement is that, the border should be of a few pixels. So the childs should be clipped by the round client border if it is placed beyond the client. If only rectangular shape is possible for client, you can imagine what will be the problem. There will be non uniform border thickness, right?

          - NS -

          N 1 Reply Last reply
          0
          • N Nishad S

            Hi, Is it possible to make the client area of a window as non-rectangular? If yes how? Thanks in advance.

            - NS -

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #8

            The client area of a window is kind of an abstract concept. The WM_NCHITTEST message is used by the system to determine points in or outside of the client area. You can handle this message and adjust the return value appropriately. For drawing, you'll need to use clipping regions if necessary. Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            N 1 Reply Last reply
            0
            • M Mark Salsbery

              The client area of a window is kind of an abstract concept. The WM_NCHITTEST message is used by the system to determine points in or outside of the client area. You can handle this message and adjust the return value appropriately. For drawing, you'll need to use clipping regions if necessary. Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              N Offline
              N Offline
              Nishad S
              wrote on last edited by
              #9

              But what about the clipping of child controls by the client area?

              - NS -

              1 Reply Last reply
              0
              • N Nishad S

                Let me say an example. Suppose my window has a round shape. And it has child controls. And my requirement is that, the border should be of a few pixels. So the childs should be clipped by the round client border if it is placed beyond the client. If only rectangular shape is possible for client, you can imagine what will be the problem. There will be non uniform border thickness, right?

                - NS -

                N Offline
                N Offline
                Nelek
                wrote on last edited by
                #10

                Send me a pm to have your email and I will send you the document anyways, there may be some code that gives you an idea.

                Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

                1 Reply Last reply
                0
                • N Nishad S

                  Hi, Is it possible to make the client area of a window as non-rectangular? If yes how? Thanks in advance.

                  - NS -

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #11

                  See here.


                  "A good athlete is the result of a good and worthy opponent." - David Crow

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  N 1 Reply Last reply
                  0
                  • D David Crow

                    See here.


                    "A good athlete is the result of a good and worthy opponent." - David Crow

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    N Offline
                    N Offline
                    Nishad S
                    wrote on last edited by
                    #12

                    Thank you. But I could not found the solution for my doubt. I am not talking about the NcHitTest. But the actual client area, by which the child's visibility is clipped. AFAIK client are cannot be non-rectangular. :(

                    - NS -

                    1 Reply Last reply
                    0
                    • N Nishad S

                      Hi, Is it possible to make the client area of a window as non-rectangular? If yes how? Thanks in advance.

                      - NS -

                      R Offline
                      R Offline
                      rnendel
                      wrote on last edited by
                      #13

                      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 :-) 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          //

                      N 1 Reply Last reply
                      0
                      • R rnendel

                        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 :-) 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          //

                        N Offline
                        N Offline
                        Nishad S
                        wrote on last edited by
                        #14

                        rnendel wrote:

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

                        This solution was not applicable (at that time) I think... :)

                        - ns ami -

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups