程序关闭时候出错,帮忙看看什么原因。

chenbin0522 2009-03-26 03:50:29
mfc单文档程序


MainFrm.h:

CListView m_List;


MainFrm.cpp:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

// Create Main List
if(this->m_List.Create(NULL, NULL,
AFX_WS_DEFAULT_VIEW|LVS_REPORT|LVS_SHOWSELALWAYS,
CRect(0,0,570,236),this, IDC_MAINLIST) == false)
{
return -1;
}

this->m_List.GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_INFOTIP| LVS_EX_GRIDLINES);

return 0;
}


错误信息:
Windows has triggered a breakpoint in Test.exe.

This may be due to a corruption of the heap, which indicates a bug in Test.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while Test.exe has focus.

The output window may have more diagnostic information.
...全文
70 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenbin0522 2009-03-26
  • 打赏
  • 举报
回复
那我在单文档程序里面将listview改成CListCtrl 有什么区别?
chenbin0522 2009-03-26
  • 打赏
  • 举报
回复
能编译通过,只是在关闭程序的时候会出现错误。我想把单文档界面改成一个有充满画面的ListView控件的程序。
cnzdgs 2009-03-26
  • 打赏
  • 举报
回复
视图对象需要用new构造,关闭时会自动销毁。
tanwei1002 2009-03-26
  • 打赏
  • 举报
回复
不过有几点不明白,你创建个list是做什么用,为什么创建的时候不指定list的父窗口。
还有OnCreate()为什么要把工具栏状态栏取消。。。。
我刚刚是在没有取消工具栏状态栏代码下编译能通过
即:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}

if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}

// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);


if(this->m_List.Create(this, NULL,
AFX_WS_DEFAULT_VIEW|LVS_REPORT|LVS_SHOWSELALWAYS,
CRect(0,0,570,236),this, IDC_MAINLIST) == false)
{
return -1;
}

this->m_List.GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_INFOTIP| LVS_EX_GRIDLINES);



return 0;
}
tanwei1002 2009-03-26
  • 打赏
  • 举报
回复
在使用CListView这样的类的时候 记得在MainFrm.h前加上 #include <afxcview.h>
刚刚我试了下 编译能通过

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧