On Fri, 02 May 2008 08:22:39 -0700, <at*@mailinator.comwrote:
Hi,
Consider a custom control, say, MyControl that's being derived from
Control.
1. How am I supposed to set the initial size of MyControl? Am I
supposed to override the DefaultSize property?
Usually, the initial size of your control would be set in the Designer
when you drag it onto another form. But yes, if you want your control to
inherently have some specific default size, overriding DefaultSize is the
way to do that.
2. If so, the VisibleClipBounds of the control is not actually what
I've asked in the DefaultSize property, if the BorderStyle of
MyControl is set to FixedSingle or Fixed3D. i.e., if the DefaultSize
is set to "300, 100"; the actual size of the VisibleClipBounds in the
OnPaint method will be "296,96" which is obviously 4 pixels lower than
expected.
I haven't done much with custom bordered controls, but it seems pretty
clear to me that when the border is drawn within the boundary of the
control (as opposed to a window/form where the border is draw in the
"non-client" area), that the border will occupy part of the client area.
If you want your client area to be a full 300x100, you need to set the
size of the control a little larger to account for the border.
Pete