Page 1 of 1

wxWidgets under Windows and Dll's

Posted: Tue Dec 03, 2019 12:00 pm
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

Re: wxWidgets under Windows and Dll's

Posted: Tue Dec 03, 2019 12:32 pm
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?

Re: wxWidgets under Windows and Dll's

Posted: Tue Dec 03, 2019 1:26 pm
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

Re: wxWidgets under Windows and Dll's

Posted: Wed Dec 04, 2019 1:47 pm
by ONEEYEMAN
Hi,
Do you have a backtracve from the crash?
Also, what is your wx version and Windows version?

Thank you.