📄 subject_55019.htm
字号:
<p>
序号:55019 发表者:莹莹菜 发表日期:2003-10-05 16:43:01
<br>主题:这是什么错误提示?
<br>内容:给SDI应用程序添加Toolbar,编译通过,运行时出现如下错误提示。这是怎么回事呀?我很菜,请详细一点。<BR><BR>Debug Assertion Failed!<BR><BR>Program: Toolbar\Debug\Toolbar.exe<BR>File: winfrm2.cpp<BR>Line: 106<BR><BR>For information on how your program can cause an assertion<BR>failure, see the Visual C++ document on asserts.<BR><BR>(Press Retry to debug the application)
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:无情阁东雪 回复日期:2003-10-05 17:05:37
<br>内容:出现断言错误,可能是你的工具栏没有创建成功,或是根本就没有创建
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:莹莹菜 回复日期:2003-10-05 17:08:03
<br>内容:创建了呀,应该怎么做?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:莹莹菜 回复日期:2003-10-05 18:09:49
<br>内容:相关代码如下:<BR><BR>IDR_TBCOLOR:创建的颜色工具栏的ID;<BR>m_wndColorBar:上述工具栏的变量,类型为ToolBar,访问权限受保护(protected)。<BR><BR>int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)<BR>{<BR> if (CFrameWnd::OnCreate(lpCreateStruct) == -1)<BR> return -1;<BR> <BR> if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP<BR> | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||<BR> !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))<BR> {<BR> TRACE0("Failed to create toolbar\n");<BR> return -1; // fail to create<BR> }<BR><BR> ////////////////////////////////////<BR> // MY CODE STARTS HERE<BR> ////////////////////////////////////<BR><BR> // Add the color toolbar<BR> int iTBCtlID;<BR> int i;<BR> // Create the Color Toolbar<BR> if (!m_wndColorBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |<BR> WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS |<BR> CBRS_FLYBY | CBRS_SIZE_DYNAMIC || !m_wndColorBar.<BR> LoadToolBar(IDR_TBCOLOR)))<BR> {<BR> TRACE0("Failed to create toolbar\n");<BR> return -1; // fail to create <BR> }<BR> // Find the black button on the toolbar<BR> iTBCtlID = m_wndColorBar.CommandToIndex(ID_COLOR_BLACK);<BR> if (iTBCtlID >= 0)<BR> {<BR> // Loop through the buttons, setting them to act as radio<BR> //buttons<BR> for (i = iTBCtlID; i < (iTBCtlID + 8); i++)<BR> {<BR> m_wndColorBar.SetButtonStyle(i, TBBS_CHECKGROUP);<BR> }<BR> }<BR><BR> /////////////////////////////////////////<BR> // MY CODE ENDS HERE<BR> /////////////////////////////////////////<BR><BR><BR> if (!m_wndStatusBar.Create(this) ||<BR> !m_wndStatusBar.SetIndicators(indicators,<BR> sizeof(indicators)/sizeof(UINT)))<BR> {<BR> TRACE0("Failed to create status bar\n");<BR> return -1; // fail to create<BR> }<BR><BR> // TODO: Delete these three lines if you don't want the toolbar to<BR> // be dockable<BR> m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);<BR> <BR> /////////////////////////////////////<BR> // MY CODE STARTS HERE<BR> /////////////////////////////////////<BR><BR> // Enable docking for the Color Toolbar<BR> m_wndColorBar.EnableDocking(CBRS_ALIGN_ANY);<BR><BR> ////////////////////////////////////////<BR> // MY CODE ENDS HERE<BR> ////////////////////////////////////////<BR><BR> EnableDocking(CBRS_ALIGN_ANY);<BR> DockControlBar(&m_wndToolBar);<BR><BR> //////////////////////////////<BR> // MY CODE STARTS HERE<BR> //////////////////////////////<BR><BR> // Dock the Color ToolBar<BR> DockControlBar(&m_wndColorBar);<BR><BR> /////////////////////////////<BR> // MY CODE ENDS HERE<BR> /////////////////////////////<BR><BR><BR> return 0;<BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:雾影晨光 回复日期:2003-10-05 19:26:22
<br>内容:为什么不进行逐行调试呢,也许可以发现在上面的代码中间那一行出现了错误。建议你同步学习如何进行调试。<BR>上面的代码中间,我都看不出有什么错误,不过,我都很水的。:)<BR>我唯一有疑问的地方在于ID_COLOR_BLACK+8有没有超过你的色彩工具条中间的最大ID号码,同时各个ID号码是不是连续的?不过我都觉得你可能不会在这个问题上犯错误。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:莹莹菜 回复日期:2003-10-05 19:43:18
<br>内容:我很菜,刚开始学,教材怎么说就怎么做,对逐行调试不是很明白的,调试结果也看不懂。<BR>你说的后两个问题,我都看了,没错误的。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:无情阁东雪 回复日期:2003-10-05 21:27:15
<br>内容:把代码放上来
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:iamhere 回复日期:2003-10-05 23:23:00
<br>内容:这句话有错误,<BR>if (!m_wndColorBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |<BR> WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS |<BR> CBRS_FLYBY | CBRS_SIZE_DYNAMIC || !m_wndColorBar.<BR> LoadToolBar(IDR_TBCOLOR)))<BR><BR>应该是:<BR><BR>if (!m_wndColorBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |<BR> WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS |<BR> CBRS_FLYBY | CBRS_SIZE_DYNAMIC ) || !m_wndColorBar.<BR> LoadToolBar(IDR_TBCOLOR))<BR><BR>注意CreateEx函数右括号的位置!<BR><BR>另外:我说小MM啊,不要死跟着书本一步步来,碰到这种问题就该顺便学习一下程序的调试!学会了这个,你会事半功倍的!<BR> <BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:莹莹菜 回复日期:2003-10-06 09:39:31
<br>内容:真是太神了你!你是怎么看出来的呀?<BR>谢谢iamhere!<BR>谢谢无情阁东雪!<BR>谢谢雾影晨光!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -