wxWidgets under Windows and Dll's

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
Jolarha
In need of some credit
In need of some credit
Posts: 1
Joined: Tue Dec 03, 2019 8:35 am

wxWidgets under Windows and Dll's

Post by Jolarha »

Hi Folks!
I decided to use wxWidgets for my new application. The part I want to talk about here is to do graphics operations from a DLL on a wxWidgets Device Context (DC).

What I want to do is to load DLLs as plugins and they should draw on a DC. To tell it more easier: There is a function called Render() in the DLL this function gets a wxWidgets wxClientDC as a parameter. When this function is called it draws something in the DC.

I hope you understand what I mean and try to tell in my dodgy english

So, what happens is, that everything works fine sometimes but mostly everthing ends with a crash of the application. My question is, if it is a good idea what I do or if this calls for trouble. I mean, DLLs are as far as I know seperate processes and each process has its chunk of memory. If I pass a Device Context from the application to a DLL this Device Context belongs to the application and not to the DLL process. The DLL process is using memory of the application. Is that allowed?

As I said, I hope you understand what I mean despite of my lousy english.

Thanks
Todd
Last edited by Jolarha on Mon Dec 16, 2019 9:30 am, edited 1 time in total.
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets under Windows and Dll's

Post by doublemax »

In general i think that should work. If both the application and the DLL use wxWidgets, it's important that you link to wxWidgets dynamically, too. Same goes for the CRTs.

Are you doing that?
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxWidgets under Windows and Dll's

Post by PB »

Jolarha wrote: Tue Dec 03, 2019 12:00 pm DLLs are as far as I know seperate processes and each process has its chunk of memory.
I believe this is not true, at least not on MSW. AFAIK DLLs share the memory address space of the process that loaded them, otherwise one could not e.g. use any pointers with functions residing in DLLs, including the CRT (there is no marshalling involved).

Edit
https://docs.microsoft.com/en-us/window ... management
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets under Windows and Dll's

Post by ONEEYEMAN »

Hi,
Do you have a backtracve from the crash?
Also, what is your wx version and Windows version?

Thank you.
Post Reply