Set ClientRectangle for UserControl?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #1

    Set ClientRectangle for UserControl?

    I'm writing a container control, which has borders and a
    title bar. So the ClientRectangle should be different
    from Bounds. But how do I set ClientRectangle ?

    I see Panel does it. The origin for child controls is
    shifted. But I cannot find any info on how to do it.

    Thanks in advance. Waiting for solution...
  • 100

    #2
    Re: Set ClientRectangle for UserControl?

    Hi,
    Frankly I don't know how Panel does it but I'll try to give you some hints.
    1. You can override OnLayout (or catch Layout event) if you want to provide
    your own control arrangement logic.
    2. According to MSDN you can set the client size via ClientSize property,
    but you have to override SetClientSizeCo re as well. I haven't tried this,
    but anyway you cannot change the client size origin.
    3. In Windows setting the the client size location and size is done as a
    responce to WM_NCCALCSIZE. I won't be surprised if panel control process
    this message. So, take a look on WM_NCCALCSIZE message it might be exactly
    what you are after.

    HTH
    B\rgds
    100

    <qrli@hotmail.c om> wrote in message
    news:0dc301c38f 26$b691bf00$a10 1280a@phx.gbl.. .[color=blue]
    > I'm writing a container control, which has borders and a
    > title bar. So the ClientRectangle should be different
    > from Bounds. But how do I set ClientRectangle ?
    >
    > I see Panel does it. The origin for child controls is
    > shifted. But I cannot find any info on how to do it.
    >
    > Thanks in advance. Waiting for solution...[/color]


    Comment

    • Jay B. Harlow [MVP - Outlook]

      #3
      Re: Set ClientRectangle for UserControl?

      grli,
      I not sure how Panel does it, I suspect it an artifact of how the underlying
      Win32 control works. (I'm really not sure what the underlying Win32 control
      is).

      Have you looked into the overridable DisplayRectangl e property, as this is
      the property that identifies the usable client area, as opposed the physical
      client area.

      For example on the GroupBox control, DisplayRectangl e is smaller than
      ClientRectangle .

      Hope this helps
      Jay

      <qrli@hotmail.c om> wrote in message
      news:0dc301c38f 26$b691bf00$a10 1280a@phx.gbl.. .[color=blue]
      > I'm writing a container control, which has borders and a
      > title bar. So the ClientRectangle should be different
      > from Bounds. But how do I set ClientRectangle ?
      >
      > I see Panel does it. The origin for child controls is
      > shifted. But I cannot find any info on how to do it.
      >
      > Thanks in advance. Waiting for solution...[/color]


      Comment

      • Guest's Avatar

        #4
        Re: Set ClientRectangle for UserControl?

        That helps. Thanks a lot.
        [color=blue]
        >-----Original Message-----
        >Hi,
        >Frankly I don't know how Panel does it but I'll try to[/color]
        give you some hints.[color=blue]
        >1. You can override OnLayout (or catch Layout event) if[/color]
        you want to provide[color=blue]
        >your own control arrangement logic.
        >2. According to MSDN you can set the client size via[/color]
        ClientSize property,[color=blue]
        >but you have to override SetClientSizeCo re as well. I[/color]
        haven't tried this,[color=blue]
        >but anyway you cannot change the client size origin.
        >3. In Windows setting the the client size location and[/color]
        size is done as a[color=blue]
        >responce to WM_NCCALCSIZE. I won't be surprised if panel[/color]
        control process[color=blue]
        >this message. So, take a look on WM_NCCALCSIZE message[/color]
        it might be exactly[color=blue]
        >what you are after.
        >
        >HTH
        >B\rgds
        >100
        >
        ><qrli@hotmail. com> wrote in message
        >news:0dc301c38 f26$b691bf00$a1 01280a@phx.gbl. ..[color=green]
        >> I'm writing a container control, which has borders and[/color][/color]
        a[color=blue][color=green]
        >> title bar. So the ClientRectangle should be different
        >> from Bounds. But how do I set ClientRectangle ?
        >>
        >> I see Panel does it. The origin for child controls is
        >> shifted. But I cannot find any info on how to do it.
        >>
        >> Thanks in advance. Waiting for solution...[/color]
        >
        >
        >.
        >[/color]

        Comment

        Working...