mfc按钮调用函数
voidCTest3Dlg::OnPaint(){if(IsIconic()){CPaintDCdc(this);//devicecontextforpaintingSe...
void CTest3Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
CDC *pDC = GetDlgItem(m_pic)->GetDC();
pDC->MoveTo(0,0);
pDC->LineTo(100,100);
ReleaseDC(pDC);
}
}
想通过单击button按钮才开始执行此函数(按执行的话将会直接执行此函数),请问如何实现?
另外能否通过单击BUTTON按钮重复调用某个函数? 展开
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
CDC *pDC = GetDlgItem(m_pic)->GetDC();
pDC->MoveTo(0,0);
pDC->LineTo(100,100);
ReleaseDC(pDC);
}
}
想通过单击button按钮才开始执行此函数(按执行的话将会直接执行此函数),请问如何实现?
另外能否通过单击BUTTON按钮重复调用某个函数? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询