Reputation: 3238
Delphi XE6 - I am creating a COM based plugin for Excel using AddInExpress. Everything works up to this point. I have added a Ribbon Menu that the user can click to show specific information. I am wanting to show this in a component call HTMLPopup (by TMS Software). It is a popup form designed to show information based on HTML formatting. The component declaration is
HTMLPopup := THTMLPopup.Create(AOwner: TComponent);
My challenge is that I do not have (or can't figure out) what is an applicable owner. Since this is a LIBRARY/DLL, I don't have a form to "Own" this.
I have tried setting
HTMLPopup := THTMLPopup.Create(self); // Errors on compile, SELF undeclared
When I set owner to a datamodule, I get an AV at runtime.
I have tried setting
HTMLPopup :=THTMLPopup.Create(Application); //Again, error at runtime.
as well as ... HTMLPopup :=THTMLPopup.Create(nil); //Again, error at runtime.
The only workaround I have found it to create a form, but leave it hidden, then create my HTMLPopup with the owner being my hidden form. This appears to be kind of "kludgey". Is this the right way to do this?
Thanks
Upvotes: 0
Views: 1116
Reputation: 612934
Normally you would pass nil
as the owner which means the component will be unowned. This will mean that your code will be responsible for later calling Free
to destroy the component.
If your component cannot accept being unowned then I'm afraid that a hidden form, or similar, is probably the most expedient workaround.
You might consider contacting the vendor of the component to get support from them. After all, they know the component better than anybody. And perhaps the problem is nothing more than a simple bug in this control.
You could also avoid using a third party control and host a TWebBrowser
.
One thing that I guess you'll need to watch out for is how your popup's window owner is set. This is a different thing from the component owner. The window owner is known in Delphi terminology as the popup parent. A window is always shown above its owner. You'll want to make sure that an Excel window is the owner of your window.
Upvotes: 2