Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-11

Does closing a form hide it or free it?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

vfclists .

I have a form I use as database dialog that looks up a list of databases to connect to and when I close the form I expect it to be closed via caHide so that I can reuse it with ShowModal later, but it seems to get destroyed because Screen.FindForm doesn't locate it. The CloseAction is set to caHide.

 if FDatabasesDialog = nil then
    FDatabasesDialog :=
TDatabasesForm(Screen.FindForm(TDatabasesForm.ClassName));
  if FDatabasesDialog = nil then
    FDatabasesDialog := TDatabasesForm.Create(Application);

Is there some fault with this code?

The only reason I can think if is that it could be down to a fault in the FindForm implementation as the Application object it still present.

It is running on a 1.5 series build on Debian Linux under Qt. I will try it elsewhere if there are some bugs there.

Frank Church ======================= http://devblog.brahmancreations.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161105/a89174fb/attachment.html>

Reply by email

vfclists .
to Mattias Gaertner

On 5 November 2016 at 14:06, Mattias Gaertner via Lazarus <

Show quoted text 15 lines
wrote: > if FDatabasesDialog = nil then > FDatabasesDialog := TDatabasesForm(Screen.FindForm(TDatabasesForm. ClassName)); FindForm finds a form by Name, not by ClassName. Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus-ide.org/listinfo/lazarus

FindForm depends on the ClassName, usuing
Screen.FindForm(TDatabasesForm.Name) gave the error:

Error: Only class methods, class properties and class variables can be referred with class references

Any way my use of the Screen.FindForm routine was wrong I had a FindForm routine of my own and I assumed that the built in one worked similarly. I think I switched to the built in because it handles DataModules where as mine worked on forms.

function FindForm(formClass: string):TForm;
var
  i: integer;
  upFormClass: string;
begin
  result := nil;
  upformClass := UpperCase(formClass);
  for i := 0 to Screen.FormCount-1 do
  begin
    if UpperCase(Screen.Forms[i].ClassName) = upFormClass then
    begin
      result := Screen.Forms[i];
    end;
 end;
end;
Frank Church ======================= http://devblog.brahmancreations.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20161106/014b026d/attachment.html>

Reply by email