Open and close a Form lazarus / 9-Editor ---------------------------------------------------------------------- ironman_br · 2006-04-11 17:24 I´m tryng to do this, but don´t work How I can do this? procedure TJPrincipal.CheckBoxAQEextraChange(Sender: TObject); var   FormAQEOptions: TFormAQEOptions; begin   {FormAQEOptions := TFormAQEOptions.Create(self);   If (CheckBoxAQEextra.Checked = True) then      FormAQEOptions.Visible := True else      begin         FormAQEOptions.Visible := False;         FormAQEOptions.Close;         FormAQEOptions.Release;         Label4.Caption := ':P';      end;           } end; ---------------------------------------------------------------------- johnf · 2006-04-11 18:22 It look like you are trying to open a form.  You have to 'show' the form. John ---------------------------------------------------------------------- ironman_br · 2006-04-11 18:38 How I cad do It Right? i tryed: procedure TJPrincipal.CheckBoxAQEExtrachangeClick(Sender: TObject); var FormAQEOptions: TFormAQEOptions; begin      FormAQEOptions := TFormAQEOptions.Create(self);      If (CheckBoxAQEextra.Checked = True) then      FormAQEOptions.Show else      begin           FormAQEOptions.Hide;           FormAQEOptions.Destroy;      end; end; He show the form, but don´t hide ;P ---------------------------------------------------------------------- Anonymous · 2006-04-11 19:17 Hi Friend. For destroy the form try this code in the event OnClose procedure TFormAQEOptions.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin    CloseAction:=caFree; // This constant Destroy the form end;                             // if you wish view can create again Regards. ---------------------------------------------------------------------- matthijs · 2006-04-12 06:05 It looks like the form only needs to be created and shown if the checkbox is true. So I would do this in the following way: Code: [Select] var   FormAQEOptions: TFormAQEOptions; procedure TJPrincipal.CheckBoxAQEExtrachangeClick(Sender: TObject); begin   If (CheckBoxAQEextra.Checked = True) then begin     if not Assigned(FormAQEOptions) then       FormAQEOptions := TFormAQEOptions.Create(self);     FormAQEOptions.Show;   end else begin     if Assigned(FormAQEOptions) then FormAQEOptions.Close;   end; end; Please check this code as I have no Lazarus at the moment to test it myself. But it will give the general idea of how to do this. Important is to put the var declaration out of the method for this to work correctly, because otherwise it will go out of scope when the procedure ends. This will make subsequent calls to this method fail.