关于CFormView类视图的Create()函数的一个错误?
|
楼主发表于:2005-05-14 20:17:16
在用下面的Create()函数创建CFormView类视图对象m_wndView时,出现后面的错误,是什么原因呢?应该怎么改呢?谢谢!
if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
{
TRACE0( "Failed to create view window/n ");
return -1;
}
提示错误是:
E:/.../MainFrm.cpp(56) : error C2248: 'Create ' : cannot access protected member declared in class 'CFormView '
| | | |
|
|
#1楼 得分:10回复于:2005-05-14 20:22:05
这是因为CFormView的Create函数是protected的,你重载Create函数,以public的形式就可以了。
in h file, you will write...
public Create(...)
in cpp file, you will write
int CMyFormView::Create(....)
{
return CFormView::Create(...);
}
| | |
|
|
#2楼 得分:0回复于:2005-05-14 20:38:09
JerryGR,谢谢:)
我照你说的方法做了修改,虽然没有再出现关于Create函数的报错,但是执行后原来可以出现的工具栏显示不出来了,而且关闭执行完的主窗口后出现了“Debug Assertion Failed”错误,这会是什么原因呢
| | |
|
|
#3楼 得分:0回复于:2005-05-14 21:16:24
Create创建了,需要显示ShowWindow
检查析构
| | |
|
|
#4楼 得分:10回复于:2005-05-14 21:22:18
CWnd * pWnd = (CWnd*)&m_wndView; //这里这样转换。
if (!pWnd-> Create(NULL, NULL, WS_CHILD|WS_VISIBLE, CRect(0,0,10,10), this, 1001, NULL))
{
error....
}
| | |
|
|
#5楼 得分:0回复于:2005-05-14 21:31:01
|
|
|
#6楼 得分:0回复于:2005-05-14 21:33:42
NetLinux,谢谢:)
我用您说的这种方法改后还是有这个问题:(顺便问问,这种方法对我今后对m_wndView的正常使用有影响么?
| | |
|
|
#7楼 得分:0回复于:2005-05-15 11:15:03
没有影响.
不过那个对话框模板是-子窗口风格,Visible 不要打对号。
| | |
|
|
#8楼 得分:0回复于:2005-06-02 15:14:04
先给分了:)谢谢oyljerry等各位仁兄的帮忙!
| |