Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32 Device Context without Window

Tags:

c++

winapi

In my application i need to create HBITMAP objects to which I render and from where I copy the result.

I use the function "CreateDIBSection" to create these bitmaps, however this function required a DC (Device Context) as first parameter. Currently I get this by calling GetDC(hWnd) on the main windows handle (hWnd). But I would like to be able to create HBITMAPS without the requirement of having an application window, without some kind of in memory DC, Is this possible?

like image 907
ronag Avatar asked Aug 01 '10 11:08

ronag


People also ask

What is device context in win32?

A device context is a structure that defines a set of graphic objects and their associated attributes, as well as the graphic modes that affect output.

What is a Windows device context?

A device context is a Windows data structure containing information about the drawing attributes of a device such as a display or a printer. All drawing calls are made through a device-context object, which encapsulates the Windows APIs for drawing lines, shapes, and text.


1 Answers

CreateCompatibleDC(NULL) will create you a device context that is compatible with the screen - which sounds like it would be ideal in the situation.

like image 179
Will A Avatar answered Sep 23 '22 16:09

Will A