bool CBookClient::AddNode(BOOK_INFO *item) { if (item == NULL) return false; BOOK_INFO *node = new BOOK_INFO; node->strName = item->strName; node->nImage = item->nImage; node->strPath = item->strPath; node->nBookmark = item->nBookmark; CContainerUI* pDesk = NULL; if( !m_dlgBuilder.GetMarkup()->IsValid() ) { pDesk = static_cast<CContainerUI*>(m_dlgBuilder.Create(_T("iBook.xml"), (UINT)0, NULL, &m_pm)); } else { pDesk = static_cast<CContainerUI*>(m_dlgBuilder.Create((UINT)0, &m_pm)); } if( pDesk != NULL ) { this->Add(pDesk); CButtonUI* btn = static_cast<CButtonUI*>(m_pm.FindSubControlByName(pDesk, _T("btnBookEx"))); CLabelUI *text = static_cast<CLabelUI*>(m_pm.FindSubControlByName(pDesk, _T("labelBookEx"))); CButtonUI *btnEdit = static_cast<CButtonUI*>(m_pm.FindSubControlByName(pDesk, _T("btnbookdel"))); if (btn == NULL || text == NULL || btnEdit == NULL) return false; CDuiString strImage; strImage.Format(_T("book\\%02d.png"), node->nImage); btn->SetBkImage(strImage); text->SetText(node->strName); btnEdit->SetVisible(m_bEdit); pDesk->SetTag((UINT_PTR)node); } else { delete node; node = NULL; return false; } return true; }
void CMainDialog::AddComboboxItem() { CComboUI* pcbx2 = static_cast <CComboUI*> (m_pm.FindControl(_T("combo2"))); assert (pcbx2); if (pcbx2) { CDialogBuilder builder; CContainerUI* pItem = static_cast <CContainerUI*> (builder.Create(_T("comboitem.xml"), 0)); pItem->GetItemAt(0)->SetBkImage(_T ("icon_home.png")); if (pcbx2->GetCount() % 2 == 0) { pItem->GetItemAt(1)->SetText(_T ("百度一下,你就知道了")); pItem->GetItemAt(2)->SetText(_T ("http://www.baidu.com")); } else { pItem->GetItemAt(1)->SetText(_T ("360搜索 - 干净、安全、可信任的搜索引擎")); pItem->GetItemAt(2)->SetText(_T ("http://www.so.com/")); } pItem->SetTag(pcbx2->GetCount()); pItem->OnEvent += MakeDelegate (this, &CMainDialog::OnClickItem); pcbx2->Add(pItem); } }