void CGraphicsPlusDlg::OnBnClickedButton1()//画线 { CDC *pDC=GetDC(); Graphics graphics(pDC->m_hDC); Pen red(Color(255,255,0,0),3); Pen blue(Color(255,0,0,255),3); graphics.DrawLine(&red,50,100,700,100); graphics.DrawLine(&blue,50,150,700,150); } void CGraphicsPlusDlg::OnBnClickedButton2()//输出文字 { Graphics graphics(m_hWnd);//Graphics的另外一种初始化方式 Font myFont(L"Arial", 16);//字体和文字大小 SolidBrush blackBrush(Color(255, 0, 0, 0));//黑色字体 PointF origin(0.0f, 0.0f); graphics.DrawString(_T("流年逝水"),-1,&myFont,origin,&blackBrush); } void CGraphicsPlusDlg::OnBnClickedButton3()//贴图 { Image image(_T("77860.jpg")); Graphics graphics(m_hWnd); graphics.DrawImage(&image,PointF(0,0)); } void CGraphicsPlusDlg::OnBnClickedButton4()//矩形 { Graphics graphics(m_hWnd); Pen pen(Color(255,0,0),1); graphics.DrawRectangle(&pen,RectF(100,100,200,200)); }