单文档FormView主窗口OnPaint函数的有关问题
单文档FormView主窗口OnPaint函数的问题
如题,我在主窗口放了一个树形控件,从网上下了别人写的一个给树控件加了背景图的扩展类,使用该类的时候要定义主窗口的OnPaint函数,代码如下
------解决方案--------------------
你这个类叫CTestView吗???
------解决方案--------------------
你的类建乱套了吧?CTestView的基类是啥?怎么不认识OnPaint?
------解决方案--------------------
CTestView的父类::OnPaint();
吐槽下,你明明就是Dialog还叫View
CTestView继承有问题。
IMPLEMENT_DYNAMIC(CTestView, CDialog)??你确定这么写了吗?
------解决方案--------------------
else
CTestView::OnPaint()
如题,我在主窗口放了一个树形控件,从网上下了别人写的一个给树控件加了背景图的扩展类,使用该类的时候要定义主窗口的OnPaint函数,代码如下
void CTestView::OnPaint()运行时报错
{
CPaintDC dc(this); // device context for painting
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;
}
else
{
CDialog::OnPaint();//这句的问题,注释掉这句不报错,但树控件背景成白色的了
}
}
error C2248: 'OnPaint' : cannot access protected member declared in class 'CWnd'怎样解决啊??
error C2352: 'CWnd::OnPaint' : illegal call of non-static member function
------解决方案--------------------
你这个类叫CTestView吗???
------解决方案--------------------
你的类建乱套了吧?CTestView的基类是啥?怎么不认识OnPaint?
------解决方案--------------------
CTestView的父类::OnPaint();
吐槽下,你明明就是Dialog还叫View
CTestView继承有问题。
IMPLEMENT_DYNAMIC(CTestView, CDialog)??你确定这么写了吗?
------解决方案--------------------
else
CTestView::OnPaint()