实现 void SetStation(char* station, bool bOpenDoor,StopStationState StationState, bool bShowStopStationPage) 实现二三四三个参数的功能,,第二个参数要求实现能够控制图形界面开关门,第三个是实现三个站点状态正确显示(不抱期望),第四个是图形界面两个页面之间的切换, 第一个参数要求实现图中站点信息显示控制,比如当前站显示为红色,上一站和下一站都是黑色,更上一站显示为灰色。 如果能全部实现这些功能,C币还可以追加。
下面是我自己写的代码,但是功能没有实现。
#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(); */
SetStation("佛主岭",false,STOPED,true);
}
void SetStation(char* station, bool bOpenDoor,StopStationState StationState, bool bShowStopStationPage)
{
//btnopenDoor.Selected();
COptionUI* m_Opendoor = static_cast<COptionUI*>(m_PaintManager.FindControl(_T("OpenDoor")));
COptionUI* m_ShowPage = static_cast<COptionUI*>(m_PaintManager.FindControl(_T("Gloa2")));
m_Opendoor->Selected(true);
m_ShowPage->Selected(false);
}
/* 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_PaintManager.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();
}
}
}
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,false);
duiFrame.CenterWindow();
duiFrame.ShowModal();
return 0;
}
附上一个xml内容:
<?xml version="1.0" encoding="utf-8" ?>
<!--标题栏区图片切换-->
<HorizontalLayout height="84">
<TabLayout name="" float="true" pos="0,0,0,0" width="1628" height="81">
<ChildLayout xmlfile="Tarm1.xml" />
</TabLayout>
<TabLayout name="" float="true" pos="1628,0,0,0" width="292" height="81">
<ChildLayout xmlfile="OVOpen.xml"/>
</TabLayout>
<!--Tab点击-->
<!--标题栏开关门-->
<TabLayout name="tabTest" float="true" pos="1628,0,0,0" width="292" height="81">
<ChildLayout xmlfile="OVOpen.xml" />
<ChildLayout xmlfile="NotOpen.xml" />
</TabLayout>
<!--标题栏 到站信息-->
<TabLayout name="tabTest2" float="true" pos="0,0,0,0" width="1628" height="81">
<ChildLayout xmlfile="Tarmt.xml" />
<ChildLayout xmlfile="Tarm1.xml" />
</TabLayout>
</HorizontalLayout >
<!--客户区代码-->
<HorizontalLayout height="320">
<!--站点图标改变颜色-->
<TabLayout name="Mid" float="true" pos="0,0,0,0" width="1920" height="325">
<ChildLayout xmlfile="Mid.xml" />
</TabLayout>
<!--客户区开关门图片-->
<HorizontalLayout>
<HorizontalLayout>
<TabLayout name="tabTest1" float="true" pos="0,0,0,0" width="1920" height="325">
<ChildLayout xmlfile="SiteMessage2.xml" />
<ChildLayout xmlfile="SiteMessage.xml" />
</TabLayout>
</HorizontalLayout>
<!--中间图片切换-->
<TabLayout name="tabTest3" float="true" pos="0,0,0,0" width="1920" height="325">
<ChildLayout xmlfile="Mid.xml" />
<ChildLayout xmlfile="SiteMessage1.xml" />
</TabLayout>
</HorizontalLayout>
</HorizontalLayout>
<!--下方点击按钮栏-->
<HorizontalLayout >
<Option name="Gloa1" text="即将到达" float="true" pos="1180,10,0,0" width="60" height="24"
bkimage="ggu\a9_1.png" group="tabDemo" selected="true" />
<Option name="Gloa2" text="已到达" float="true" pos="1180,40,0,0" width="60" height="24"
bkimage="ggu\a9.png" group="tabDemo" selected="true" />
<Option name="OpenDoor" text="开门" float="true" pos="1340,10,0,0" width="44" height="24"
bkimage="ggu\a9_1.png" group="tabDemo" selected="true" />
<Option name="NotOpen" text="不开门" float="true" pos="1340,40,0,0" width="44" height="24"
bkimage="ggu\a9.png" group="tabDemo" />
<Option name="NextStation" text="下一站" float="true" pos="1280,10,0,0" width="44" height="24"
bkimage="ggu\a13_1_1.png" group="tabDemo" selected="true" />
<Option name="PrevStation" text="上一站" float="true" pos="1280,40,0,0" width="44" height="24"
bkimage="ggu\a13_1.png" group="tabDemo" />
<Option name="NextStation1" text="Next" float="true" pos="50,10,0,0" width="44" height="24"
bkimage="ggu\a13_1_1.png" group="tabDemo" selected="true" />
<Option name="PrevStation1" text="Prev" float="true" pos="50,40,0,0" width="44" height="24"
bkimage="ggu\a13_1.png" group="tabDemo" />
<Option name="NextStation2" text="Next" float="true" pos="100,10,0,0" width="44" height="24"
bkimage="ggu\a13_1_1.png" group="tabDemo" selected="true" />
<Option name="PrevStation2" text="Prev" float="true" pos="100,40,0,0" width="44" height="24"
bkimage="ggu\a13_1.png" group="tabDemo" />
hotimage="file='ComboBox/Combo_over.bmp' " pushedimage="file='ComboBox/Combo_over.bmp' ">
</HorizontalLayout>
期待各位大佬的答案,谢谢谢谢