tags:

views:

153

answers:

1

Is it possible to create a custom GDI device in user mode? The idea is to create a device context (HDC) which we can pass to an opaque component, so that when the component calls GDI functions like TextOut we can get the actual text string.

+3  A: 

I have not used GDI much, but I've heard that metafiles record the drawing and can be played back. You might be able to get the text string from it.

I've looked at it more, and you can create a GDI with CreateEnhMetaFile() that records drawing into a metafile. Have the component draw using this GDI device. Then you can call EnumEnhMetaFile(), passing it a callback. Your callback will get called with a pointer to an ENHMETARECORD. The ENHMETARECORD begins with an EMR. It has a member called iType that is the type of drawing operation.

Jordan Miner
Thanks, that's just what I was looking for!
CyberShadow