Set ClientRectangle for UserControl?

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...
 
1

100

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
 
J

Jay B. Harlow [MVP - Outlook]

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
 
G

Guest

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




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top