在 Windows CE 6.0 中的进程之间共享 GDI 句柄
我知道 GDI 句柄在“Big Windows”中是唯一的且特定于进程,但是它们在 Windows CE 6.0 中的工作方式是否相同?
例如: 我有一个字体管理服务,其他几个服务和应用程序将使用该服务。 该服务具有用于打印和显示的有效字体和配置列表; 它们中的每一个都已调用 CreateFontIndirect()。 当这些客户端应用程序之一请求特定字体(和配置)时,我可以向其返回适当的 HFONT 吗? 如果没有,是否有一种安全/有效的方法来复制句柄,例如内核句柄的 DuplicateHandle 。
我问的原因是,我已经看到通过 PostMessage 传递到另一个应用程序的 HFONT 可以正常工作,但我不认为它们是“应该”的。
I know that GDI handles are unique and process specific in 'Big Windows' but do they work the same way in Windows CE 6.0?
For example:
I've got a font management service that several other services and applications will be using. This service has a list of valid fonts and configurations for printing and displaying; CreateFontIndirect() has been called on each of them. When one of these client applications requests a particular font (and configuration), can I return it the appropriate HFONT? If not, is there a safe/valid way to duplicate the handle, ala DuplicateHandle for Kernel handles.
The reason I ask, is that I've seen HFONTs passed to another application through PostMessage work correctly, but I didn't think they were 'supposed' to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信你是对的,你不能依赖 HFONT 安全地跨进程传递。
它们没有正确通过,所以没有“应该”。 虽然 HFONT 不能保证跨进程工作,但也不能保证它们在进程中唯一。 “Arial”在每个应用程序的特定版本的两个不同进程中可能在某个时间点具有相同的 HFONT 值,并且可以随时更改(包括使用它的中途!)
就像我在绘画一样,橙色油漆用完了,我把它作为我书架上的第三管。 我可以伸手抓住第三个管子……但我不能保证它是橙色的……我不能保证它甚至含有油漆! 也许你今天正在沙发上刷牙……哎呀!
GDI 句柄类似于该示例中的数字“3”。 今天,GDI 可能会在所有区域保持相同的管子顺序。 它可能会保持其中一些有序,有些则不然(即,橙色“有点有效”,但“海泡绿”被破坏了)。 它们在一台 CE 设备上可能是有序的,但在另一台设备上则不然。
一如既往,YMMV。
I believe you are correct, you cannot rely on HFONTs being safe to pass across processes.
They were not passed correctly, so there is no 'supposed to'. While HFONTs are not guaranteed to work across processes, they're also not guaranteed to be unique across processes. 'Arial' may have the same HFONT value in two difference processes at a point in time with a particular version of each application, and could change at any moment (including half-way through using it!)
It's like if I'm painting, and run out of orange paint, which i keep as the 3rd tube on my easle. I could reach for your easle and grab the 3rd tupe... but i have no guarantee that it's orange... i have no guarantee that it even contains paint! Perhaps you were brushing your teeth at the easle today.. oops!
GDI handles are like the number '3' in that example. Today, GDI might keep the tubed in the same order on all easles. It might keep some of them in order, some not (ie, orange 'sorta works', but 'seafoam green' is busted). They could be in order on one CE device, but not on another.
As always, YMMV.