weixin_42163711
神农藏百草
2018-07-02 04:01
采纳率: 78.6%
浏览 648

VC++ 关于函数调用问题

调用函数的时候,界面能生成,但是还是有错误提示,提示的是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;

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • longzhilanyuan
    龙之蓝缘 2018-07-02 08:14
    已采纳

    代码有点乱,看的眼花。没看出来哪里的问题,你试试virtual void Notify(TNotifyUI& msg)把这个函数调用之后还给duilib,你可以中断下看调用堆栈,不知道你用的哪个版本的duilib,duilib本身来说就有BUG,多跟进去看看源码吧。

    点赞 评论
  • weixin_42163711
    神农藏百草 2018-07-02 08:46
      <!--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" />

    这是部分xml内容
    
    点赞 评论

相关推荐