我用ATL做了一个activex控件,在excel中使用。excel中有打印预览的功能。我现在要求我打印预览的样子与该控件在excel中显示的样子不一样。所以我需要判断下,该控件中的OnDraw调用是显示时调用,还是打印时调用。然后根据不同的情况来画图或是打印。现在我想知道在ATL的OnDraw中如何判断其HDC值是基于屏幕的,还是打印机的。CDC中有一个IsPrinting()函数,但HDC是个句柄,不知道怎么使用。另外网上说activex支持打印预览,但不支持打印,这个我还没有试过,望求解答。谢谢。。另外有一帖:http://topic.csdn.net/u/20071213/09/0c034ed1-e285-4e23-b9dc-cf14e812430e.html
The GetObjectType retrieves the type of the specified object.
DWORD GetObjectType(
HGDIOBJ h // handle to graphics object
);
Parameters
h
[in] Handle to the graphics object.
Return Values
If the function succeeds, the return value identifies the object. This value can be one of the following. Value Meaning
OBJ_BITMAP Bitmap
OBJ_BRUSH Brush
OBJ_COLORSPACE Color space
OBJ_DC Device context
OBJ_ENHMETADC Enhanced metafile DC
OBJ_ENHMETAFILE Enhanced metafile
OBJ_EXTPEN Extended pen
OBJ_FONT Font
OBJ_MEMDC Memory DC
OBJ_METAFILE Metafile
OBJ_METADC Metafile DC
OBJ_PAL Palette
OBJ_PEN Pen
OBJ_REGION Region
If the function fails, the return value is zero. To get extended error information, call GetLastError.