本程序实现双列表选择管理器(A Dual ListBox Selection Manager), 如图:
在 OnInitialUpdate 加入下列代码:
void CDualListDemoView::OnInitialUpdate() { ... // Normal processing // ADDED TO DEFAULT THE LISTS. // This code will need to be replaced with your // application specific code that knows what belongs // in each list. m_DualListManager.AddItemToAvailableList(_T("Red"), 0); m_DualListManager.AddItemToAvailableList(_T("Green"), 1); m_DualListManager.AddItemToAvailableList(_T("Blue"), 2); m_DualListManager.AddItemToChoosenList(_T("Yellow"), 3); m_DualListManager.AddItemToChoosenList(_T("Purple"), 4); m_DualListManager.AddItemToChoosenList(_T("Orange"), 5); // ADDED TO INITIALIZE THE MANAGER CLASS m_DualListManager.InitializeControls(this, IDC_FV_LIST_AVAILABLE, IDC_FV_LIST_CHOOSEN, IDC_FV_ADD, IDC_FV_ADD_ALL, IDC_FV_REMOVE, IDC_FV_REMOVE_ALL, IDC_FV_MOVE_UP, IDC_FV_MOVE_DOWN); }
重载 OnCmdMsg methodm 然后调用在 Dual List Manager Object 中调用 ProcessCmdMsg.
BOOL CDualListDemoView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { // ADDED TO INTERCEPT MESSAGE THAT THE DUAL // LIST MANAGER NEEDS m_DualListManager.ProcessCmdMsg(nID, nCode); // NOW CALL THE BASE CLASS return CFormView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); }
加入下列成员到你的 header file.
CDualListManager m_DualListManager;
Quote:辉哥活动的时间可真无拘束。
XiaoHui 回复于 2010-11-27 04:04 :