The details window exists in the editor but will not open
· #1it doesnt work
the details window is right there
it doesnt work
the details window is right there
Does it fail at compile time or when you click something? Please paste the error and the line where the debugger stops. Seeing a form in the designer does not establish that an instance exists while the program runs.
Read the error message. Then read it again.
clicking the button stops at DetailsForm.Show
the exception line says
EAccessViolation: Access violationit worked before i took details out of auto create
That explains it. Your unit's global DetailsForm variable starts as nil. Removing the form from auto-create removed the constructor call, and declaring the variable did not replace it.
For a designer-made TDetailsForm, create an instance with TDetailsForm.Create, use it, then free it when its lifetime ends. Its normal constructor loads the form resource.
For comparison, this routine creates a blank temporary dialog without a form resource. Put it in an LCL unit with Forms in its uses clause:
procedure ShowBlankDetails;
var
Details: TForm;
begin
Details := TForm.CreateNew(nil);
try
Details.Caption := 'Details';
Details.ShowModal;
finally
Details.Free;
end;
end;The modal call returns when the dialog closes. That makes this lifetime suitable for try and finally. Do not substitute Show here, because it returns immediately and the form would then be freed immediately.
oh the picture of the window is not the window
i put it back in auto create and now it opens
oh the picture of the window is not the window
That distinction cost me a morning once. I had adjusted the caption three times while the program continued calling a nil reference with excellent spelling.
Keep the auto-created instance or create your own instance on demand. Doing both produces two windows and a very persuasive report about a button changing the wrong one.