绘制饼图DrawPie

it2025-04-04  15

代码:

void Cgditest1Dlg::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;

        // 绘制图标        dc.DrawIcon(x, y, m_hIcon);    }    else    {        //UpdateData(TRUE);        CPaintDC dc(this);        Graphics g(dc);        Pen mypen(Color::Red,2);        //g.DrawArc(&mypen,10,10,200,100,GetDlgItemInt(IDC_EDIT1),GetDlgItemInt(IDC_EDIT2));        g.DrawPie(&mypen,10,10,200,100,GetDlgItemInt(IDC_EDIT1),GetDlgItemInt(IDC_EDIT2));        //g.DrawArc(&mypen,10,10,200,100,45,270);        CDialog::OnPaint();    }}

 

只修改了方法,其它和上例一样

转载于:https://www.cnblogs.com/lkgosurlfing/archive/2009/05/23/1487620.html

相关资源:Qt4.7 利用Painter drawPie绘制螺旋波形
最新回复(0)