Set ClientRectangle for UserControl?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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...
 
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 SetClientSizeCore 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
 
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 DisplayRectangle property, as this is
the property that identifies the usable client area, as opposed the physical
client area.

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

Hope this helps
Jay
 
That helps. Thanks a lot.
-----Original Message-----
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 SetClientSizeCore 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




.
 
Back
Top