我在编程时遇到了一个问题:
For information on how your program can cause an assertion failure ,
see the Visual C++ documention on asserts,
(Press Retry to debug thre application)
终止 重试 忽略
并且在调试时中断总出现在下面语句处:
m_wndPushButton0.Create (_T ("查看当前"), WS_CHILD | WS_VISIBLE |
BS_DEFPUSHBUTTON, rect, this, IDC_Dangqian);
想来想去也不知道问题到底出在哪里?
由于我是一位编程新手,所以还请哪位高手能详细解答一下,非常感谢!!
For information on how your program can cause an assertion failure ,
see the Visual C++ documention on asserts,
(Press Retry to debug thre application)
终止 重试 忽略
并且在调试时中断总出现在下面语句处:
m_wndPushButton0.Create (_T ("查看当前"), WS_CHILD | WS_VISIBLE |
BS_DEFPUSHBUTTON, rect, this, IDC_Dangqian);
想来想去也不知道问题到底出在哪里?
由于我是一位编程新手,所以还请哪位高手能详细解答一下,非常感谢!!
解决方案 »
- 字母的区位码怎么得到??
- 怎么去掉菜单上的阴影?
- SYS驱动程序我 HOOK 了 ZwCreateFile 函数,如何拒绝文件的创建?
- CString为什么不能用,调试的时候watch:ERROR:cannot display value急急急!在线等!!
- 怪问题求救: VB做的COM VC调用,解释模式正常, 编译成dll就出问题
- 关于SOCKET自动传送的问题
- 一个CChildFrame类,一个CMyAppDoc类,多个View类。如何实现不同的View窗口标题和标题图标的不同??
- VC++中如何在单文档中停靠一个浮动的对话框?
- total copy是如何实现的,请各位高人说明一下
- 函数internetOpen之类以前怎么没见到过啊!?
- 求助,关于SAPI开发语音合成
- 请教:在VC2005中,如何让 .lib文件生成到指定的文件夹?
IDC_Dangqian,有人已经使用它了吗?总之,多帖一些代码
最好明确指定父窗口的句柄
For information on how your program can cause an assertion failure ,
see the Visual C++ documention on asserts,
(Press Retry to debug thre application)
终止 重试 忽略
点“重试”,看程序在哪行代码处中断。
单从你上面的代码不太好判断具体是什么问题。
然后m_wndPushButton0.create(,,,)要创建这个按钮,
this指定按钮的父窗口,但是该参数是CWnd* 类型的,所以lz的this,参数类型不对
并且m_wndPushButton0.create(,,,)是用来创建一个按钮,
this指定按钮的父窗口,原语句这样写的
void CChildView::OnPaint()
{
CPaintDC dc(this);
CFont* pOldFont = dc.SelectObject (&m_fontMain);
TEXTMETRIC tm;
dc.GetTextMetrics (&tm);
m_cxChar = tm.tmAveCharWidth;
m_cyChar = tm.tmHeight + tm.tmExternalLeading;
dc.SelectObject (pOldFont);
CRect rect (m_cxChar * 2, m_cyChar, m_cxChar * 48, m_cyChar * 2);
rect.SetRect (m_cxChar * 15, m_cyChar * 3, m_cxChar * 45,m_cyChar * 5);
m_wndPushButton0.Create (_T ("查看当前"), WS_CHILD | WS_VISIBLE |
BS_PUSHBUTTON, rect, this, IDC_Dangqian);
'
'
'
}
但不知道怎样改一下比较好?还请指点一下,谢谢
this指的是主窗口。
我贴了一段程序在下面。
m_wndPushButton0就是CButton类型的,
IDC_Dangqian 在开始我已经定义了。第一次编译
时时好的,多编译几次就出现上面的问题。我贴了段程序在上面,你可以看一下。
用cwnd替换this试试。
你的代码我 测试时没有出现问题啊。
不过你这里面,this不是主窗口,多文档里mainframe才是主窗口
void CChildView::OnPaint()
{
CPaintDC dc(this);
CFont* pOldFont = dc.SelectObject (&m_fontMain);
TEXTMETRIC tm;
dc.GetTextMetrics (&tm);
m_cxChar = tm.tmAveCharWidth;
m_cyChar = tm.tmHeight + tm.tmExternalLeading;
dc.SelectObject (pOldFont);
CRect rect (m_cxChar * 2, m_cyChar, m_cxChar * 48, m_cyChar * 2);
rect.SetRect (m_cxChar * 15, m_cyChar * 3, m_cxChar * 45,m_cyChar * 5);
m_wndPushButton0.Create (_T ("查看当前"), WS_CHILD | WS_VISIBLE |
BS_PUSHBUTTON, rect, this, IDC_Dangqian);
}
还是那个问题,
好像有时出现竟然无法识别一个存在的头文件的问题。
不过还是很感谢你!!就把分加给你吧。
冒昧问一下:如果你有时间,很希望你能帮我看一下完整的程序。不知可否?
如果不便,还请见谅!