我有以下代码在我的 MFC MDI 应用程序的文档窗口中创建一个列表视图:
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
CRect getWindowRect, windowRect;
this->GetWindowRect(&getWindowRect);
windowRect.left = 0;
windowRect.top = 0;
windowRect.right = getWindowRect.right;
windowRect.bottom = getWindowRect.bottom;
CListCtrl *CarsListView = new CListCtrl();
CarsListView->Create( WS_CHILD | WS_VISIBLE | LVS_REPORT, windowRect, this, 9001 );
CarsListView->InsertColumn(0, _T("Reg. no"), LVCFMT_LEFT, 500);
CarsListView->InsertColumn(1, _T("Status"), LVCFMT_RIGHT, 100);
CarsListView->InsertColumn(2, _T("Type"), LVCFMT_LEFT, 60);
CarsListView->ShowWindow(SW_SHOW);
return 0;
}
它工作正常,它创建控件并显示它。但我无法单击或悬停它。有人告诉我我应该继承这个控件,但我真的不知道他的意思。我想我应该创建一个类CarsListView
并实现消息处理程序,但这看起来很复杂。(例如,我是否必须重新设计列标题上的悬停动作?)
我需要有关此主题的帮助。我怎样才能让它工作?