MFC 画曲线

来源:互联网 发布:linux查看线程占用cpu 编辑:程序博客网 时间:2024/06/08 03:47
void Ctest2Dlg::OnPaint()
{




if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文


SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);


// 使图标在工作区矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;


// 绘制图标


}


else
{
//CDialogEx::OnPaint();


CPaintDC dc(this);     //用于绘制设备的上下文
CRect rect;            //矩形区域对象
GetClientRect(rect);     //获取客户区
dc.FillSolidRect(rect, RGB(0, 0, 0));//用黑色填充客户区


int x, y;
for (x = 10; x < 630; x++)
{
for (y = 10; y < 670; y++)
{
dc.SetPixel(x, y, RGB(0, 0, 255));
}
}


}
}