Can DC be used outside the paint cycle? Is my window constant time constant?
I am trying to figure out how long my Device Context (DC) control has been valid.
I know I can call:
GetDC(hWnd);
to get the device context of my control window, but is it allowed?
When Windows sends me a WM_PAINT message, I have to call BeginPaint / EndPaint to correctly confirm that I drew it, and internally clear the invalid area:
BeginPaint(hWnd, {out}paintStruct);
try
finally
EndPaint(hWnd, paintStruct);
end;
But calling BeginPaint also returns me DC inside the PAINTSTRUCT structure. This is the DC that I have to draw.
- , , DC, BeginPaint(), DC, GetDC().
, , Desktop Composition, DC, BeginPaint?
, , DC :
, , , Borland Delphi, .
WM_PAINT Delphi , wParam DC . MSDN , wParam WM_PAINT .
GDI + Graphics HDC, GDI +, .
WM_PAINT GDI + . nieve :
WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(m_hwnd, ps);
Graphics g = new Graphics(ps.hdc);
g.DrawImage(m_someBitmap, 0, 0);
g.Destroy();
EndPaint(h_hwnd, ps);
}
GDI , CachedBitmap. :
WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(m_hwnd, ps);
Graphics g = new Graphics(ps.hdc);
CachedBitmap bm = new CachedBitmap(m_someBitmap, g);
g.DrawCachedBitmap(m_bm, 0, 0);
bm.Destroy();
g.Destroy();
EndPaint(h_hwnd, ps);
}
CachedBitmap , :
m_graphics = new Graphics(GetDC(m_hwnd));
m_cachedBitmap = new CachedBitmap(b_someBitmap, m_graphcis);
:
WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(m_hwnd, ps);
m_graphics.DrawCachedBitmap(m_cachedBitmap, 0, 0);
EndPaint(h_hwnd, ps);
}
, , DC, , DC , . , :
MSDN, , DC , .
: , . , .