Subject | RE: [IBO] TIB_Edit Height Property |
---|---|
Author | Alan McDonald |
Post date | 2005-01-04T00:50:52Z |
> I'm trying to slim down some forms containing a few TIB_Edit controls. IReason:
> have set them to 15 instead of the default 19 (with no border, no
> bevel and
> no 3d look), and AutoSize to false, at design time they look fine but run
> them up and they pop back to 19 height.. there's not setting for height in
> the IB_Query so what can I do to keep their height down to my design?
> thanks
> Alan
>
I don't fiddle too much with fontmetrics but there is something wrong with
this code in IBC_Edit.IMP. If you set the hieght of an IB_Edit control to
e.g. 15 with BorderStyle bsNone and parentfont = False, when the control is
created, it pops back to font plus arbitrary margin which is not needed. But
if the Font remains as ParentFont, the set margin is obeyed and remains at
15.
I think this is a bug but a workaround is to set the IB_Edit controls to 15
at formcreate and it doesn;t change them again.
Alan
function TIB_CustomEdit.GetTextMargins: TPoint;
var
DC: HDC;
SaveFont: HFont;
I: Integer;
SysMetrics, Metrics: TTextMetric;
begin
if NewStyleControls then
begin
if BorderStyle = bsNone then
I := 0
else
if Ctl3D then
I := 1
else
I := 2;
Result.X := SendMessage(Handle, EM_GETMARGINS, 0, 0) and $0000FFFF + I;
Result.Y := I;
end
else
begin
if BorderStyle = bsNone then
I := 0
else
begin
DC := GetDC(0);
GetTextMetrics(DC, SysMetrics);
SaveFont := SelectObject(DC, Font.Handle);
GetTextMetrics(DC, Metrics);
SelectObject(DC, SaveFont);
ReleaseDC(0, DC);
I := SysMetrics.tmHeight;
if I > Metrics.tmHeight then
I := Metrics.tmHeight;
I := I div 4;
end;
Result.X := I;
Result.Y := I;
end;
end;