void CTest1View::OnCdc()
{
// TODO: Add your command handler code here
//针对整个屏幕的DC绘画 以屏幕为坐标
CDC dc;
//创建一个显示器DC
dc.CreateDC("DISPLAY",NULL,NULL,NULL);
dc.Rectangle(50,50,500,500);
dc.DeleteDC();
}
void CTest1View::OnCwindowdc()
{
// TODO: Add your command handler code here
//针对整个窗口的DC 窗口类的所有区域都可以绘画
CWindowDC cDC(this);
cDC.Rectangle(0,0,400,400);
}
void CTest1View::OnCclidndc()
{
// TODO: Add your command handler code here
//针对客户区的DC只能在一定区域绘画
CClientDC dc(this);
dc.Rectangle(0,0,400,400);
CDC * pDC=GetDC();
ReleaseDC(pDC);
}
void CTest1View::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.FillSolidRect(150,150,50,50,RGB(0,255,0));
// TODO: Add your message handler code here
// Do not call CView::OnPaint() for painting messages
}
void CTest1View::OnCmetateledc()
{
CMetaFileDC dc;
//创建DC
dc.Create("C:\\meta.dat");
//绘图
dc.FillSolidRect(50,50,50,50,RGB(0,255,0));
//关闭DC
HMETAFILE hMetaFile=dc.Close();
//显示DC
CClientDC dc1(this);
dc1.PlayMetaFile(hMetaFile);
//删除DC
DeleteMetaFile(hMetaFile);
// TODO: Add your command handler code here
}