在OnPaint里加的,启动完后,什么也不显示,要鼠标拖动窗口左右晃动一下,图标才显示出来。DEBUG发现代码已经正常执行了。不知道为什么不能正确显示。我的按钮是在一个CDialogBar里放的。
代码:
void CScencesView::OnPaint()
{
CPaintDC dc(this); // device context for painting
CButton* b = (CButton*)((CMainFrame*)AfxGetMainWnd())->m_wndDlgBar.GetDlgItem(IDC_BUTTON1);
CDC* pdc = b->GetDC();
POINT p;
RECT lp;
b->GetClientRect(&lp);
p.x = lp.left;
p.y = lp.top;
pdc->DrawIcon(p,AfxGetApp()->LoadIcon(IDI_ICON2));
b->UpdateWindow();
// Do not call CFormView::OnPaint() for painting messages
}在Ondraw里也是一样的情况。:(
谁知道怎么回事。
代码:
void CScencesView::OnPaint()
{
CPaintDC dc(this); // device context for painting
CButton* b = (CButton*)((CMainFrame*)AfxGetMainWnd())->m_wndDlgBar.GetDlgItem(IDC_BUTTON1);
CDC* pdc = b->GetDC();
POINT p;
RECT lp;
b->GetClientRect(&lp);
p.x = lp.left;
p.y = lp.top;
pdc->DrawIcon(p,AfxGetApp()->LoadIcon(IDI_ICON2));
b->UpdateWindow();
// Do not call CFormView::OnPaint() for painting messages
}在Ondraw里也是一样的情况。:(
谁知道怎么回事。
重载CButton::DrawItem()函数,在这里就可以了
程序就出错?