wxWidgets in a plugin dll

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
User avatar
vouk
Knows some wx things
Knows some wx things
Posts: 25
Joined: Fri Feb 15, 2019 7:34 am
Location: Germany
Contact:

wxWidgets in a plugin dll

Post by vouk »

I am currently writing an open source (GPL) plugin dll for an adobe application on windows. I need to have some UI of course and would like to use wxWidgets 3.1.2 (static linked) for this. Currently I use MFC but it's a nightmare working with it and I'd like to have easy cross platform support in the future.

Building a classic application / executable is pretty easy, but how can I get it working inside a dll? I did take a look at the dll sample project already and it partially works. But then I could only access GUI components using the events. I was also not able to enable the visual styles. They were working in MFC dialogs but not in wxWidgets.

I would like to be free in choice where I use dialogs and notifications and everything. Is there a way to get it working?

My simplified code:

Code: Select all

extern "C" DllExport int thefunction(int action, void *param1, void *param2)
{
  Inst *inst = reinterpret_cast<Inst*>(param1);

  switch (action)
  {
    case STARTUP:
    {
      inst->plugin = new Plugin(1234);
      break;
    }
    case SHUTDOWN:
    {
      delete(inst->plugin);
      break;
    }
    case BTNACTION:
    {
      inst->plugin->someaction();
      break;
    }
  }
}

class Plugin
{
public:
  Plugin(int id);
  void someaction()
  {
      wxDialog *dlg = new wxDialog(...);
      dlg->Show();
  }
}
Thank you so much in advance.

Daniel
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7478
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets in a plugin dll

Post by ONEEYEMAN »

Hi,
Welcome to the wonderful wxWidgets world!

I think (I may be wrong though), you should use dynamic build of wx.
Other than that - what do you mean "access GUI components using events"? What else do you expect?
Also - what visual styles you are looking for? Keep in mind that it is possible to have a conditional compilation based on the OS.

And finally - there are example of how to build Adobe Plugin using wxWidgets on the web. I believe Vadim wrote one or referenced one notr that long ago.
Did you look?

Thank you.
User avatar
vouk
Knows some wx things
Knows some wx things
Posts: 25
Joined: Fri Feb 15, 2019 7:34 am
Location: Germany
Contact:

Re: wxWidgets in a plugin dll

Post by vouk »

I was searching the whole week for an example or a possible solution for it. What I basically want is a plugin class where I could simply execute wxWidgets code. I am aware that I need some kind of event loop running and everything. Creating and showing a wxDialog like in my example code simply doesn't work right?

I find it very difficult to search in this matter in google. When in I search for "wxWidgets in a dll application" I get mostly results dealing with wxWidgets dlls.

In the host application i have a button "configure video encoder ..." and once the user clicks i just want to do some wxWidgets magic.

The visual styles are are the common controls 6 styles. I added the resource file, tried adding the pragma... nothing worked. I get it working for MFC, but not for wxWidgets. But lets try to solve the first issue first.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets in a plugin dll

Post by doublemax »

The "dll" sample shows how to run the whole wxWidgets event loop in a separate thread. That's also the method used to create e.g. PhotoShop plugins with wxWidgets. Are you doing the same?
But then I could only access GUI components using the events.
It's still not clear to me what this means. Can you elaborate?
Use the source, Luke!
User avatar
vouk
Knows some wx things
Knows some wx things
Posts: 25
Joined: Fri Feb 15, 2019 7:34 am
Location: Germany
Contact:

Re: wxWidgets in a plugin dll

Post by vouk »

What I meant with it was like showing a frame or dialog with events like this (from the dll example project):

Code: Select all

// Send a message to wx thread to show a new frame:
wxThreadEvent *event = new wxThreadEvent(wxEVT_THREAD, CMD_SHOW_WINDOW);
event->SetString(title);
wxQueueEvent(wxApp::GetInstance(), event);
I found a better solution here: https://simon.rozman.si/computers/wxwid ... dll-plugin

This even solves my common-controls 6 issues as it is switching the activation context when necessary and does not run any additional threads.

Using wxWidgets is so pleasant compared to using MFC or even Win32.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7478
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets in a plugin dll

Post by ONEEYEMAN »

Hi,
Out of curiosity - are you using manifest?

Thank you.
User avatar
vouk
Knows some wx things
Knows some wx things
Posts: 25
Joined: Fri Feb 15, 2019 7:34 am
Location: Germany
Contact:

Re: wxWidgets in a plugin dll

Post by vouk »

I am using the pragma approach:

Code: Select all

#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
Post Reply