标签:
DuiLib 很好用,同时在没有完全理解源码的前提下,坑也不少,比如今天遇到的添加滚动条不显示。。。
CControlUI * CMainView::CreateControl(LPCTSTR pstrClass) {
if (0 == _tcscmp(pstrClass, _T("RealTimeInfoPage"))) {
return new CRealTimeInfoPage();
}
return NULL;
}
class CRealTimeInfoPage : public CContainerUI {
public:
CRealTimeInfoPage();
~CRealTimeInfoPage();
};
CRealTimeInfoPage::CRealTimeInfoPage() {
CDialogBuilder builder;
this->Add(builder.Create(_T("xml\\RealTimeInfoPage.xml")));
}
void CContainerUI::EnableScrollBar(bool bEnableVertical, bool bEnableHorizontal) {
if( bEnableVertical && !m_pVerticalScrollBar ) {
m_pVerticalScrollBar = new CScrollBarUI;
m_pVerticalScrollBar->SetScrollRange(0);
m_pVerticalScrollBar->SetOwner(this);
m_pVerticalScrollBar->SetManager(m_pManager, NULL, false);
if ( m_pManager ) {
LPCTSTR pDefaultAttributes = m_pManager->GetDefaultAttributeList(_T("VScrollBar"));
if( pDefaultAttributes ) {
m_pVerticalScrollBar->SetAttributeList(pDefaultAttributes);
}
}
} else if( !bEnableVertical && m_pVerticalScrollBar ) {
m_pVerticalScrollBar->Delete();
m_pVerticalScrollBar = NULL;
}
if( bEnableHorizontal && !m_pHorizontalScrollBar ) {
m_pHorizontalScrollBar = new CScrollBarUI;
m_pHorizontalScrollBar->SetScrollRange(0);
m_pHorizontalScrollBar->SetHorizontal(true);
m_pHorizontalScrollBar->SetOwner(this);
m_pHorizontalScrollBar->SetManager(m_pManager, NULL, false);
if ( m_pManager ) {
LPCTSTR pDefaultAttributes = m_pManager->GetDefaultAttributeList(_T("HScrollBar"));
if( pDefaultAttributes ) {
m_pHorizontalScrollBar->SetAttributeList(pDefaultAttributes);
}
}
} else if( !bEnableHorizontal && m_pHorizontalScrollBar ) {
m_pHorizontalScrollBar->Delete();
m_pHorizontalScrollBar = NULL;
}
NeedUpdate();
}
CPaintManagerUI* CPaintManagerUI::GetPaintManager(LPCTSTR pstrName) {
if( pstrName == NULL ) return NULL;
CString sName = pstrName;
if( sName.IsEmpty() ) return NULL;
for( int i = 0; i < m_aPreMessages.GetSize(); i++ ) {
CPaintManagerUI* pManager = static_cast<CPaintManagerUI*>(m_aPreMessages[i]);
if( pManager != NULL && sName == pManager->GetName() ) return pManager;
}
return NULL;
}
CDuiPtrArray* CPaintManagerUI::GetPaintManagers() {
return &m_aPreMessages;
}
CRealTimeInfoPage::CRealTimeInfoPage(CPaintManagerUI *pManager) {
CDialogBuilder builder;
this->Add(builder.Create(_T("xml\\RealTimeInfoPage.xml"), NULL, NULL, pManager));
}
CControlUI * CMainView::CreateControl(LPCTSTR pstrClass) {
if (0 == _tcscmp(pstrClass, _T("RealTimeInfoPage"))) {
return new CRealTimeInfoPage(&m_PaintManager);
}
return NULL;
}
标签:
原文地址:http://www.cnblogs.com/mforestlaw/p/5894904.html