device-context

Weirdness with SetWindowExt and SetWindowExtEx (negative height, upside down)

心已入冬 提交于 2019-12-11 08:03:05
问题 I am running into a weird behavior regarding SetViewportExt() and SetViewportExtEx() . My MFC application uses MM_ISOTROPIC mapping for setting up the view device context and configures the device context as follows: m_dc.SetMapMode( MM_ISOTROPIC ); // Set the window extent (document space) CSize docSizeLP = GetDocumentSizeLP(); m_dc.SetWindowExt(docSizeLP.cx, docSizeLP.cy); // Next set the viewport extent CSize docSizeDP = GetDocumentSizeDP(); m_dc.SetViewportExt((int) (docSizeDP.cx * fZoom)

Win32: Does a window have the same HDC for its entire lifetime?

与世无争的帅哥 提交于 2019-12-09 06:28:52
问题 Am i allowed to use a DC outside of a paint cycle? Is my window's DC guaranteed to be valid forever? i'm trying to figure out how long my control's Device Context (DC) is valid. i know that i can call: GetDC(hWnd); to get the device context of my control's window, but is that allowed? When Windows sends me a WM_PAINT message, i am supposed to call BeginPaint/EndPaint to properly acknowledge that i've painted it, and to internally clear the invalid region: BeginPaint(hWnd, {out}paintStruct);

What bad things may happen without calling to ReleaseDC?

旧巷老猫 提交于 2019-12-08 18:52:49
问题 Programming with C++, once we get the context device by GetDC to use. What bad things may happen if we exit the program without calling to ReleaseDC? 回答1: From the docs The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. It has no effect on class or private DCs. As you can see, it may be needed if other applications can access the same DC. In any

Win32: Does a window have the same HDC for its entire lifetime?

有些话、适合烂在心里 提交于 2019-12-03 08:18:17
Am i allowed to use a DC outside of a paint cycle? Is my window's DC guaranteed to be valid forever? i'm trying to figure out how long my control's Device Context (DC) is valid. i know that i can call: GetDC(hWnd); to get the device context of my control's window, but is that allowed? When Windows sends me a WM_PAINT message, i am supposed to call BeginPaint / EndPaint to properly acknowledge that i've painted it, and to internally clear the invalid region: BeginPaint(hWnd, {out}paintStruct); try //Do my painting finally EndPaint(hWnd, paintStruct); end; But calling BeginPaint also returns me

Fastest method for blitting from a pixel buffer into a device context

混江龙づ霸主 提交于 2019-12-01 23:25:17
问题 Good evening, I have several 32-bit images in memory buffers that I wish to "blit" to a device context, quickly. Speed is an issue here because the buffer will be manipulated constantly and need to be blitted to the DC repeatedly. The color depth of the buffer is 32-bits, so it is already in the DIB-expected format of SetDIBits(). However, this is rather cumbersome since the bitmap target of SetDIBits() cannot be already selected into the DC prior to the operation. So I will need to