duilib的一些bug

来源:互联网 发布:osi网络层 编辑:程序博客网 时间:2024/06/02 21:02

duilib是一个开源的界面库,我的一个软件--小妞会装机就是用它做界面库。小妞会装机这个软件界面比较简单,就用到了一些基本控件,所以用duilib是挺合适的。但是有个问题真是让人郁闷,那就是它的界面编辑器总是崩溃。看来duilib用的人还是很少,要不不会有这么多问题。我自己是不能忍受了,就把这个bug改了一下。本想将修复代码提交给duilib,但是申请加入duilib群没有成功。算了,贴在这儿吧。如果有人正遇到这个问题倒是可以做一个参考。

出问题的地方:

void CLayoutManager::TestForm(LPCTSTR pstrFile){CFormTestWnd* pFrame=new CFormTestWnd();CPaintManagerUI* pManager=new CPaintManagerUI();SIZE size=m_Manager.GetInitSize();pManager->SetInitSize(size.cx,size.cy);pManager->SetSizeBox(m_Manager.GetSizeBox());RECT rect=m_Manager.GetCaptionRect();if (rect.bottom==0){rect.bottom=30;}pManager->SetCaptionRect(rect);size=m_Manager.GetRoundCorner();pManager->SetRoundCorner(size.cx,size.cy);size=m_Manager.GetMinInfo();pManager->SetMinInfo(size.cx,size.cy);size=m_Manager.GetMaxInfo();pManager->SetMaxInfo(size.cx,size.cy);pManager->SetShowUpdateRect(m_Manager.IsShowUpdateRect());if( pFrame == NULL )return;g_HookAPI.EnableInvalidate(false);pFrame->SetManager(pManager);HWND h_wnd =pFrame->Create(m_Manager.GetPaintWindow(),_T("FormTest"),UI_WNDSTYLE_FRAME,0,0,0,size.cx,size.cy);// CControlUI* pRoot=CloneControls(GetForm()->GetItemAt(0));// 使用新建的XML树来预览,不会挂掉pManager->Init(h_wnd);CDialogBuilder builder;CContainerUI* pRoot=static_cast<CContainerUI*>(builder.Create(pstrFile,(UINT)0,NULL,pManager));if(pRoot==NULL)return;//pRoot->SetManager(NULL,NULL);pFrame->SetRoot(pRoot);pFrame->Init();pFrame->CenterWindow();HWND m_hWnd=pFrame->GetHWND();MSG msg = { 0 };while( ::IsWindow(m_hWnd) && ::GetMessage(&msg, NULL, 0, 0) ) {if( msg.hwnd != m_hWnd ) {if( (msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST) )continue;if( msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST ) continue;if( msg.message == WM_SETCURSOR )continue;}if( !CPaintManagerUI::TranslateMessage(&msg) ) {::TranslateMessage(&msg);::DispatchMessage(&msg);}if( msg.message == WM_QUIT ) break;}if( msg.message == WM_QUIT ) ::PostQuitMessage(msg.wParam);g_HookAPI.EnableInvalidate(true);DeleteFile(pstrFile);}

改为

void CLayoutManager::TestForm(LPCTSTR pstrFile){CFormTestWnd* pFrame=new CFormTestWnd();CPaintManagerUI* pManager=new CPaintManagerUI();SIZE size=m_Manager.GetInitSize();pManager->SetInitSize(size.cx,size.cy);pManager->SetSizeBox(m_Manager.GetSizeBox());RECT rect=m_Manager.GetCaptionRect();if (rect.bottom==0){rect.bottom=30;}pManager->SetCaptionRect(rect);size=m_Manager.GetRoundCorner();pManager->SetRoundCorner(size.cx,size.cy);size=m_Manager.GetMinInfo();pManager->SetMinInfo(size.cx,size.cy);size=m_Manager.GetMaxInfo();pManager->SetMaxInfo(size.cx,size.cy);pManager->SetShowUpdateRect(m_Manager.IsShowUpdateRect());if( pFrame == NULL )return;g_HookAPI.EnableInvalidate(false);pFrame->SetManager(pManager);HWND h_wnd =pFrame->Create(m_Manager.GetPaintWindow(),_T("FormTest"),UI_WNDSTYLE_FRAME,0,0,0,size.cx,size.cy);// CControlUI* pRoot=CloneControls(GetForm()->GetItemAt(0));// 使用新建的XML树来预览,不会挂掉pManager->Init(h_wnd);CDialogBuilder builder;CContainerUI* pRoot=static_cast<CContainerUI*>(builder.Create(pstrFile,(UINT)0,NULL,pManager));if(pRoot==NULL)return;//pRoot->SetManager(NULL,NULL);pFrame->SetRoot(pRoot);pFrame->Init();pFrame->CenterWindow();// 修正win7下TestForm一开始没有反应,必须先激活其它程序在切换到TestFrom才有反应的bugpFrame->ShowModal();//HWND m_hWnd=pFrame->GetHWND();//MSG msg = { 0 };//while( ::IsWindow(m_hWnd) && ::GetMessage(&msg, NULL, 0, 0) ) {//if( msg.hwnd != m_hWnd ) {//if( (msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST) )//continue;//if( msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST ) //continue;//if( msg.message == WM_SETCURSOR )//continue;//}//if( !CPaintManagerUI::TranslateMessage(&msg) ) {//::TranslateMessage(&msg);//::DispatchMessage(&msg);//}//if( msg.message == WM_QUIT ) break;//}//if( msg.message == WM_QUIT ) ::PostQuitMessage(msg.wParam);g_HookAPI.EnableInvalidate(true);DeleteFile(pstrFile);}

就好了

原创粉丝点击