weixin_42163711
神农藏百草
采纳率100%
2018-07-02 01:39

VC++与duilib相关的问题,程序一直报错,我不知道是哪里有问题

20
已采纳

上代码,调试到duiFrame.Create(NULL, _T("DUIWnd"), WS_VISIBLE | WS_POPUP, WS_EX_WINDOWEDGE);这一行还没有报错,然后再下一行就显示错误了。

报错显示Debug Assertion Failed

#pragma once

#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<CComboUI*>(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.CenterWindow();
duiFrame.ShowModal();

return 0;

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • u012081284 只要思想不滑坡 3年前

    一般来讲有两种情况:1.xml内容格式有问题,导致解析错误。这个可以通过预览工具等来排查。2.xml路径不正确。

    点赞 1 评论 复制链接分享