从Duilib的HelloWorld来学习!

来源:互联网 发布:梅阿查实况巅峰数据 编辑:程序博客网 时间:2024/05/21 07:01

duilib是一个windows下的皮肤库,用win32写的。。。

先看个效果图吧:

这个图片里有源代码,右键保存下图标,把后缀改为zip,即可。由于skin目录下的图片不便上传,需要自己加入合适的图片。

 

要使用duilib库,必须先把库导入,代码如下:

复制代码
 1 #include "xxx\UIlib.h" //xxx为UIlib.h的路径 2 using namespace Duilib; //Duilib为库自定义的名字空间 3  4 #ifdef _DEBUG 5  #ifdef _UNICODE 6   #pragma comment(lib, "xxx\Duilib_ud.lib") 7  #else 8   #pragma comment(lib, "xxx\Duilib_d.lib") 9  #endif10 #else11  #ifdef _UNICODE12   #progma comment(lib, "xxx\Duilib_u.lib")13  #else14   #progma comment(lib, "xxx\Duilib.lib")15 #endif
复制代码

 

使用duilib库的程序和win32程序一样也是从WinMain开始的。在WinMain函数中,一般是这样做的:

复制代码
1 CPaintManagerUI::SetInstance(hInstance);//将程序实例与皮肤绘制管理器挂钩2 CPaintMamagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + TEXT("skin"));//设置皮肤库的资源路径,资源有图片、xml文件等3 CPaintManagerUI::SetResourceZip(/*路径*/);//皮肤库支持压缩文件,这里指定压缩文件路径4 //new一个类,这个类继承自CWindowWnd类5 //调用类的Create函数创建窗口,这里会发送WM_CREATE消息,而这个类一般会在HandleMessage函数中处理WM_CREATE消息6 //创建完窗口后,可以调用该类的SetIcon(IDI_HW)函数来设置任务栏上显示的图标7 //然后调用CPaintManagerUI::MessageLoop(),进入消息循环
复制代码

在duilib中每个窗口均要定义一个CPaintManagerUI成员对象用来管理整个窗口的绘制。

duilib中的窗口均继承自CWindowWnd类,在CWindowWnd类中有虚函数HandleMessage来处理Windows消息(如WM_CREATE、WM_SIZE等)。另外,如果你的窗口想要响应鼠标的点击、编辑框内容改变等消息的话,可以把你的窗口类继承INotify接口,这样你的窗口上的一个按钮被点击了,可以在继承自INotify接口的Notify函数中进行处理。

在自己定义的窗口类中一般这样来处理HandleMessage:

复制代码
 1 LRESULT CHelloWorld::HandleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam ) 2 { 3     LRESULT lRes = 0;//返回值 4     BOOL bHandled = TRUE;//是否被处理了 5     switch (uMsg) 6     { 7     case WM_CREATE: 8         lRes = OnCreate(uMsg ,wParam, lParam, bHandled); 9         break;10     default:11         bHandled = FALSE; break;12     }13     14     if (bHandled) return lRes;15     if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes) != 0)//没有处理,这传送给窗口绘制管理器处理,Notify函数将会在这里的m_pm.MessageHandler函数中被调用16         return lRes;17     return CWindowWnd::HandleMessage(uMsg, wParam, lParam);//都不处理则有CWindowWnd处理18 }
复制代码

INotifyUI接口的Notify()由CPaintManagerUI::MessageHandler调用。继承INotifyUI接口的类对象会被加入到CPaintManagerUI的m_aNotifiers数组中,而要加入m_aNotifiers数组一般由窗口类自己在OnCreate函数调用CPaintManagerUI的静态方法AddNotifier将自己加入到m_aNotifiers中。

而在自己的窗口类的OnCreate函数中,通常调用m_pm.Init(m_hWnd)来把自己的窗口句柄与窗口绘制管理器挂接在一起,即用于向CPaintManagerUI提供窗口句柄及窗口上下文句柄。

复制代码
 1 LRESULT CHelloWorld::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 2 { 3     m_pm.Init(m_hWnd);    // 把自己的窗口句柄与窗口绘制管理器挂接在一起 4     CDialogBuilder builder; 5     CControlUI* pRoot = builder.Create(TEXT("HelloWorld.xml"), (UINT)0, NULL, &m_pm); // 根据xml中的配置创建控件 6     ASSERT(pRoot && "Failure to parse XML"); 7     m_pm.AttachDialog(pRoot); // 把这些控件绘制到本窗口上 8     m_pm.AddNotifier(this);    // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数 9     Init();10     return 0;11 12 }
复制代码

以上就是关于duilib程序的一个建立过程。


 

贴代码先:

复制代码
 1 // stdafx.h : 标准系统包含文件的包含文件, 2 // 或是经常使用但不常更改的 3 // 特定于项目的包含文件 4 // 5  6 #pragma once 7  8 #define WIN32_LEAN_AND_MEAN             // 从 Windows 头中排除极少使用的资料 9 // Windows 头文件:10 #include <windows.h>11 #include <objbase.h>12 13 // TODO: 在此处引用程序需要的其他头文件14 #include "..\..\DuiLib\UIlib.h"15 16 using namespace DuiLib;17 18 #ifdef _DEBUG19 #   ifdef _UNICODE20 #       pragma comment(lib, "..\\..\\bin\\DuiLib_ud.lib")21 #   else22 #       pragma comment(lib, "..\\..\\bin\\DuiLib_d.lib")23 #   endif24 #else25 #   ifdef _UNICODE26 #       pragma comment(lib, "..\\..\\bin\\DuiLib_u.lib")27 #   else28 #       pragma comment(lib, "..\\..\\bin\\DuiLib.lib")29 #   endif30 #endif
复制代码
复制代码
1 // stdafx.cpp : 只包括标准包含文件的源文件2 // HelloWorld.pch 将作为预编译头3 // stdafx.obj 将包含预编译类型信息4 5 #include "stdafx.h"6 7 // TODO: 在 STDAFX.H 中8 // 引用任何所需的附加头文件,而不是在此文件中引用
复制代码
复制代码
 1 // HelloWorld.h 2 #pragma once 3  4 class CHelloWorld: public CWindowWnd, public INotifyUI    // 继承自CWindowWnd和INotifyUI 5 { 6     ////////////////////////////////////////////////////////////////////////// 7     // 构造函数及自定义函数 8 public: 9     CHelloWorld();10     void Init();    // 界面控件一些初始化、比如某个按钮最开始是禁用状态就应该在这个时候处理...11     void OnOK();    // 点击OK按钮的处理12     void OnClose();    // 点击Close按钮的处理13 14     // WM_CREATE消息的处理15     LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);16     // WM_NCHITTEST消息的处理17     LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);18     LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);19     LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);20     LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);21     LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);22     LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);23 24     //////////////////////////////////////////////////////////////////////////25     // 继承自CWindowWnd类26 public:27     LPCTSTR GetWindowClassName() const ;    // 纯虚函数,必须有实现28     UINT GetClassStyle() const;29     void OnFinalMessage(HWND /*hWnd*/);    // 窗口接收到最后一条消息的处理30     LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);    // 消息响应函数31 32     //////////////////////////////////////////////////////////////////////////33 34     // 继承自INotifyUI接口35 public:36     void Notify(TNotifyUI& msg);37 38     //////////////////////////////////////////////////////////////////////////39 40     // 成员变量41     //////////////////////////////////////////////////////////////////////////42 private:43     CButtonUI*        m_pBtnOK;    // 按钮控件44     CButtonUI*        m_pBtnClose;// 按钮控件45 46     CPaintManagerUI m_pm;    // 窗口绘制器47 };
复制代码
复制代码
  1 // HelloWorld.cpp : 定义应用程序的入口点。  2 //  3   4 #include "stdafx.h"  5 #include "HelloWorld.h"  6 #include "resource.h"  7   8 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)  9 { 10     CPaintManagerUI::SetInstance(hInstance);    // 将程序实例与皮肤绘制管理器挂钩 11     // 设置皮肤库的资源路径,资源有图片、xml文件等 12     CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + TEXT("skin")); 13  14     HRESULT Hr = ::CoInitialize(NULL); 15     if( FAILED(Hr) ) return 0; 16  17     CHelloWorld* pHW = new CHelloWorld(); 18     if (pHW == NULL) 19         return 0; 20     pHW->Create(NULL, TEXT("Hello World"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE | WS_EX_APPWINDOW); 21     pHW->SetIcon(IDI_HW); 22     pHW->CenterWindow(); 23     pHW->ShowWindow(); 24     CPaintManagerUI::MessageLoop(); 25  26     ::CoUninitialize(); 27     return 0; 28 } 29  30 CHelloWorld::CHelloWorld() 31 : m_pBtnOK(NULL) 32 , m_pBtnClose(NULL) 33 { 34  35 } 36  37 void CHelloWorld::Init()    // 本例中此函数其实没有做任何事情 38 { 39     m_pBtnOK = static_cast<CButtonUI *>(m_pm.FindControl(TEXT("OK"))); 40     if (m_pBtnOK == NULL) 41         return; 42     // m_pBtnOK->OnNotify += MakeDelegate(this, &CHelloWorld::OnOK); 43     // MakeDelegate的实现感觉很强大,这样也可以实现把OK按钮的时间转接到OnOK来处理 44  45     m_pBtnClose = static_cast<CButtonUI *>(m_pm.FindControl(TEXT("Close"))); 46     if (m_pBtnClose == NULL) 47         return; 48     //m_pBtnClose->OnNotify += MakeDelegate(this, &CHelloWorld::OnClose); 49 } 50  51 void CHelloWorld::OnOK() 52 { 53     Close();    // CWindowWnd继承来的函数Close,是关闭自己 54 } 55  56 void CHelloWorld::OnClose() 57 { 58     Close(); 59 } 60  61 LPCTSTR CHelloWorld::GetWindowClassName() const 62 { 63     return TEXT("HelloWorld"); 64 } 65  66 UINT CHelloWorld::GetClassStyle() const 67 { 68     return UI_CLASSSTYLE_FRAME | CS_DBLCLKS; 69 } 70  71 void CHelloWorld::OnFinalMessage( HWND /*hWnd*/ ) 72 { 73     delete this; 74 } 75  76 LRESULT CHelloWorld::HandleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam ) 77 { 78     LRESULT lRes = 0; 79     BOOL bHandled = TRUE; 80     switch (uMsg) 81     { 82     case WM_CREATE: 83         lRes = OnCreate(uMsg ,wParam, lParam, bHandled); 84         break; 85  86     case WM_DESTROY: 87         ::PostQuitMessage(0); 88         bHandled = FALSE; 89         break; 90  91     case WM_NCHITTEST: 92         lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); 93         break; 94  95     case WM_KEYDOWN: 96         if (wParam == VK_ESCAPE) 97         { 98             OnClose(); 99         }100         break;101 102     case WM_SIZE:103         lRes = OnSize(uMsg, wParam, lParam, bHandled);104         break;105 106     case WM_NCACTIVATE:107         lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);108         break;109 110     case WM_GETMINMAXINFO:111         lRes = true;112         OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled);        113         break;114 115     case WM_SYSCOMMAND:116         lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); 117         break;118 119     case WM_NCCALCSIZE:120         lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); 121         break;122 123     default:124         bHandled = FALSE; break;125     }126     127     if (bHandled) return lRes;128     if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes) != 0)129         return lRes;130     return CWindowWnd::HandleMessage(uMsg, wParam, lParam);131 }132 133 LRESULT CHelloWorld::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)134 {135     //LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);136     //styleValue &= ~WS_CAPTION;137     //::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);138     //RECT rcClient;139     //::GetClientRect(*this, &rcClient);140     //::SetWindowPos(*this, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, SWP_FRAMECHANGED);141 142     m_pm.Init(m_hWnd);    // 把自己的窗口句柄与窗口绘制管理器挂接在一起143     CDialogBuilder builder;144     // 根据xml的配置来创建控件145     CControlUI* pRoot = builder.Create(TEXT("HelloWorld.xml"), (UINT)0, NULL, &m_pm);146     ASSERT(pRoot && "Failure to parse XML");147     m_pm.AttachDialog(pRoot);    // 把上面的控件绘制到本窗口上,之前有把m_hWnd传给m_pm148     m_pm.AddNotifier(this);    // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数149     Init();150     return 0;151 152 }153 154 LRESULT CHelloWorld::OnSize( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )155 {156     SIZE szRoundCorner = m_pm.GetRoundCorner();    // GetRoundCorner用来获取xml中的Window标签中roundcorner属性值,该值指示圆角的长宽157     if( !::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0) ) {158         CRect rcWnd;159         ::GetWindowRect(*this, &rcWnd);160         rcWnd.Offset(-rcWnd.left, -rcWnd.top);    // rcWnd.right就成为了窗口的宽度了161         rcWnd.right++; rcWnd.bottom++;162         HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);163         ::SetWindowRgn(*this, hRgn, TRUE);    // 窗口圆角化处理164         ::DeleteObject(hRgn);165     }166 167     bHandled = FALSE;168     return 0;169 }170 171 LRESULT CHelloWorld::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)172 {173     POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);174     ::ScreenToClient(*this, &pt);175 176     RECT rcClient;177     ::GetClientRect(*this, &rcClient);178 179     if( !::IsZoomed(*this) ) {180         RECT rcSizeBox = m_pm.GetSizeBox();    // GetSizeBox用来获取xml中Window标签的sizebox属性,该属性指示你的鼠标移动到窗口边框多少个像素会变成指示符(这个指示符表示可以改变窗口大小的指示符)181         if( pt.y < rcClient.top + rcSizeBox.top ) {182             if( pt.x < rcClient.left + rcSizeBox.left ) return HTTOPLEFT;183             if( pt.x > rcClient.right - rcSizeBox.right ) return HTTOPRIGHT;184             return HTTOP;185         }186         else if( pt.y > rcClient.bottom - rcSizeBox.bottom ) {187             if( pt.x < rcClient.left + rcSizeBox.left ) return HTBOTTOMLEFT;188             if( pt.x > rcClient.right - rcSizeBox.right ) return HTBOTTOMRIGHT;189             return HTBOTTOM;190         }191         if( pt.x < rcClient.left + rcSizeBox.left ) return HTLEFT;192         if( pt.x > rcClient.right - rcSizeBox.right ) return HTRIGHT;193     }194 195     RECT rcCaption = m_pm.GetCaptionRect();    // GetCaptionRect用来获取xml中Window标签的caption属性,该属性指示标题栏的大小196     if( pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right && pt.y >= rcCaption.top && pt.y < rcCaption.bottom ) {197             CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));198             if( pControl && _tcsicmp(pControl->GetClass(), _T("ButtonUI")) != 0 && _tcsicmp(pControl->GetClass(), _T("OptionUI")) != 0)199                 return HTCAPTION;200     }201 202     return HTCLIENT;203 }204 205 void CHelloWorld::Notify( TNotifyUI& msg )206 {207     if (msg.sType == TEXT("click"))    // click事件208     {209         if (msg.pSender->GetName() == TEXT("OK"))210             OnOK();211         if (msg.pSender->GetName() == TEXT("Close"))212             OnClose();213     }214     else if (msg.sType == TEXT("windowinit"))215     {216     }217 }218 219 LRESULT CHelloWorld::OnNcActivate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )220 {221     if( ::IsIconic(*this) ) bHandled = FALSE;222     return (wParam == 0) ? TRUE : FALSE;223 }224 225 LRESULT CHelloWorld::OnGetMinMaxInfo( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )226 {227     MONITORINFO oMonitor = {};228     oMonitor.cbSize = sizeof(oMonitor);229     ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor);230     CRect rcWork = oMonitor.rcWork;231     rcWork.Offset(-rcWork.left, -rcWork.top);232 233     LPMINMAXINFO lpMMI = (LPMINMAXINFO) lParam;234     lpMMI->ptMaxPosition.x    = rcWork.left;235     lpMMI->ptMaxPosition.y    = rcWork.top;236     lpMMI->ptMaxSize.x        = rcWork.right;237     lpMMI->ptMaxSize.y        = rcWork.bottom;238 239     bHandled = FALSE;240     return 0;241 }242 243 LRESULT CHelloWorld::OnSysCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )244 {245     if (wParam == SC_CLOSE)246     {247         bHandled = TRUE;248         SendMessage(WM_CLOSE);249         return 0;250     }251 #if defined(WIN32) && !defined(UNDER_CE)252     BOOL bZoomed = ::IsZoomed(*this);253     LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam);254     if( ::IsZoomed(*this) != bZoomed )255     {256     }257 #else258     LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam);259 #endif260     return lRes;261 }262 263 LRESULT CHelloWorld::OnNcCalcSize( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )264 {265     return 0;266     // wParam为TRUE时,返回0将会使窗口的大小变为客户区的大小,也就是说这将把窗口的标题栏、窗口边框移除,只显示客户区267 }
复制代码
复制代码
 1 // xml皮肤配置文件 2 <?xml version="1.0" encoding="utf-8" standalone="yes" ?> 3 <Window size="400,250" caption="0,0,0,30" roundcorner="6,6" sizebox="4,4,4,4" mininfo="100,50" maxinfo="500,300"> 4     <VerticalLayout  bkcolor="#FF000000"> 5         <HorizontalLayout width="400" height="30" bkimage="file=&apos;top_bg.png&apos; corner=&apos;5,5,5,5&apos;"> 6             <HorizontalLayout widht="80"> 7                 <Button name="OK" text="OK" align="center" width="80" height="30" textcolor="#FFC8C8C8" disabletextcolor="#FFA7A6AA" normalimage="file=&apos;BtnOK.png&apos; source=&apos;0,0,80,30&apos;" hotimage="file=&apos;BtnOK.png&apos; source=&apos;80,0,160,30&apos;" pushedimage="file=&apos;BtnOK.png&apos; source=&apos;160,0,240,30&apos;" disabledimage="file=&apos;BtnOK.png&apos; source=&apos;240,0,320,30&apos;" /> 8             </HorizontalLayout> 9             <HorizontalLayout width="240">10                 <Label name="caption" text="Hello World" textcolor="#FFFFFFFF" align="center" />11             </HorizontalLayout>12             <HorizontalLayout widht="80">13                 <Button name="Close" text="Close" align="center" width="79" height="30" textcolor="#FFC8C8C8" disabletextcolor="#FFA7A6AA" normalimage="file=&apos;BtnClose.png&apos; source=&apos;0,0,79,30&apos;" hotimage="file=&apos;BtnClose.png&apos; source=&apos;80,0,158,30&apos;" pushedimage="file=&apos;BtnClose.png&apos; source=&apos;159,0,237,30&apos;" disabledimage="file=&apos;BtnClose.png&apos; source=&apos;238,0,316,30&apos;" />14             </HorizontalLayout>15         </HorizontalLayout>16         <VerticalLayout bkimage="file=&apos;MBbottombg.png&apos; corner=&apos;6,6,6,6&apos;">17             18         </VerticalLayout>19     </VerticalLayout>20 </Window>
复制代码


其他:

1.开始写完程序运行后发现任务栏上没有图标,原来可以用SetIcon函数来设置,SetIcon函数的参数是一个资源ID(UINT类型),可以自己绘制一个图标或者导入一个,然后将该图标的id传入即可,还是比较方便的。注意的是SetIcon不需要使用MAKEINTRESOURCE来转换,在SetIcon函数内调用了MAKEINTRESOURCE。

2.在用窗口类的Create函数时,指定UI_WNDSTYLE_FRAME为第三个参数时,窗口可以双击最大化,而使用UI_WNDSTYLE_DIALOG时无法最大化。原来

1 #define UI_WNDSTYLE_FRAME      (WS_VISIBLE | WS_OVERLAPPEDWINDOW)2 #define UI_WNDSTYLE_CHILD      (WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)3 #define UI_WNDSTYLE_DIALOG     (WS_VISIBLE | WS_POPUPWINDOW | WS_CAPTION | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)

WS_OVERLAPPEDWINDOW默认带有WM_MAXIMIZEBOX属性,固默认可以双击最大化。WS_POPUPWINDOW默认有WS_BORDER,WS_POPUP和WS_SYSMENU属性,没有WM_MAXIMIZEBOX属性,固POPUPWINDOW默认无法双击最大化。

3.WM_NCCALCSIZE消息的处理,MSDN中有这么一段描述

When wParam is TRUE, simply returning 0 without processing the NCCALCSIZE_PARAMS rectangles will cause the client area to resize to the size of the window, including the window frame. This will remove the window frame and caption items from your window, leaving only the client area displayed.

也就是说这个消息处理时返回0,则窗口将会没有标题栏和外边框,只有客户区了。

4.WM_NCHITTEST消息的处理,可以返回HTTOPLEFT(窗口的左上角,鼠标变为可调边框标识)、HTTOPRIGHT等。返回HTCAPTION标识击中为标题栏,返回HTCLIENT标识击中为客户区。

5.按键消息的处理:可继承IMessageFilterUI,该接口有MessageHandler纯虚函数,自己要实现对按键的处理;在OnCreate中把自己加入到绘制管理器对象的m_aPreMessageFilters预处理消息数组中。这样在绘制管理器的MessageLoop()中将调用TranslateMessage按键处理,在TranslateMessage又将调用PreMessageHandler,然后PreMessageHandler中又将调用MessageHandler函数(即那个需要处理按键消息的窗口类的函数)

6.foreimage可以在按钮的背景上加入前景图片;控件的float设为true时,改变窗口大小,控件的显示会有问题,只能显示控件的一部分,解决办法是使用布局来控制控件位置,不用设置控件位置;relativePos要与float="true"同用,可调节百分比;pos属性也要与float="true"同用才可调节控件位置;皮肤科刷新有问题,必须依赖于背景颜色;

 

 

原文:http://www.cnblogs.com/wnarutou/archive/2012/11/19/2776576.html

我这里只是做了个转载,以便随时查阅!