The details window exists in the editor but will not open

Go down

The details window exists in the editor but will not open

· #1

it doesnt work

the details window is right there

Re: The details window exists in the editor but will not open

· #2

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.

Re: The details window exists in the editor but will not open

· #3

clicking the button stops at DetailsForm.Show

the exception line says

text
EAccessViolation: Access violation

it worked before i took details out of auto create

Re: The details window exists in the editor but will not open

· #4

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:

pascal
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.

Re: The details window exists in the editor but will not open

· #5

oh the picture of the window is not the window

i put it back in auto create and now it opens

Re: The details window exists in the editor but will not open

· #6

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.

Re: The details window exists in the editor but will not open

· #7

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.

Go up

Sign in to reply