1

I have a Managed Record named TEmail with a nested private class called TEmailForm that inherits from TForm. The idea is my email Record can create a modal form as needed for the user to type an email. I need the TEmailForm to have a reference to the TEmail Record that created it, so I overloaded the constructor for my nested EmailForm class like this:

constructor Create(AOwner: TComponent; EmailPnt: PEmail); reintroduce;

EmailPnt: PEmail is a pointer to the TEmail Record that created the form.

I then implemented my constructor like this:

constructor TEmail.EmailForm.Create(AOwner: TComponent; EmailPnt: PEmail);
begin
    inherited Create(AOwner);
    Email := EmailPnt;
end;

It compiles fine, but when I get to the line that says inherited Create(AOwner);, I get the following exception:

Project EmailTester.exe raised exception class EResNotFound with message 'Resource TEmail.TEmailForm not found'.

If I move the TEmailForm class outside of the TEmail Record so it is no longer a private nested class, everything works perfectly, but I don't want the TEmailForm exposed publicly when you use the Unit. What can I do here to get this to work?

6
  • Have you tried to replace inherited Create(AOwner) with inherited CreateNew(AOwner)? Commented Jun 27, 2024 at 20:03
  • @AndreasRejbrand CreateNew does not cause the Resource Not Found error; however, it loads an empty form because it doesn't use the associated DFM file I have for the email form. Commented Jun 27, 2024 at 20:17
  • 1
    Okay, it wasn't clear to me if you actually used a DFM or if you populated the form dynamically at run-time. Commented Jun 27, 2024 at 20:18
  • Have you tried putting the TEmailForm class definition in the implementation section? Or is that not practical? Commented Jun 27, 2024 at 22:06
  • Can you provide a minimal example for us to investigate? Commented Jun 28, 2024 at 8:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.