简体   繁体   English

如何使用Windows API知道DC(Windows设备上下文)的类型

[英]How can I know the type of dc (Windows device context) with Windows API

I got a handle of dc (of the type HDC ) under Windows. 我在Windows下得到了dc(HDC类型)的句柄。 Can I get the type of that cd(memory dc, window dc ,printer etc.) with Windows APIs? 我可以使用Windows API获得该cd的类型(内存dc,窗口dc,打印机等)吗?

This is in general not possible, and usually not necessary either. 通常这是不可能的,而且通常也没有必要。 A device context is meant to abstract the underlying implementation. 设备上下文旨在抽象底层实现。

Occasionally, however, it is helpful to know, where the contents of a device context are displayed, to adjust rendering, for example. 但是,有时候,了解设备上下文的内容在何处显示(例如,调整渲染)会很有帮助。 Calling GetDeviceCaps with nIndex set to TECHNOLOGY retrieves that information. nIndex设置为TECHNOLOGY调用GetDeviceCaps会检索该信息。 This doesn't allow you to discern between all four Device Context Types plus their subtypes, though. 但是,这不允许您区分所有四种设备上下文类型及其子类型。

GetObjectType called on the HDC will return different values, including OBJ_DC and OBJ_MEMDC . 在HDC上调用的GetObjectType将返回不同的值,包括OBJ_DCOBJ_MEMDC

This is useful to differentiate screen DCs from memory DCs. 这有助于区分屏幕DC和内存DC。

When creating fonts for memory DCs to export bitmaps ANTIALIASED_QUALITY is probably what you want. 为内存DC创建字体以导出位图时, ANTIALIASED_QUALITY可能就是您想要的。 When creating fonts for the screen CLEARTYPE_QUALITY may be preferred. 在为屏幕创建字体时,首选CLEARTYPE_QUALITY

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM