views:

431

answers:

1

Hello,

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.

Thanks in advance.

Dave

+1  A: 

I believe you are correct, you cannot rely on HFONTs being safe to pass across processes.

'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.'

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.

Aaron
Thanks for the explanation. I asked the question on [msft.public.windowsce.embedded][1] and the disc. (I think) demonstrates some of the confusion with the WinCE implementation. [1]: http://groups.google.com/group/microsoft.public.windowsce.embedded/browse_thread/thread/507a6fe50e1f2697?hl=en#
DavidEBest