C++:使用 Firebreath 在多个实例中绘制位图
我正在努力解决这个问题,
我想使用 GDI+ 将位图绘制到 PluginWindowWin (Firebreath) 中;为此,我有一个计时器,暂时模拟 wm_paint 消息,其中的代码:
using namespace Gdiplus;
Graphics graphics(hwnd);
graphics.DrawImage(image, 0, 0, 400, 400);
image 是一个 Gdiplus::Image,它可以工作很好,但是如果我创建该插件的 2 个实例(两个不同的 HWND),它只会绘制其中之一。
这是预期的行为吗?我的意思是,GDI+ 只会在从 HWND 创建的一个上下文中绘制?
谢谢!
I'm struggling with this,
I want to draw a Bitmap into a PluginWindowWin (Firebreath) using GDI+; for that I have a timer, simulating the wm_paint message for now, and this code inside:
using namespace Gdiplus;
Graphics graphics(hwnd);
graphics.DrawImage(image, 0, 0, 400, 400);
image is a Gdiplus::Image, it works fine, BUT if I create 2 instances of the plugin (two different HWND) it will ONLY draw in one of them.
Is that the expected behavior?, I mean, GDI+ will draw only in one context created from an HWND?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,每个(顶层)窗口必须有自己的线程。如果将任一窗口放入其自己的线程中,
您应该能够通过将消息发送到具有自己的消息调度程序的两个窗口/线程来并行绘制。
编辑:使用共享 GDI 对象进行线程化是一项危险的任务。资源管理必须是线程安全的。
Basically, each (toplevel) window must have its own thread. If you put either window in its own thread,
you should be able to draw in parallel by sending the message to both windows/threads having their own message dispatcher.
Edit: Threading with shared GDI- objects is a risky task. Resource management must be thread safe.