Mega Code Archive

 
Categories / Delphi / Examples
 

Sizechildform

Below is some code [from Delphi@elsist.org] that may be useful re 'config' and 'sizing a form created in a DLL to the size of a "parent" form... QUESTION I got a problem while creating a Form stored in a DLL as child of a TWinControl in the main application. It works fine, but the Form created in the DLL doesn't fit the size of the TWinControl, though it's set to alClient. [NON-FUNCTIONAL CODE SNIPPET DELETED] ANSWER Override the SetBounds method and code something like the following (*----------------------------------------------------------------------------------*) procedure TfrmBaseForm.SetBounds(ALeft, ATop, AWidth, AHeight: Integer); var hWin : THandle; R : TRect; begin case FormMode of fmChild : begin if not HandleAllocated then Exit; hWin := GetParent(Self.Handle); if hWin = 0 then Exit; Windows.GetClientRect(hWin, R); inherited SetBounds(R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top); end; else inherited SetBounds(ALeft, ATop, AWidth, AHeight); end; end; Regards Theo ----------------------------------- Theo Bebekis Thessaloniki, Greece bebekis@otenet.gr