[fpc-devel] Parameters must match exactly?
Michael Van Canneyt
michael at freepascal.org
Mon May 17 11:50:52 CEST 2010
On Mon, 17 May 2010, Graeme Geldenhuys wrote:
> Hi,
>
> Sorry, I'm still battling with this. My original code looked as follows:
>
> procedure TfpgApplicationBase.CreateForm(AFormClass: TComponentClass; out
> AForm: TfpgWindowBase);
> begin
> try
> AForm := TfpgWindowBase(AFormClass.Create(self));
> if FMainForm = nil then
> FMainForm := AForm;
> except
> AForm := nil;
> raise;
> end;
> end;
>
>
> I then used that method as follows:
>
> var
> BulkDiscountListForm: TBulkInvoiceRateListForm;
>
> function DisplayMyForm: boolean:
> begin
> fpgApplication.CreateForm(TBulkInvoiceRateListForm,
> BulkDiscountListForm);
> try
> Result := BulkDiscountListForm.ShowModal = mrOK;
> if Result then
> // save data
> finally
> BulkDiscountListForm.Free;
> end;
> ...
> end;
>
>
> This doesn't work with FPC 2.5.1. I then removed the 'out' parameter type
> and my code compiled, but now it gives the following compiler warning all
> over the place for each form I create.
And correctly so, because you need the OUT: you are modifying the pointer
and need to pass back the modified pointer to the caller.
Michael.
More information about the fpc-devel
mailing list