Skip to content

Commit

Permalink
控件名称忽略大小写
Browse files Browse the repository at this point in the history
  • Loading branch information
qdtroy committed Feb 22, 2017
1 parent 2c61c90 commit 62d5879
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Demos/gamebox/ControlEx.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ class CDialogBuilderCallbackEx : public IDialogBuilderCallback
public:
CControlUI* CreateControl(LPCTSTR pstrClass)
{
//if( _tcsicmp(pstrClass, _T("GameList")) == 0 ) return new CGameListUI;
//else if( _tcsicmp(pstrClass, _T("GameItem")) == 0 ) return new CGameItemUI;
//else if( _tcsicmp(pstrClass, _T("ShortCut")) == 0 ) return new CShortCutUI;
//else if( _tcsicmp(pstrClass, _T("LabelMutiline")) == 0 ) return new CLabelMutilineUI;
if( _tcsicmp(pstrClass, _T("GameList")) == 0 ) return new CGameListUI;
else if( _tcsicmp(pstrClass, _T("GameItem")) == 0 ) return new CGameItemUI;
else if( _tcsicmp(pstrClass, _T("ShortCut")) == 0 ) return new CShortCutUI;
else if( _tcsicmp(pstrClass, _T("LabelMutiline")) == 0 ) return new CLabelMutilineUI;
return NULL;
}
};
Expand Down
22 changes: 11 additions & 11 deletions Demos/gamebox/GameBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ class CGameBoxFrame : public WindowImplBase, public CWebBrowserEventHandler

}


CDuiString GetSkinFile()
{
return _T("skin.xml");
}

CControlUI* CreateControl(LPCTSTR pstrClass)
{
//if( _tcsicmp(pstrClass, _T("GameList")) == 0 ) return new CGameListUI;
//else if( _tcsicmp(pstrClass, _T("GameItem")) == 0 ) return new CGameItemUI;
//else if( _tcsicmp(pstrClass, _T("ShortCut")) == 0 ) return new CShortCutUI;
//else if( _tcsicmp(pstrClass, _T("LabelMutiline")) == 0 ) return new CLabelMutilineUI;
if( _tcsicmp(pstrClass, _T("GameList")) == 0 ) return new CGameListUI;
else if( _tcsicmp(pstrClass, _T("GameItem")) == 0 ) return new CGameItemUI;
else if( _tcsicmp(pstrClass, _T("ShortCut")) == 0 ) return new CShortCutUI;
else if( _tcsicmp(pstrClass, _T("LabelMutiline")) == 0 ) return new CLabelMutilineUI;
return NULL;
}

Expand All @@ -41,10 +40,11 @@ class CGameBoxFrame : public WindowImplBase, public CWebBrowserEventHandler
m_pFindList = (CHorizontalLayoutUI*)(m_pm.FindControl(_T("findlist")));


CDialogBuilderCallbackEx callback;
for (int i = 0; i < 60; i++)
{
CDialogBuilder builder;
CControlUI* pGameItem = static_cast<CControlUI*>(builder.Create(_T("gameitem.xml"), (UINT)0, NULL, &m_pm));
CControlUI* pGameItem = static_cast<CControlUI*>(builder.Create(_T("gameitem.xml"), (UINT)0, &callback, &m_pm));
m_pGameList->Add(pGameItem);
CDuiString sText;
sText.Format(_T("游戏%d"), i);
Expand All @@ -55,7 +55,7 @@ class CGameBoxFrame : public WindowImplBase, public CWebBrowserEventHandler
for (int i = 0; i < 6; i++)
{
CDialogBuilder builder;
CControlUI* pGameItem = static_cast<CControlUI*>(builder.Create(_T("gameitem.xml"), (UINT)0, NULL, &m_pm));
CControlUI* pGameItem = static_cast<CControlUI*>(builder.Create(_T("gameitem.xml"), (UINT)0, &callback, &m_pm));
m_pFindList->Add(pGameItem);

CDuiString sText;
Expand Down Expand Up @@ -450,10 +450,10 @@ void InitResource()


// 注册控件
REGIST_DUICONTROL(CLabelIconUI);
REGIST_DUICONTROL(CGameItemUI);
REGIST_DUICONTROL(CGameListUI);
REGIST_DUICONTROL(CLabelMutilineUI);
//REGIST_DUICONTROL(CLabelIconUI);
//REGIST_DUICONTROL(CGameItemUI);
//REGIST_DUICONTROL(CGameListUI);
//REGIST_DUICONTROL(CLabelMutilineUI);
}

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
Expand Down
11 changes: 6 additions & 5 deletions Demos/gamebox/SearchWnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class CSearchWnd : public WindowImplBase

CControlUI* CreateControl(LPCTSTR pstrClass)
{
//if( _tcsicmp(pstrClass, _T("GameList")) == 0 ) return new CGameListUI;
//else if( _tcsicmp(pstrClass, _T("GameItem")) == 0 ) return new CGameItemUI;
//else if( _tcsicmp(pstrClass, _T("ShortCut")) == 0 ) return new CShortCutUI;
//else if( _tcsicmp(pstrClass, _T("LabelMutiline")) == 0 ) return new CLabelMutilineUI;
if( _tcsicmp(pstrClass, _T("GameList")) == 0 ) return new CGameListUI;
else if( _tcsicmp(pstrClass, _T("GameItem")) == 0 ) return new CGameItemUI;
else if( _tcsicmp(pstrClass, _T("ShortCut")) == 0 ) return new CShortCutUI;
else if( _tcsicmp(pstrClass, _T("LabelMutiline")) == 0 ) return new CLabelMutilineUI;
return NULL;
}

Expand All @@ -32,8 +32,9 @@ class CSearchWnd : public WindowImplBase
CListUI* pGameList = static_cast<CListUI*>(m_pm.FindControl(_T("searchlist")));
if(pGameList != NULL)
{
CDialogBuilderCallbackEx callback;
CDialogBuilder builder;
CListContainerElementUI* pGameItem = static_cast<CListContainerElementUI*>(builder.Create(_T("searchitem.xml"), (UINT)0));
CListContainerElementUI* pGameItem = static_cast<CListContainerElementUI*>(builder.Create(_T("searchitem.xml"), (UINT)0, &callback));
pGameList->Add(pGameItem);
CControlUI *pText = pGameItem->FindSubControl(_T("searchitem_text"));
pText->SetText(sItem);
Expand Down
2 changes: 2 additions & 0 deletions DuiLib/Core/ControlFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace DuiLib

CControlUI* CControlFactory::CreateControl(CDuiString strClassName)
{
strClassName.MakeLower();
MAP_DUI_CTRATECLASS::iterator iter = m_mapControl.find(strClassName);
if ( iter == m_mapControl.end()) {
return NULL;
Expand All @@ -73,6 +74,7 @@ namespace DuiLib

void CControlFactory::RegistControl(CDuiString strClassName, CreateClass pFunc)
{
strClassName.MakeLower();
m_mapControl.insert(MAP_DUI_CTRATECLASS::value_type(strClassName, pFunc));
}

Expand Down

0 comments on commit 62d5879

Please sign in to comment.