Shaobo Zi
Shaobo Zi

Reputation: 729

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. Can I get the type of that cd(memory dc, window dc ,printer etc.) with Windows APIs?

Upvotes: 0

Views: 418

Answers (2)

Renate
Renate

Reputation: 811

GetObjectType called on the HDC will return different values, including OBJ_DC and OBJ_MEMDC.

This is useful to differentiate screen DCs from memory DCs.

When creating fonts for memory DCs to export bitmaps ANTIALIASED_QUALITY is probably what you want. When creating fonts for the screen CLEARTYPE_QUALITY may be preferred.

Upvotes: 1

IInspectable
IInspectable

Reputation: 51386

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. This doesn't allow you to discern between all four Device Context Types plus their subtypes, though.

Upvotes: 3

Related Questions