我创建一个从CDockablePane派生的类,这样的代码。
class CWorkspaceBar : public CDockablePane
{
public:
CWorkspaceBar();
// Attributes
protected:
CXListBox m_wndThumbList;
// Operations
public:
// Overrides
// Implementation
public:
virtual ~CWorkspaceBar();
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
在函数CWorkspaceBar :: OnCreate中创建一个CListBox。
int CWorkspaceBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rectDummy;
rectDummy.SetRectEmpty();
if (!m_wndThumbList.Create (WS_CHILDWINDOW | WS_VISIBLE |WS_VSCROLL|WS_HSCROLL| LBS_OWNERDRAWFIXED|LBS_HASSTRINGS|LBS_NOTIFY,rectDummy, this,IDC_THUMBNAILIMAGELIST))
{
TRACE0("Failed to create workspace view\n");
return -1;
}
return 0;
}
在函数CWorkspaceBar :: OnSize中我调整了CListBox对象的大小,但它无法填充整个父窗口。
void CWorkspaceBar::OnSize(UINT nType, int cx, int cy)
{
CDockablePane::OnSize(nType, cx, cy);
if(IsWindow(m_wndThumbList.GetSafeHwnd()))
m_wndThumbList.SetWindowPos (NULL,0,0,cx,cy, SWP_NOACTIVATE | SWP_NOZORDER);
}
我测试了CListCtrl和CTreeCtrl,它运行良好,只有CListBox无法填充整个父窗口。如何修复它,这是MFC的错误吗?
答案 0 :(得分:2)
创建列表框时使用LBS_NOINTEGRALHEIGHT。