调用函数的时候,界面能生成,但是还是有错误提示,提示的是Debug Assertion Failed,如果把调用函数注释掉,就能正常显示图片界面(图形界面用xml写的),主函数中调用SetStation出错。
#pragma once
#include
#include
#include
#include
using namespace DuiLib;
#ifdef _DEBUG
ifdef _UNICODE
pragma comment(lib, "DuiLib_ud.lib")
else
pragma comment(lib, "DuiLib_d.lib")
endif
#else
ifdef _UNICODE
pragma comment(lib, "DuiLib_u.lib")
else
pragma comment(lib, "DuiLib.lib")
endif
#endif
struct station{
char StationName[13];
char* pOption;
char* pLabel;
};
enum StopStationState
{
NotArrive,// 未到站
STOPED,// 已到站
WillArrive,// 将到站
};
class CDuiFrameWnd : public WindowImplBase
{
public:
virtual LPCTSTR GetWindowClassName() const { return _T("DUIMainFrame"); }
virtual CDuiString GetSkinFile() { return _T("Qtitle.xml"); }
virtual CDuiString GetSkinFolder() { return _T(""); }
//duilib窗口的初始化函数
void InitWindow()
{
// SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); //窗口的最大化
//struct station cStation = {"佛主岭","Fontc1","surebtn"} ,cStation1,cStation2,cStation3,cStation4,cStation5,cStation6;
struct station cStation[13] = {{"佛主岭","Fontc1","surebtn"},{"高新五路","Fontc2","surebtn"},{"高新四路","Fontc3","surebtn"},{"流芳园大街","Fontc4","surebtn"},
{"工程大学","Fontc5","surebtn"},{"光谷大道","Fontc6","surebtn"}};
//strcpy(cStation.StationName,"佛主岭");
/* CButtonUI* p_surebtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("surebtn")));
//这里获取到的指针可能是空的,可以断点看看
CComboUI* pAccountCombo = static_cast<CComboUI*>(m_pm.FindControl(_T("StationMess")));
CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
//指针判断,如果指针为空,直接操作会崩溃?所以都需要判断下,程序健壮性
if(pAccountCombo && pAccountEdit)pAccountEdit->SetText(pAccountCombo->GetText());
pAccountEdit->SetFocus(); */
}
void SetStation(char* station, bool bOpenDoor, StopStationState StationState, bool bShowStopStationPage)
{
//btnopenDoor.Selected();
COptionUI* m_Opendoor = static_cast<COptionUI*>(m_pm.FindControl(_T("OpenDoor")));
COptionUI* m_ShowPage = static_cast<COptionUI*>(m_pm.FindControl(_T("Gloa2")));
m_Opendoor->Selected(bOpenDoor);
m_ShowPage->Selected(bShowStopStationPage);
}
/* void OnPrepare(){
CComboUI* pStationCombo = static_cast(m_pm.FindControl(_T("StationMess")));
}*/
virtual void Notify(TNotifyUI& msg)
{
if(msg.sType == _T("click"))
{
if(msg.pSender->GetName() == _T("p_surebtn"))
{
COptionUI* pControl = static_cast<COptionUI*>(m_pm.FindControl(_T("StationChoice")));
}
}
else if(msg.sType == _T("itemselect"))
{
if(msg.pSender->GetName() == _T("StationMess"))
{
//代码有问题,m_pm未初始化???
// CComboUI* pAccountCombo = static_cast<CComboUI*>(m_pm.FindControl(_T("StationMess")));
// pAccountCombo->GetText();
}
}
}
public:
CPaintManagerUI m_pm;
private:
CButtonUI* p_surebtn;
};
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
CPaintManagerUI::SetInstance(hInstance);
CDuiFrameWnd duiFrame;
duiFrame.Create(NULL, _T("DUIWnd"), WS_VISIBLE | WS_POPUP, WS_EX_WINDOWEDGE);
//duiFrame.SetStation("流芳园大街", false, STOPED,true);
duiFrame.CenterWindow();
duiFrame.ShowModal();
return 0;
}