Page 1 of 1

Events not triggered for UI loaded from DLL. Windows only.

Posted: Mon Jun 29, 2020 4:04 pm
by david_mtl
Hi everyone,

I'm using a DLL for sections of my UI that are reused in multiple apps. For example, I defined a custom dialog in the DLL for my options window. When I click a button in my app, the dialog pops up and everything works correctly.

In the DLL, I also define a class (MyCustomPanel) derived from wXPanels which contains a list and some buttons. When my app loads, an object of MyCustomPanel is instantiated and added to the main app just like any panels.

This works fine in linux, this piece of the UI is perfectly integrated with the main app and I can click on its component. The problem is with Windows, MyCustomPanel appears in the main app correctly but I can't interact with it at all. I can't click on the buttons, I can't tab to its component. It's there visually but there is no interaction with it. The other buttons from my app works correctly, it's a problem only with the components of MyCustomPanel.

So it seems the ui components of MyCustomPanel are not registered correctly with the main app to receive the events. The binding of the buttons is done using the function Connect() just like it's done in the main app. (Code generated from wxFormbuilder).

Any idea?

Re: Events not triggered for UI loaded from DLL. Windows only.

Posted: Mon Jun 29, 2020 4:16 pm
by doublemax
Are you using dynamic linking (=using DLLs) of wxWidgets under Windows, too? That's mandatory when both the main application and any DLL use wxWidgets.

Re: Events not triggered for UI loaded from DLL. Windows only.

Posted: Mon Jun 29, 2020 5:10 pm
by david_mtl
I am. I have 2 DLL that uses wxWidgets + my main app. In my main app, I can open a custom dialog defined in my DLL and it works correctly. The problem is only when the ui is integrated into the panel of the main app.

This is a screen shot of Dependency Walker. My app, "APP-LIMITESCYCLES" uses wxmsw313UD_GDD_CUSTOM.DLL like my 2 DLL LIBCEAMSWIP.DLL and LIBCEAMS.DLL
wxWidgetsDLL.PNG
DLL dependency of my app
wxWidgetsDLL.PNG (14.57 KiB) Viewed 186 times
I remember I had a problem with static linking at some point but it should have been fixed now. Is there something I could use to check that both my dll and my app is using the same instance of wxWidgets at run time?

Re: Events not triggered for UI loaded from DLL. Windows only.

Posted: Mon Jun 29, 2020 6:08 pm
by david_mtl
I found the problem.

The parent of the custom panel was set to the wxFrame of the app and not to its main wxPanel. I changed it and it's now working properly. For some reason, it wasn't a problem on Linux.