Creating a visual plugin instance - Show event called twice

Hello,

When I create an instance of a Delphi visual plugin (C# host), I am finding that the OnShow event is called, then the OnActivate event, then the OnShow event is called again and then the OnActivate event is called once more…

I’ve tried to get to the bottom of this, I’m not sure but it might be something to do with the “ShowParented” procedure that gets called.

When I start the C# UI, I can see that the plugin is briefly flashing up as if it is a form, then it is later attached to the host panel.

Any ideas please?

Rob H

Any ideas please?

I can’t reproduce this with simple testcase. I’ve modified Mixed Mode\Delphi for Win32\UnmanagedPluginModule sample and added OnActivate and OnShow events. I see that only OnShow fired once.

can you create a simple sample that reproduces this case, pls?

It’s going to be difficult to do this, which is why I haven’t done so yet…

I have the following code:

I create the instance:
fCurrentPlugin = moduleManager1.CreateInstance§; <- form show is called here and if I pause the code I see it physically appear on top of the main screen

Then I host it
PluginControl.HostPlugin(fCurrentPlugin as IBasePlugin); <- form show also called here and I see it in the HostPanel

Am I doing the right thing above?

Regards,

Rob H

in the ManagedCSharpHost sample we do the same:

	// release previsuly loaded plugin 
	fCurrentPlugin = null;
	pnl_Host.UnhostPlugin();

	fCurrentPlugin = moduleManager1.CreateInstance(lb_Plugins.SelectedItem as PluginDescriptor);
	pnl_Host.HostPlugin(fCurrentPlugin as IBasePlugin);

	if (fCurrentPlugin is IHYCrossPlatformNonVisualPlugin)
		(fCurrentPlugin as IHYCrossPlatformNonVisualPlugin).Start();

Thanks - where would you expect the Show event to be called - after CreateInstance or on HostPlugin?

Mine is different in that it is a visual plugin too.

delphi Show event is called on HostPlugin

Thanks. After hours of scratching my head I have realised the problem.

My plugin (at design time) has its “Visible” property set to “true”. Set it to false and it just shows once.