Пример #1
0
BOOL CListUIEx::SetHeaderItemData(int nColumn, CControlUI* pControl)
{
	CListHeaderUI *pHeader = CListUI::GetHeader();
	if (pHeader == NULL)
	{
		return FALSE;
	}
	CListHeaderItemUI *pHeaderItem = (CListHeaderItemUI *)pHeader->GetItemAt(nColumn);
	pHeaderItem->Add(pControl);
	return TRUE;
}
Пример #2
0
void CMainDialog::OnNotify( TNotifyUI& msg )
{
	if (msg.sType == _T ("itemactivate")) {
		if (_tcsicmp (msg.pSender->GetClass(), _T("ListUI")) == 0) {
			CListUI* pList = static_cast <CListUI*> (m_pm.FindControl(_T ("lstNormal")));
			ASSERT(pList);
			if (pList) {
				CDuiString str;
				str.Format(_T ("双击或回车了 %d 项"), pList->GetCurSel());
				MessageBox (GetHWND(), str, NULL, MB_OK);
			}
		} else if (msg.pSender && msg.pSender->GetParent () && msg.pSender->GetParent ()->GetParent () &&
			_tcsicmp (msg.pSender->GetParent ()->GetParent ()->GetClass(), _T("Tree")) == 0)
		{
			CDuiTreeView* pTree1 = static_cast<CDuiTreeView*>(m_pm.FindControl(_T("Tree1")));
			if( pTree1 != NULL && pTree1->GetItemIndex(msg.pSender) != -1 )
			{
				if( _tcscmp(msg.pSender->GetClass(), _T("ListLabelElementUI")) == 0 ) {
					CDuiTreeView::Node* node = (CDuiTreeView::Node*)msg.pSender->GetTag();
					pTree1->SetChildVisible(node, !node->data()._child_visible);
				}
			}
		}
	}

	if( msg.sType == _T("itemclick") ) {
		if (msg.pSender && msg.pSender->GetParent () && msg.pSender->GetParent ()->GetParent () &&
			_tcsicmp (msg.pSender->GetParent ()->GetParent ()->GetClass(), _T("Tree")) == 0)
		{
			CDuiTreeView* pTree1 = static_cast<CDuiTreeView*>(m_pm.FindControl(_T("Tree1")));
			if( pTree1 && pTree1->GetItemIndex(msg.pSender) != -1 )
			{
				if( _tcscmp(msg.pSender->GetClass(), _T("ListLabelElementUI")) == 0 ) {
					CDuiTreeView::Node* node = (CDuiTreeView::Node*)msg.pSender->GetTag();

					POINT pt = { 0 };
					::GetCursorPos(&pt);
					::ScreenToClient(m_pm.GetPaintWindow(), &pt);
					pt.x -= msg.pSender->GetX();
					SIZE sz = pTree1->GetExpanderSizeX(node);
					if( pt.x >= sz.cx && pt.x < sz.cy )                     
						pTree1->SetChildVisible(node, !node->data()._child_visible);
				}
			}
		}
	}

	if (_tcscmp(msg.pSender->GetClass(), _T("ListHeaderItemUI")) == 0 && msg.sType == _T ("headerclick")) {
		CListUI* pList = static_cast <CListUI*> (m_pm.FindControl(_T ("lstNormal")));
		ASSERT(pList);
		if (pList) {
			CListHeaderUI* pHeader = pList->GetHeader();
			ASSERT(pHeader);
			if (pHeader) {
				for (int i = 0; i < pHeader->GetCount(); ++i) {
					CControlUI* pItem = pHeader->GetItemAt (i);
					ASSERT(pItem);
					if (pItem) {
						if (PtInRect (&pItem->GetPos(), msg.ptMouse)) {
							CDuiString str;
							str.Format(_T ("单击了头 %d 项"), i);
							MessageBox (GetHWND(), str, NULL, MB_OK);
						}
					}
				}
			}
		}
	}

	CDuiDialog::OnNotify(msg);
}