Hello everyone,
I draw a rectangle object and a text object. The text is in the middle of the rectangle. Both objects are grouped.
If I change the height of the rectangle the text will be larger than this frame. How can prevent this so that the text always stays within this frame?


with ImageEnVect1 do
begin
//Rectangle
ObjNo := AddNewObject;
ObjKind[ ObjNo ] := iekBOX;
ObjBrushStyle[ ObjNo ] := bsSolid;
ObjBrushColor[ ObjNo ] := clGreen;
ObjLeft[ ObjNo ] := X;
ObjTop [ ObjNo ] := Y;
//TextLabel
TextObj := AddNewObject;
ObjKind[ TextObj ] := iekTEXT;
ObjText[ TextObj ] := 'HW 103';
ObjTextAutoSize[ TextObj ] := false;
ObjTextAlign[ TextObj ] := iejCenter;
StretchTextRect( TextObj );
txtFont := FontDialog1.Font;
txtFont.Height := 0;
SetObjFont(TextObj,txtFont);
//TextLabel at box center
ObjLeft[ TextObj ] := Round(ObjLeft[ ObjNo ] + (ObjWidth[ ObjNo ] / 2) - (ObjWidth[ TextObj ] / 2));
ObjTop[ TextObj ] := Round(ObjTop[ ObjNo ] + (ObjHeight[ ObjNo ] / 2) - (ObjHeight[ TextObj ] / 2));
//GroupObjects
UnSelAllObjects;
AddSelObject( ObjNo );
AddSelObject( TextObj );
GroupObjects();
MouseInteractVt := [miObjectSelect];
end;
Regards,
Kostas