C ++: draw raster images in multiple instances using Firebreath

I'm fighting it

I want to draw a Bitmap in PluginWindowWin (Firebreath) using GDI +; for this, I have a timer simulating a wm_paint message, and this code inside:

using namespace Gdiplus; Graphics graphics(hwnd); graphics.DrawImage(image, 0, 0, 400, 400); 

image is Gdiplus :: Image , it works fine, BUT if I create 2 instances of the plugin (two different HWNDs), it will ONLY draw in one of them.

Is this the expected behavior ?, I mean that GDI + will draw in only one context created from HWND?

Thanks!

+4
source share
1 answer

In principle, each window (toplevel) should have its own stream. If you put any window in your own stream, you should be able to draw in parallel by sending a message to both windows / streams that have their own message manager.

Edit: Threading with shared GDI objects is a risky task. Resource management must be thread safe.

+1
source

Source: https://habr.com/ru/post/1391910/


All Articles