Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Embedded form question
Wed, Dec 3 2014 4:11 PMPermanent Link

Jim Gallagher

If I take the embedded form demo and add this to the resize event of the child form:

procedure TEmbeddedForm.EmbeddedFormResize(Sender: TObject);
begin
 DockButton.Left := EmbeddedForm.Width div 2;
end;

(or any reference to the form's width or height)

When I select a docking option that resizes the form I get an Application Error: "Unable to get property 'tcontrol_fwidth' of undefined or null reference    Line: 20640"

Is this as designed, or am I doing something wrong?  It seems to happen only with embedded forms.

-Jim
Wed, Dec 3 2014 5:40 PMPermanent Link

Raul

Team Elevate Team Elevate

On 12/3/2014 4:11 PM, Jim Gallagher wrote:
>   When I select a docking option that resizes the form I get an Application Error: "Unable to get property 'tcontrol_fwidth' of undefined or null reference    Line: 20640"
>
> Is this as designed, or am I doing something wrong?  It seems to happen only with embedded forms.

You're doing it wrong - EmbeddedForm is not initialized (it's nil) so
calling EmbeddedForm.Width results in the error.

if you look at how the forms are created then you'll see that each
embeddedform is created using local "TempForm" variable (makes sense
since we want to be able to create more than one) hence the locally
declared "EmbeddedForm" is never initialized.


What you want to do in this case is refer to the actual instance of the
form you're on so use this :

   DockButton.Left := self.Width div 2;

Raul
Wed, Dec 3 2014 10:05 PMPermanent Link

Jim Gallagher

Raul wrote:

>What you want to do in this case is refer to the actual instance of the
>form you're on so use this :
>    DockButton.Left := self.Width div 2;

You're right, of course.  I should have seen that.  Thanks for your help!

-Jim
Image