Form show and close in one button click - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Form show and close in one button click

Hello all,

I am a very new programmer. I have an image. I need to open a corresponding form on a mouse click and then if the user again clicks on the image the form needs to be closed. My code works for the first time it is opened and closed. But if i open again the form and then try to close it the second time , i get an error which says access violation, reading memory address 0x0000000.

if dxmdiFormA then begin
try
frmFormA.Close;
except
On E : Exception do
begin
ExceptionLog(E, Self);
dxmdiFormA := False;
end;
end;

end else begin

frmFormA := TfrmFormA.Create(nil, Huii);
dxmdiFormA := True;
end;

end;


the variable dxmdiFormA (boolean) is defined globally and set as false.

Can any one tell me what is wrong?

Thanks.
Sign In or Register to comment.