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.

Howdy, Stranger!

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

Categories