如何得到当前的 HDC hDC, // handle to device context我要用下边的这个函数。
int DrawText(
HDC hDC, // handle to device context
LPCTSTR lpString, // pointer to string to draw
int nCount, // string length, in characters
LPRECT lpRect, // pointer to struct with formatting dimensions
UINT uFormat // text-drawing flags
);
int DrawText(
HDC hDC, // handle to device context
LPCTSTR lpString, // pointer to string to draw
int nCount, // string length, in characters
LPRECT lpRect, // pointer to struct with formatting dimensions
UINT uFormat // text-drawing flags
);
HDC GetDC(
HWND hWnd // handle to a window
);
CDC *pDC=GetDC();
::DrawTextW(HDC(*pDC), &ct, 1, rc,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
CDC * pDC=GetDC( );
这里的GetDC( )是CWnd类的成员函数,它返回一个允许用户绘制它的窗口客户区的设备
环境;如果还希望绘制非客户区,则使用:
CDC *pDC=GetWindowDC( );
如果需要绘制整个屏幕,如编写一个屏幕保护程序或游戏程序时,可能需要对整屏进行
绘制,这时使用:
CDC *pDC=CDC::FromHandle (::GetDC (NULL));
dc.DrawText("this", rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
HDC hDC=pDC->GetSafeHdc();//加上这个
::DrawTextW(hDC, &ct, 1, rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);