Dui中函数说明2

客户端

       目前客户端的实现,不少大公司采用了较为新潮的Direct UI技术,本项目中也考虑使用Direct UI,但可惜微软并没有提供可使用的Direct UI 封装,因此我们自己设计实现Direct UI,并在此基础上实现客户端UI部分的功能。

       Direct UI 框架的实现并不复杂,就是繁琐,如抽象窗口,控件自绘制,设计完成消息循环与映射,资源管理...

      

       CWinWnd: 注册创建主窗口,也是唯一具备Win 窗口句柄的窗口,其他一切控件子窗口,均绘制在此窗口上,维持逻辑存在。

       具体实现如下:

       头文件:

  1. #ifndef H_WINWND_H  
  2. #define H_WINWND_H  
  3. #include "CTypeDef.h"  
  4. #include "UIStructDef.h"  
  5. #include "UIMSGMgr.h"  
  6. #include <map>  
  7.   
  8. class CWinWnd : public IWinWnd  
  9. {  
  10. public:  
  11.     CWinWnd(void);  
  12.     virtual ~CWinWnd(void);  
  13.   
  14.     BOOL RegWinClass( HINSTANCE hInstance = NULL);                                                      // 注册窗口类  
  15.   
  16.       
  17.     HWND Create(HWND ahwndParent, LPCTSTR apstrName, DWORD adwStyle, DWORD adwExStyle,                  // 创建窗口  
  18.                 const RECT arc, HMENU ahMenu = NULL, HINSTANCE hInstance = NULL);  
  19.       
  20.     HWND Create(HWND ahwndParent, LPCTSTR apstrName, DWORD adwStyle, DWORD adwExStyle,                  // 创建窗口  
  21.                 int ax = CW_USEDEFAULT, int ay = CW_USEDEFAULT, int acx = CW_USEDEFAULT,   
  22.                 int acy = CW_USEDEFAULT, HMENU ahMenu = NULL, HINSTANCE hInstance = NULL);  
  23.   
  24.     void SetWndInfo(HINSTANCE ahInstance, ULong aulStyle,ULong aulStyleEx, int aiXVertex, int aiYVertex, int aiWeigth, int aiHeigth, HMENU ahMenu = NULL);              // 设置大小信息  
  25.   
  26.   
  27.     void ShowWindow(BOOL bShow /*= true*/BOOL bTakeFocus /*= false*/);                                // 显示窗口  
  28.     static LRESULT CALLBACK   
  29.         __WndProc(HWND ahWnd, UINT auMsg, WPARAM awParam, LPARAM alParam);                              // 消息回调   
  30.     HWND Subclass(HWND hWnd);                                                                           // 子类化  
  31.     void Unsubclass(void);                                                                              // 反子类化  
  32.     void SetIcon(UINT nRes);                                                                            // 设置图标  
  33.     void CenterWindow(void);                                                                            // 居中  
  34.     void Close(UINT nRet);                                                                              // 关闭  
  35.     UINT ShowModal(void);                                                                               // ???  
  36.       
  37. //protected:  
  38. protected:  
  39.     virtual LRESULT   
  40.         HandleMessage(UINT auMsg, WPARAM awParam, LPARAM alParam);                                      // 消息处理  
  41.     virtual void   
  42.         OnFinalMessage(HWND ahWnd);                                                                     // 退出  
  43.     virtual void   
  44.         SetWinClassName(TCHAR* apClassName);                                                            // 设置注册类名称  
  45.     virtual LPCTSTR   
  46.         GetWinClassName(voidconst;                                                                    // 获得注册类名称  
  47.     virtual void   
  48.         SetWinName(TCHAR* apClassName);                                                                 // 设置窗口名称  
  49.     virtual LPCTSTR   
  50.         GetWinName(voidconst;                                                                         // 获得窗口名称  
  51.     virtual void                                                                                          
  52.         SetXmlFile(TCHAR* apXmlFile);                                                                   // 设置Xml文件名称  
  53.     virtual LPCTSTR                                                                                       
  54.         GetXmlFile(voidconst;                                                                         // 获得Xml文件名称  
  55.   
  56. protected:  
  57.     HWND            m_hWnd;                                                                             // 窗口句柄  
  58.     WNDPROC         m_OldWndProc;                                                                       // 旧的消息回调  
  59.     bool            m_bSubclassed;                                                                      // 子窗口  
  60.     TCHAR           m_lszRegClassName[MAX_PATH+1];                                                      // 窗口注册类名称  
  61.     TCHAR           m_lszWndName[MAX_PATH+1];                                                           // 窗口名称  
  62.     TCHAR           m_szXmlFile[MAX_PATH+1];                                                                // 界面配置文件名称  
  63.   
  64.     TCHAR           m_lszInstancePath[MAX_PATH+1];                                                        
  65.     TCHAR           m_lszCurPath[MAX_PATH+1];                                                         
  66.   
  67.     CMSGMgr         m_oMsgMgr;                                                                          // 对象消息处理  
  68.     CUIBaseCtrl*    m_pRootCtrl;                                                                        // 根控件  
  69.     CUICache*       m_pUICache;                                                                         // 界面资源缓存  
  70.   
  71.     int             m_iXVertex;                                                                                                                                                   
  72.     int             m_iYVertex;  
  73.     int             m_iWeigth;  
  74.     int             m_iHeigth;  
  75.     HMENU           m_hMenu;  
  76.     ULong           m_ulStyle;  
  77.     ULong           m_ulStyleEx;  
  78.     HINSTANCE       m_hInstance;  
  79. };  
  80. #endif//H_WINWND_H    


实现文件:

  1. #include "StdAfx.h"  
  2. #include "UIWinWnd.h"  
  3. #include <afxwin.h>  
  4.   
  5.   
  6. CWinWnd::CWinWnd(void)   
  7. : m_hWnd(NULL)  
  8. , m_OldWndProc(::DefWindowProc)  
  9. , m_iXVertex(CW_USEDEFAULT)  
  10. , m_iYVertex(CW_USEDEFAULT)  
  11. , m_iWeigth(CW_USEDEFAULT)  
  12. , m_iHeigth(CW_USEDEFAULT)  
  13. , m_hMenu(NULL)  
  14. , m_hInstance(NULL)  
  15. , m_pUICache(NULL)  
  16.   
  17. {  
  18.     memset(m_lszRegClassName, 0, sizeof(TCHAR)*(MAX_PATH+1));  
  19.     memset(m_lszInstancePath, 0, sizeof(TCHAR)*(MAX_PATH+1));  
  20.     memset(m_lszCurPath, 0, sizeof(TCHAR)*(MAX_PATH+1));  
  21.     memset(m_lszWndName, 0, sizeof(TCHAR)*(MAX_PATH+1));  
  22.     memset(m_szXmlFile, 0, sizeof(TCHAR)*(MAX_PATH+1));  
  23.     m_pUICache = CUICache::GetSigoObj();  
  24. }  
  25.   
  26.   
  27. CWinWnd::~CWinWnd(void)  
  28. {  
  29. }  
  30.   
  31. LRESULT CALLBACK CWinWnd::__WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)  
  32. {  
  33.     CWinWnd* pThis = NULL;  
  34.     if( uMsg == WM_NCCREATE )   
  35.     {  
  36.         LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);  
  37.         pThis = static_cast<CWinWnd*>(lpcs->lpCreateParams);  
  38.           
  39.         if (pThis)  
  40.         {  
  41.             pThis->m_hWnd = hWnd;  
  42.             ::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LPARAM>(pThis));  
  43.         }  
  44.     }   
  45.     else   
  46.     {  
  47.         pThis = reinterpret_cast<CWinWnd*>(::GetWindowLongPtr(hWnd, GWLP_USERDATA));  
  48.         if( uMsg == WM_NCDESTROY && pThis != NULL )   
  49.         {  
  50.             LRESULT lRes = ::CallWindowProc(pThis->m_OldWndProc, hWnd, uMsg, wParam, lParam);  
  51.             ::SetWindowLongPtr(pThis->m_hWnd, GWLP_USERDATA, 0L);  
  52.   
  53.             if( pThis->m_bSubclassed )   
  54.             {  
  55.                 // pThis->Unsubclass();  
  56.             }  
  57.   
  58.             pThis->m_hWnd = NULL;  
  59.             pThis->OnFinalMessage(hWnd);  
  60.             return lRes;  
  61.         }  
  62.     }  
  63.     if( pThis != NULL )   
  64.         return pThis->HandleMessage(uMsg, wParam, lParam);  
  65.     else   
  66.         return ::DefWindowProc(hWnd, uMsg, wParam, lParam);  
  67. }  
  68.   
  69. LRESULT CWinWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)  
  70. {  
  71.     return ::CallWindowProc(m_OldWndProc, m_hWnd, uMsg, wParam, lParam);  
  72. }  
  73.   
  74. void CWinWnd::OnFinalMessage(HWND /*hWnd*/)  
  75. {  
  76. }  
  77.   
  78. // 注册窗口类  
  79. BOOL CWinWnd::RegWinClass(HINSTANCE hInstance)  
  80. {  
  81.     m_hInstance = hInstance;  
  82.     if (!m_pUICache)  
  83.         return FALSE;  
  84.       
  85.     m_pUICache->SetInstance(hInstance);  
  86.     // 初始化应用程序路径  
  87.     m_pUICache->GetInstancePath(m_lszInstancePath);  
  88.     m_pUICache->SetResPackPath(m_lszInstancePath);  
  89.     m_pUICache->GetCurrentPath(m_lszCurPath);  
  90.   
  91.     WNDCLASS wc = {0};  
  92.     wc.style = CS_DBLCLKS;                      
  93.     wc.cbClsExtra = 0;  
  94.     wc.cbWndExtra = 0;  
  95.     wc.hIcon = NULL;  
  96.     wc.lpfnWndProc = CWinWnd::__WndProc;  
  97.     wc.hInstance = hInstance;  
  98.     wc.hInstance = NULL;  
  99.     wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);  
  100.     wc.hbrBackground = NULL;  
  101.     wc.lpszMenuName  = NULL;  
  102.     wc.lpszClassName = GetWinClassName();  
  103.     ATOM ret = ::RegisterClass(&wc);  
  104.     ASSERT((NULL !=  ret)  || (::GetLastError()==ERROR_CLASS_ALREADY_EXISTS));  
  105.     return (ret != NULL) || ::GetLastError() == ERROR_CLASS_ALREADY_EXISTS;  
  106. }  
  107.   
  108. HWND CWinWnd::Create(HWND ahwndParent, LPCTSTR apstrName, DWORD adwStyle, DWORD adwExStyle, const RECT arc, HMENU ahMenu, HINSTANCE hInstance)  
  109. {  
  110.     return Create(ahwndParent, apstrName, adwStyle, adwExStyle, arc.left, arc.top, arc.right - arc.left, arc.bottom - arc.top, ahMenu, hInstance);  
  111. }  
  112.   
  113. HWND CWinWnd::Create(HWND ahwndParent, LPCTSTR apstrName, DWORD adwStyle, DWORD adwExStyle, int ax, int ay, int acx, int acy, HMENU ahMenu, HINSTANCE ahInstance)  
  114. {  
  115.     if (GetWinClassName() && RegWinClass(ahInstance))  
  116.     {  
  117.         m_hWnd = ::CreateWindowEx(adwExStyle, GetWinClassName(), apstrName, adwStyle, ax, ay, acx, acy, ahwndParent, ahMenu, ahInstance, this);  
  118.         ASSERT(m_hWnd!=NULL);  
  119.         return m_hWnd;  
  120.     }  
  121.     return NULL;  
  122. }  
  123.   
  124. void CWinWnd::ShowWindow(BOOL bShow /*= true*/BOOL bTakeFocus /*= false*/)  
  125. {  
  126.     ASSERT(::IsWindow(m_hWnd));  
  127.     if( !::IsWindow(m_hWnd) ) return;  
  128.     ::ShowWindow(m_hWnd, bShow ? (bTakeFocus ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE) : SW_HIDE);  
  129. }  
  130.   
  131.   
  132.   
  133. // 加载初始控件  
  134. void CWinWnd::SetWndInfo(HINSTANCE ahInstance, ULong aulStyle,ULong aulStyleEx, int aiXVertex, int aiYVertex, int aiWeigth, int aiHeigth, HMENU ahMenu)  
  135. {  
  136.     m_ulStyle   = aulStyle;  
  137.     m_ulStyleEx = aulStyleEx;  
  138.     m_iXVertex  = aiXVertex;  
  139.     m_iYVertex  = aiYVertex;  
  140.     m_iWeigth   = aiWeigth;  
  141.     m_iHeigth   = aiHeigth;  
  142.     m_hMenu     = ahMenu;  
  143.     m_hInstance = ahInstance;  
  144. }  
  145.   
  146. // 设置注册类名称  
  147. void CWinWnd::SetWinClassName(TCHAR* apClassName)  
  148. {  
  149.     if (!apClassName)  
  150.         return;  
  151.   
  152.  #ifdef UNICODE  
  153.     memcpy(m_lszRegClassName, apClassName, sizeof(TCHAR)*wcslen(apClassName));  
  154.  #else  
  155.     memcpy(m_lszRegClassName, apClassName, strlen(apClassName));  
  156.  #endif  
  157. }  
  158.   
  159. // 获得注册类名称  
  160. LPCTSTR CWinWnd::GetWinClassName(voidconst  
  161. {  
  162.     return m_lszRegClassName;  
  163. }         
  164.   
  165. // 设置窗口名称  
  166. void CWinWnd::SetWinName(TCHAR* apWndName)  
  167. {  
  168.     if (!apWndName)  
  169.         return;  
  170. #ifdef UNICODE  
  171.     memcpy(m_lszWndName, apWndName, sizeof(TCHAR)*wcslen(apWndName));  
  172. #else  
  173.     memcpy(m_lszWndName, apWndName, strlen(apWndName));  
  174. #endif  
  175.   
  176. }  
  177. // 获得Xml文件名称  
  178. LPCTSTR CWinWnd::GetWinName(voidconst  
  179. {  
  180.     return m_lszWndName;  
  181. }     
  182.   
  183. // 设置Xml文件名称  
  184. void CWinWnd::SetXmlFile(TCHAR* apXmlFile)  
  185. {  
  186.     if (!apXmlFile)  
  187.         return;  
  188. #ifdef UNICODE  
  189.     memcpy(m_szXmlFile, apXmlFile, sizeof(TCHAR)*wcslen(apXmlFile));  
  190. #else  
  191.     memcpy(m_szXmlFile, apXmlFile, strlen(apXmlFile));  
  192. #endif  
  193.   
  194. }  
  195. // 获得窗口名称  
  196. LPCTSTR CWinWnd::GetXmlFile(voidconst  
  197. {  
  198.     return m_szXmlFile;  
  199. }                                                                     
  200.   
  201.   
  202.   
  203. HWND CWinWnd::Subclass(HWND hWnd)  
  204. {  
  205.     ASSERT(::IsWindow(hWnd));  
  206.     ASSERT(m_hWnd==NULL);  
  207.     m_OldWndProc = SubclassWindow(hWnd, __WndProc);  
  208.     if( m_OldWndProc == NULL ) return NULL;  
  209.     m_bSubclassed = true;  
  210.     m_hWnd = hWnd;  
  211.     return m_hWnd;  
  212. }  
  213.   
  214. void CWinWnd::Unsubclass()  
  215. {  
  216.     ASSERT(::IsWindow(m_hWnd));  
  217.     if( !::IsWindow(m_hWnd) ) return;  
  218.     if( !m_bSubclassed ) return;  
  219.     SubclassWindow(m_hWnd, m_OldWndProc);  
  220.     m_OldWndProc = ::DefWindowProc;  
  221.     m_bSubclassed = false;  
  222. }  
  223.   
  224. UINT CWinWnd::ShowModal()  
  225. {  
  226.     ASSERT(::IsWindow(m_hWnd));  
  227.     UINT nRet = 0;  
  228.     HWND hWndParent = GetWindowOwner(m_hWnd);  
  229.     ::ShowWindow(m_hWnd, SW_SHOWNORMAL);  
  230.     ::EnableWindow(hWndParent, FALSE);  
  231.     MSG msg = { 0 };  
  232.     while( ::IsWindow(m_hWnd) && ::GetMessage(&msg, NULL, 0, 0) )   
  233.     {  
  234.         if( msg.message == WM_CLOSE && msg.hwnd == m_hWnd )   
  235.         {  
  236.             nRet = msg.wParam;  
  237.             ::EnableWindow(hWndParent, TRUE);  
  238.             ::SetFocus(hWndParent);  
  239.         }  
  240.         //if( !CPaintManagerUI::TranslateMessage(&msg) )   
  241.         {  
  242.             ::TranslateMessage(&msg);  
  243.             ::DispatchMessage(&msg);  
  244.         }  
  245.         if( msg.message == WM_QUIT ) break;  
  246.     }  
  247.     ::EnableWindow(hWndParent, TRUE);  
  248.     ::SetFocus(hWndParent);  
  249.     if( msg.message == WM_QUIT ) ::PostQuitMessage(msg.wParam);  
  250.     return nRet;  
  251. }  
  252.   
  253. void CWinWnd::Close(UINT nRet)  
  254. {  
  255.     ASSERT(::IsWindow(m_hWnd));  
  256.     if( !::IsWindow(m_hWnd) ) return;  
  257.     ::PostMessage(m_hWnd, WM_CLOSE, (WPARAM)nRet, 0L);  
  258. }  
  259.   
  260. void CWinWnd::CenterWindow()  
  261. {  
  262.     ASSERT(::IsWindow(m_hWnd));  
  263.     ASSERT((GetWindowStyle(m_hWnd)&WS_CHILD)==0);  
  264.     RECT rcDlg = { 0 };  
  265.     ::GetClientRect(m_hWnd, &rcDlg);  
  266.     RECT rcArea = { 0 };  
  267.     RECT rcCenter = { 0 };  
  268.     HWND hWndParent = ::GetParent(m_hWnd);  
  269.     HWND hWndCenter = ::GetWindowOwner(m_hWnd);  
  270.     ::SystemParametersInfo(SPI_GETWORKAREA, NULL, &rcArea, NULL);  
  271.     if( hWndCenter == NULL ) rcCenter = rcArea; else ::GetClientRect(hWndCenter, &rcCenter);  
  272.   
  273.     int DlgWidth = rcDlg.right - rcDlg.left;  
  274.     int DlgHeight = rcDlg.bottom - rcDlg.top;  
  275.   
  276.     // Find dialog's upper left based on rcCenter  
  277.     int xLeft = (rcCenter.left + rcCenter.right) / 2 - DlgWidth / 2;  
  278.     int yTop = (rcCenter.top + rcCenter.bottom) / 2 - DlgHeight / 2;  
  279.   
  280.     // The dialog is outside the screen, move it inside  
  281.     if( xLeft < rcArea.left ) xLeft = rcArea.left;  
  282.     else if( xLeft + DlgWidth > rcArea.right ) xLeft = rcArea.right - DlgWidth;  
  283.     if( yTop < rcArea.top ) yTop = rcArea.top;  
  284.     else if( yTop + DlgHeight > rcArea.bottom ) yTop = rcArea.bottom - DlgHeight;  
  285.     ::SetWindowPos(m_hWnd, NULL, xLeft, yTop, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);  
  286. }  
  287.   
  288. void CWinWnd::SetIcon(UINT nRes)  
  289. {  
  290.     HICON hIcon = (HICON)::LoadImage(m_hInstance, MAKEINTRESOURCE(nRes), IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);  
  291.     ASSERT(hIcon);  
  292.     ::SendMessage(m_hWnd, WM_SETICON, (WPARAM) TRUE, (LPARAM) hIcon);  
  293.     hIcon = (HICON)::LoadImage(m_hInstance, MAKEINTRESOURCE(nRes), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);  
  294.     ASSERT(hIcon);  
  295.     ::SendMessage(m_hWnd, WM_SETICON, (WPARAM) FALSE, (LPARAM) hIcon);  
  296. }  


 窗体控件构建:CUIBuilder 解析配置文件,构建出窗口上的个个控件窗口(类似于MFC的 Dialog)

头文件:

  1. class CUIBuilder : public CWinWnd  
  2. {  
  3. public:  
  4.     CUIBuilder(void);  
  5.     virtual ~CUIBuilder(void);  
  6.   
  7. public:  
  8.     BOOL InitUIBuilder( TCHAR*  apClass, TCHAR* apZipPack, TCHAR* apXmlFile, TCHAR* apWndName, HWND ahwndParent, DWORD  adwStyle,   
  9.                         DWORD   adwExStyle, int ax, int ay, int acx, int    acy,   
  10.                         HMENU   ahMenu, HINSTANCE ahInstance);  
  11.   
  12.     BOOL DoModule(void);  
  13. private:  
  14.     CUIBaseCtrl* LoadCtrls(TCHAR* apXmlFileName);  
  15.     LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);  
  16.       
  17. };  


实现文件:

  1. #include "StdAfx.h"  
  2. #include "UIBuilder.h"  
  3.   
  4. CUIBuilder::CUIBuilder(void)   
  5. {  
  6. }  
  7.   
  8. CUIBuilder::~CUIBuilder(void)  
  9. {  
  10. }  
  11.   
  12.   
  13. CUIBaseCtrl* CUIBuilder::LoadCtrls(TCHAR* apXmlFileName)  
  14. {  
  15.     // 范例代码 这里在窗体上创建了三个逻辑子窗口  
  16.   
  17.     //【区域控件】  
  18.     CUIBaseCtrl* lAreaCtrl = new CUIAreaCtrl(m_pUICache, m_hWnd);  
  19.     RECT loRect;  
  20.     ::GetClientRect(m_hWnd, &loRect);  
  21.     lAreaCtrl->SetRect(loRect);  
  22.     lAreaCtrl->SetBkColor(0x01FFFFFF);  
  23.     lAreaCtrl->SetCtrlID(1);  
  24.   
  25.     //【子按钮控件】  
  26.     CUIBaseCtrl* lpCtrl = new CUIButton(m_pUICache, m_hWnd);   
  27.     lpCtrl->SetRect(0,0, 500, 500);  
  28.     lpCtrl->SetBkColor(0x02FFFFFF);  
  29.     lpCtrl->SetBkImage(_T("file=\"SysBk.png\"  source=\"0,0,0,0\"  corner=\"10,10,10,10\""));  
  30.     lpCtrl->SetCtrlID(2);  
  31.     lAreaCtrl->AddChildCtrl(lpCtrl);  
  32.       
  33.     //【嵌套子按钮控件】  
  34.     CUIBaseCtrl* lpCtrlBt = new CUIButton(m_pUICache, m_hWnd);  
  35.     lpCtrlBt->SetRect(10,10, 200, 200);  
  36.     lpCtrlBt->SetBkColor(0x02FFFFFF);  
  37.     lpCtrlBt->SetCtrlID(3);  
  38.     lpCtrl->AddChildCtrl(lpCtrlBt);  
  39.   
  40.    
  41.     return lAreaCtrl;  
  42. }  
  43.   
  44. LRESULT CUIBuilder::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)  
  45. {  
  46.     LRESULT lRes = 0;  
  47.     BOOL bHandled = FALSE;  
  48.   
  49.     if( bHandled )   
  50.         return lRes;  
  51.     if(!m_oMsgMgr.MessageHandler(uMsg, wParam, lParam, lRes) )   
  52.         return lRes;  
  53.     return CWinWnd::HandleMessage(uMsg, wParam, lParam);  
  54. }  
  55.   
  56. BOOL CUIBuilder::InitUIBuilder( TCHAR*  apClass, TCHAR* apZipPack,TCHAR* apXmlFile, TCHAR* apWndName, HWND ahwndParent,  DWORD  adwStyle,   
  57.                                 DWORD   adwExStyle, int ax, int ay, int acx, int    acy,   
  58.                                 HMENU   ahMenu, HINSTANCE ahInstance)  
  59. {  
  60.     // 设置资产类名称  
  61.     SetWinClassName(apClass);  
  62.     // 设置窗口名称  
  63.     SetWinName(apWndName);  
  64.     // 设置界面配置文件名称  
  65.     SetXmlFile(apXmlFile);  
  66.     // 设置窗口信息大小  
  67.     SetWndInfo(ahInstance, adwStyle, adwExStyle, ax, ay, acx, acy,ahMenu);  
  68.     // 设置资源文件压缩包路径  
  69.     if (m_pUICache) m_pUICache->SetResPackName(apZipPack);  
  70.     return TRUE;  
  71. }  
  72.   
  73. BOOL CUIBuilder::DoModule(void)  
  74. {  
  75.     // 创建窗口  
  76.     if (!Create(NULL, m_lszWndName, m_ulStyle, m_ulStyleEx , m_iXVertex, m_iYVertex, m_iWeigth, m_iHeigth, m_hMenu, m_hInstance))  
  77.         return FALSE;  
  78.     // 加载控件配置文件创建控件  
  79.     m_pRootCtrl = LoadCtrls(m_szXmlFile);  
  80.     if (!m_pRootCtrl)  
  81.         return FALSE;  
  82.     m_oMsgMgr.InitMsgMgr(m_hWnd, m_pRootCtrl);  
  83.     ShowWindow(TRUE, FALSE);  
  84.   
  85.     CMSGMgr::MSGLoop();  
  86.     return TRUE;  
  87. }  


 

 

附窗体构建后的图:

 

 

 后续继续补充 消息循环映射处理, 控件构建,渲染等内容。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值