1. 由于CEF工程中使用了 NOMINMAX预编译设置。在引用第三方使用min,max库时,会报错。
可以这样处理,
#include <algorithm>
#define min
#define max
#include "include\UIlib.h"
2. 中文显示错误,可能是dui库编译时 Character Set 没有选择 Use Unicode Character Set,和CEF工程不一致。
3. Dui添加新的事件处理。类似这样,可以处理任何事件。
void CFrameWnd::OnPrepare()
{
pHlayout = static_cast<CHorizontalLayoutUI*>(m_pm.FindControl(_T("horizontal")));
if (pHlayout) pHlayout->OnEvent += MakeDelegate(this, &CFrameWnd::OnHlayoutEvent2);
CSliderUI* pSilder = static_cast<CSliderUI*>(m_pm.FindControl(_T("alpha_controlor")));
if( pSilder ) pSilder->OnNotify += MakeDelegate(this, &CFrameWindowWnd::OnAlphaChanged);
}
bool CFrameWnd::OnHlayoutEvent2(void* param) {
TEventUI* event = (TEventUI*)param;
if (event->Type == UIEVENT_MOUSEENTER)
{
//告诉UIManager这个消息需要处理
pHlayout->SetBorderColor(0x58A1CC);
pHlayout->SetBorderSize(5);
_cwprintf(L"UIEVENT_MOUSEENTER\n");
}
else if (event->Type == UIEVENT_BUTTONDOWN) {
_cwprintf(L"UIEVENT_BUTTONDOWN\n");
}
else if (event->Type == UIEVENT_BUTTONUP) {
_cwprintf(L"UIEVENT_BUTTONUP\n");
}
else if (event->Type == UIEVENT_MOUSELEAVE) {
pHlayout->SetBorderSize(0);
_cwprintf(L"UIEVENT_MOUSELEAVE\n");
}
return true;
}
bool CFrameWnd::OnAlphaChanged(void* param) {
TNotifyUI* pMsg = (TNotifyUI*)param;
if( pMsg->sType == _T("valuechanged") ) {
m_pm.SetOpacity((static_cast<CSliderUI*>(pMsg->pSender))->GetValue());
}
return true;
}
4. 如何在dui窗口嵌入cef browser,注意 browser区域不要有其它dui控件,否则可能browser加载不正常。原因不明。
5. 在CreateRootWindow函数中,可以创建dui窗口,代替原来的win32窗口,这样就可以随意创建title区域了。