3
votes

I have a huge MFC MDI application that draws on its scrollable view area using device context. This application uses a 3rd party library to do some additional drawing in the same view area. It works by passing the DC (Device Context) of the view area to this 3rd party library (dll) and then the DLL does the additional drawing which is pretty complex.

However, we are converting our whole application to 64 bit and the problem is that we do not have 64 bit version of this 3rd party library. Which leaves us with one option only and that is to move this 3rd party library to a separate process and then make out-of-process calls between our main Application and this new Process hosting this 3rd party library.

But now, how do we do cross-process drawing? Is there any way to do this stuff using plain GDI or MFC?

1
Take a look at using dllhost as a surrogate to access the 32bit DLL through COM. I haven't actually done this myself or I would make it an answer. I do know others that have used this approach and they've been happy with the results.Captain Obvlious

1 Answers

1
votes

This answer says that you can't just pass the HDC from one process to another.

What you might be able to do instead is to:

  1. issue GetDIBits on your DC to get the raw bitmap bits.
  2. move these to the 32-bit process by using some form of IPC.
  3. Use SetDIBits to put them in a memory DC in the other process.
  4. Allow your 3rd-party library to monkey with that DC.
  5. Do the same in reverse to get the bits back.

For IPC, I'd suggest simply mapping a chunk of shared memory into both processes. The performance will probably be pretty poor, but you should be able to get away with it.

I believe that Google Chrome does something similar to isolate the rendering engine from the individual tabs.