大理石上粘胶怎么清除:MFC中使用Duilib

来源:百度文库 编辑:偶看新闻 时间:2024/03/29 19:24:30

在上一篇文章"MFC中使用Duilib--1"中, 没有用到资源文件,即xml,本篇讲怎样加载文件。

1.  在exe输出目录下,创建一个skin目录,里面放入需要用到的图片文件,以及创建一个或几个xml文件,在这里,我创建一个skin.xml文件。内容如下:

view plaincopy to clipboardprint?
  1.   
  2.   
  3.       
  4.           
  5.           
  6.               
  7.               
  8.               
  9.               
  10.           
  11.   


需要用到的资源图片有button_nor.bmp、button_over.bmp、button_down.bmp。

 

再将上节内容中的CTestDlg的HandleMessage函数中的WM_CREATE消息改成如下内容:

view plaincopy to clipboardprint?
  1. LRESULT CTestDlg::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)  
  2. {  
  3.     if( uMsg == WM_CREATE ) {  
  4.         //m_pm.Init(m_hWnd);   
  5.         //CControlUI *pButton = new CButtonUI;   
  6.         //pButton->SetName(_T("closebtn"));   
  7.         //pButton->SetBkColor(0xFFFF0000);   
  8.         //m_pm.AttachDialog(pButton);   
  9.         //m_pm.AddNotifier(this);   
  10.         m_pm.Init(m_hWnd);  
  11.         CDialogBuilder builder;  
  12.         CControlUI *pRoot = builder.Create(L"skin\\skin.xml", (UINT)0, NULL, &m_pm);  
  13.         ASSERT(pRoot && "Failed to parse XML");  
  14.         m_pm.AttachDialog(pRoot);  
  15.         m_pm.AddNotifier(this);  
  16.         return 0;  
  17.     }  
  18.     else if( uMsg == WM_DESTROY ) {  
  19.         ::PostQuitMessage(0);  
  20.     }  
  21.     LRESULT lRes = 0;  
  22.     if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes;  
  23.     return CWindowWnd::HandleMessage(uMsg, wParam, lParam);  
  24.   
  25. }  

编译运行即可