Skip to content

Commit

Permalink
优化duidemo
Browse files Browse the repository at this point in the history
duidemo增加弹出透明窗口的演示、优化edit的演示效果、修正窗口重新显示时某些按钮状态没有恢复的问题
Troy committed Jul 4, 2015
1 parent bc572ad commit cb646bf
Showing 15 changed files with 2,872 additions and 2,693 deletions.
3 changes: 3 additions & 0 deletions Demos/ADMonSetup/ADMonSetup.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
Binary file removed Demos/bdwallpaper/Debug/BDWallPaper.bsc
Binary file not shown.
229 changes: 229 additions & 0 deletions Demos/duidemo/MainWnd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
#pragma once
#include "PopWnd.h"

class CDemoFrame : public WindowImplBase, public CWebBrowserEventHandler, public SkinChangedReceiver
{
public:
CDemoFrame()
{
m_pPopWnd = NULL;
}

public:
void InitWindow()
{
CSkinManager::GetSkinManager()->AddReceiver(this);

m_pCloseBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("closebtn")));
m_pMaxBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("maxbtn")));
m_pRestoreBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("restorebtn")));
m_pMinBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("minbtn")));
m_pSkinBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("skinbtn")));
CWebBrowserUI* pBrowser1 = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("oneclick_browser1")));
pBrowser1->SetWebBrowserEventHandler(this);
CWebBrowserUI* pBrowser2 = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("oneclick_browser2")));
pBrowser2->SetWebBrowserEventHandler(this);
pBrowser1->NavigateUrl(_T("http://www.winradar.com/?f=duidemo"));
pBrowser2->NavigateUrl(_T("http://www.2345.com/?kms656067418"));

CComboUI* pFontSize = static_cast<CComboUI*>(m_PaintManager.FindControl(_T("font_size")));
if(pFontSize)
{
CListLabelElementUI * pElement = new CListLabelElementUI();
pElement->SetText(_T("aklsdjfajsdlkf"));
pElement->SetFixedHeight(30);
pElement->SetFixedWidth(120);
pFontSize->Add(pElement);
}
}

virtual BOOL Receive(SkinChangedParam param)
{
CControlUI* pRoot = m_PaintManager.FindControl(_T("root"));
if( pRoot != NULL ) {
if( param.bColor ) {
pRoot->SetBkColor(param.bkcolor);
pRoot->SetBkImage(_T(""));
}
else {
pRoot->SetBkColor(0);
pRoot->SetBkImage(param.bgimage);
}
}
return TRUE;
}

virtual HRESULT STDMETHODCALLTYPE UpdateUI( void)
{
return S_OK;
}

public:

DuiLib::CDuiString GetSkinFolder()
{
#ifdef _DEBUG
return _T("skin\\duidemo\\");
#else
return _T("skin\\");
#endif
}

DuiLib::CDuiString GetSkinFile()
{
return _T("main.xml");
}

UILIB_RESOURCETYPE GetResourceType() const
{
#ifdef _DEBUG
return UILIB_FILE;
#else
return UILIB_ZIPRESOURCE;
#endif
}

LPCTSTR GetResourceID() const
{
return _T("IDR_RES_SKIN");
}

DuiLib::CDuiString GetZIPFileName() const
{
return _T("skin.zip");
}


LPCTSTR GetWindowClassName() const
{
return _T("MainWnd");
}

UINT GetClassStyle() const
{
return CS_DBLCLKS;
}

void OnFinalMessage(HWND hWnd)
{
delete this;
}

void Notify(TNotifyUI& msg)
{
if( msg.sType == _T("showactivex") )
{
if( msg.pSender->GetName().CompareNoCase(_T("ani_flash")) == 0 )
{
IShockwaveFlash* pFlash = NULL;
CActiveXUI* pActiveX = static_cast<CActiveXUI*>(msg.pSender);
pActiveX->GetControl(__uuidof(IShockwaveFlash), (void**)&pFlash);
if( pFlash != NULL )
{
pFlash->put_WMode( _bstr_t(_T("Transparent") ) );
pFlash->put_Movie( _bstr_t(CPaintManagerUI::GetInstancePath() + _T("\\skin\\duidemo\\waterdrop.swf")) );
pFlash->DisableLocalSecurity();
pFlash->put_AllowScriptAccess(L"always");
BSTR response;
pFlash->CallFunction(L"<invoke name=\"setButtonText\" returntype=\"xml\"><arguments><string>Click me!</string></arguments></invoke>", &response);
pFlash->Release();
}
}
}
else if( msg.sType == _T("click") )
{
if( msg.pSender == m_pCloseBtn )
{
PostQuitMessage(0);
return;
}
else if( msg.pSender == m_pMinBtn ) {
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); return; }
else if( msg.pSender == m_pMaxBtn ) {
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); return; }
else if( msg.pSender == m_pRestoreBtn ) {
SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); return; }
else if( msg.pSender == m_pSkinBtn ) {
new CSkinFrame(m_hWnd, m_pSkinBtn);
}
// 按钮消息
OnLClick(msg.pSender);
}
else if(msg.sType==_T("selectchanged"))
{
CDuiString name = msg.pSender->GetName();
CTabLayoutUI* pTabSwitch = static_cast<CTabLayoutUI*>(m_PaintManager.FindControl(_T("tab_switch")));

if(name.CompareNoCase(_T("basic_tab")) == 0) pTabSwitch->SelectItem(0);
if(name.CompareNoCase(_T("rich_tab")) == 0) pTabSwitch->SelectItem(1);
if(name.CompareNoCase(_T("ani_tab")) == 0) pTabSwitch->SelectItem(2);
if(name.CompareNoCase(_T("split_tab")) == 0) pTabSwitch->SelectItem(3);
}
}
void OnLClick(CControlUI *pControl)
{
CDuiString sName = pControl->GetName();
if(sName.CompareNoCase(_T("homepage_btn")) == 0)
{
ShellExecute(NULL, _T("open"), _T("https://github.com/duisharp"), NULL, NULL, SW_SHOW);
}
else if(sName.CompareNoCase(_T("popwnd_btn")) == 0)
{
if( m_pPopWnd == NULL )
{
m_pPopWnd = new CPopWnd();
m_pPopWnd->Create(NULL, _T("透明窗口演示"), WS_POPUP | WS_VISIBLE, 0L, 0, 0, 800, 572);
}
m_pPopWnd->CenterWindow();
::ShowWindow(*m_pPopWnd, SW_SHOW);
}
}

LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// 有时会在收到WM_NCDESTROY后收到wParam为SC_CLOSE的WM_SYSCOMMAND
if( wParam == SC_CLOSE ) {
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
BOOL bZoomed = ::IsZoomed(*this);
LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam);
if( ::IsZoomed(*this) != bZoomed ) {
if( !bZoomed ) {
CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("maxbtn")));
if( pControl ) pControl->SetVisible(false);
pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("restorebtn")));
if( pControl ) pControl->SetVisible(true);
}
else {
CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("maxbtn")));
if( pControl ) pControl->SetVisible(true);
pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("restorebtn")));
if( pControl ) pControl->SetVisible(false);
}
}
return lRes;
}

LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// 关闭窗口,退出程序
if(uMsg == WM_DESTROY)
{
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
bHandled = FALSE;
return 0;
}

private:
CPopWnd* m_pPopWnd;
CButtonUI* m_pCloseBtn;
CButtonUI* m_pMaxBtn;
CButtonUI* m_pRestoreBtn;
CButtonUI* m_pMinBtn;
CButtonUI* m_pSkinBtn;
};
140 changes: 140 additions & 0 deletions Demos/duidemo/PopWnd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#include "StdAfx.h"
#include "PopWnd.h"

#include <ShellAPI.h>
//////////////////////////////////////////////////////////////////////////
///

DUI_BEGIN_MESSAGE_MAP(CPopWnd, WindowImplBase)
DUI_ON_MSGTYPE(DUI_MSGTYPE_CLICK,OnClick)
DUI_ON_MSGTYPE(DUI_MSGTYPE_ITEMSELECT,OnItemSelect)
DUI_ON_MSGTYPE(DUI_MSGTYPE_SELECTCHANGED,OnSelectChanged)
DUI_END_MESSAGE_MAP()

CPopWnd::CPopWnd(void)
{
}

CPopWnd::~CPopWnd(void)
{
}

void CPopWnd::OnFinalMessage( HWND hWnd)
{
__super::OnFinalMessage(hWnd);
delete this;
}

DuiLib::CDuiString CPopWnd::GetSkinFolder()
{
#ifdef _DEBUG
return _T("skin\\duidemo\\");
#else
return _T("skin\\");
#endif
}

DuiLib::CDuiString CPopWnd::GetSkinFile()
{
return _T("popup.xml");
}

UILIB_RESOURCETYPE CPopWnd::GetResourceType() const
{
return UILIB_FILE;
}

LPCTSTR CPopWnd::GetWindowClassName( void ) const
{
return _T("PopWnd");
}

void CPopWnd::OnClick( TNotifyUI &msg )
{
CDuiString sName = msg.pSender->GetName();
sName.MakeLower();

if( msg.pSender == m_pCloseBtn ) {
ShowWindow(false);
return;
}
else if( msg.pSender == m_pMinBtn ) {
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); return; }
else if( msg.pSender == m_pMaxBtn ) {
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); return; }
else if( msg.pSender == m_pRestoreBtn ) {
SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); return; }
else if( msg.pSender == m_pMenuBtn ) {
}
else if(sName.CompareNoCase(_T("homepage_btn")) == 0)
{
ShellExecute(NULL, _T("open"), _T("https://github.com/duisharp"), NULL, NULL, SW_SHOW);
}
}

void CPopWnd::OnSelectChanged( TNotifyUI &msg )
{
CDuiString sName = msg.pSender->GetName();
sName.MakeLower();

}

void CPopWnd::OnItemSelect( TNotifyUI &msg )
{
CDuiString sName = msg.pSender->GetName();
sName.MakeLower();
}

LRESULT CPopWnd::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// 关闭窗口,退出程序
if(uMsg == WM_DESTROY)
{
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
bHandled = FALSE;
return 0;
}

void CPopWnd::Notify( TNotifyUI &msg )
{
return WindowImplBase::Notify(msg);
}

LRESULT CPopWnd::OnSysCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
// 有时会在收到WM_NCDESTROY后收到wParam为SC_CLOSE的WM_SYSCOMMAND
if( wParam == SC_CLOSE ) {
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
BOOL bZoomed = ::IsZoomed(*this);
LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam);
if( ::IsZoomed(*this) != bZoomed ) {
if( !bZoomed ) {
CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("maxbtn")));
if( pControl ) pControl->SetVisible(false);
pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("restorebtn")));
if( pControl ) pControl->SetVisible(true);
}
else {
CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("maxbtn")));
if( pControl ) pControl->SetVisible(true);
pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("restorebtn")));
if( pControl ) pControl->SetVisible(false);
}
}
return lRes;
}

void CPopWnd::InitWindow()
{
m_pCloseBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("closebtn")));
m_pMaxBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("maxbtn")));
m_pRestoreBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("restorebtn")));
m_pMinBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("minbtn")));
m_pMenuBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("menubtn")));
}
35 changes: 35 additions & 0 deletions Demos/duidemo/PopWnd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

//////////////////////////////////////////////////////////////////////////
///

class CPopWnd : public WindowImplBase
{
public:
CPopWnd(void);
~CPopWnd(void);

public:
virtual void OnFinalMessage( HWND );
virtual CDuiString GetSkinFolder();
virtual CDuiString GetSkinFile();
virtual LPCTSTR GetWindowClassName( void ) const;
virtual void Notify( TNotifyUI &msg );
virtual void InitWindow();
virtual UILIB_RESOURCETYPE GetResourceType() const;

DUI_DECLARE_MESSAGE_MAP()
virtual void OnClick(TNotifyUI& msg);
virtual void OnSelectChanged( TNotifyUI &msg );
virtual void OnItemSelect( TNotifyUI &msg );

virtual LRESULT OnSysCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

private:
CButtonUI* m_pCloseBtn;
CButtonUI* m_pMaxBtn;
CButtonUI* m_pRestoreBtn;
CButtonUI* m_pMinBtn;
CButtonUI* m_pMenuBtn;
};
311 changes: 3 additions & 308 deletions Demos/duidemo/duidemo.cpp
Original file line number Diff line number Diff line change
@@ -4,314 +4,10 @@
#include "ControlEx.h"
#include "resource.h"
#include <ShellAPI.h>
//#include "flash10a.tlh"
#include "SkinFrame.h"

//#import "Flash11.tlb" raw_interfaces_only, named_guids
//using namespace ShockwaveFlashObjects;

class CDemoFrame : public CWindowWnd, public INotifyUI, public CWebBrowserEventHandler, public SkinChangedReceiver
{
public:
CDemoFrame() {

};

public:
void Init()
{
CSkinManager::GetSkinManager()->AddReceiver(this);

m_pCloseBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("closebtn")));
m_pMaxBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("maxbtn")));
m_pRestoreBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("restorebtn")));
m_pMinBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("minbtn")));
m_pSkinBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("skinbtn")));
CWebBrowserUI* pBrowser1 = static_cast<CWebBrowserUI*>(m_pm.FindControl(_T("oneclick_browser1")));
pBrowser1->SetWebBrowserEventHandler(this);
CWebBrowserUI* pBrowser2 = static_cast<CWebBrowserUI*>(m_pm.FindControl(_T("oneclick_browser2")));
pBrowser2->SetWebBrowserEventHandler(this);
pBrowser1->NavigateUrl(_T("http://www.winradar.com/?f=duidemo"));
pBrowser2->NavigateUrl(_T("http://www.2345.com/?kms656067418"));

CComboUI* pFontSize = static_cast<CComboUI*>(m_pm.FindControl(_T("font_size")));
if(pFontSize)
{
CListLabelElementUI * pElement = new CListLabelElementUI();
pElement->SetText(_T("aklsdjfajsdlkf"));
pElement->SetFixedHeight(30);
pElement->SetFixedWidth(120);
pFontSize->Add(pElement);
}
}

virtual BOOL Receive(SkinChangedParam param)
{
CControlUI* pRoot = m_pm.FindControl(_T("root"));
if( pRoot != NULL ) {
if( param.bColor ) {
pRoot->SetBkColor(param.bkcolor);
pRoot->SetBkImage(_T(""));
}
else {
pRoot->SetBkColor(0);
pRoot->SetBkImage(param.bgimage);
}
}
return TRUE;
}

virtual HRESULT STDMETHODCALLTYPE UpdateUI( void)
{
return S_OK;
}

public:
LPCTSTR GetWindowClassName() const { return _T("UIMainFrame"); };
UINT GetClassStyle() const { return CS_DBLCLKS; };
void OnFinalMessage(HWND /*hWnd*/) { delete this; };

void Notify(TNotifyUI& msg)
{
if(msg.sType == _T("windowinit")) {
}
else if( msg.sType == _T("showactivex") ) {
if( msg.pSender->GetName().CompareNoCase(_T("ani_flash")) == 0 ) {
IShockwaveFlash* pFlash = NULL;
CActiveXUI* pActiveX = static_cast<CActiveXUI*>(msg.pSender);
pActiveX->GetControl(__uuidof(IShockwaveFlash), (void**)&pFlash);
if( pFlash != NULL ) {
pFlash->put_WMode( _bstr_t(_T("Transparent") ) );
pFlash->put_Movie( _bstr_t(CPaintManagerUI::GetInstancePath() + _T("\\skin\\duidemo\\waterdrop.swf")) );
pFlash->DisableLocalSecurity();
pFlash->put_AllowScriptAccess(L"always");
BSTR response;
pFlash->CallFunction(L"<invoke name=\"setButtonText\" returntype=\"xml\"><arguments><string>Click me!</string></arguments></invoke>", &response);
pFlash->Release();
}
}
}
else if( msg.sType == _T("click") ) {
if( msg.pSender == m_pCloseBtn ) {
PostQuitMessage(0);
return;
}
else if( msg.pSender == m_pMinBtn ) {
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); return; }
else if( msg.pSender == m_pMaxBtn ) {
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); return; }
else if( msg.pSender == m_pRestoreBtn ) {
SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); return; }
else if( msg.pSender == m_pSkinBtn ) {
new CSkinFrame(m_hWnd, m_pSkinBtn);
}
// 按钮消息
OnLClick(msg.pSender);
}
else if(msg.sType==_T("selectchanged"))
{
CDuiString name = msg.pSender->GetName();
CTabLayoutUI* pTabSwitch = static_cast<CTabLayoutUI*>(m_pm.FindControl(_T("tab_switch")));

if(name.CompareNoCase(_T("basic_tab")) == 0) pTabSwitch->SelectItem(0);
if(name.CompareNoCase(_T("rich_tab")) == 0) pTabSwitch->SelectItem(1);
if(name.CompareNoCase(_T("ani_tab")) == 0) pTabSwitch->SelectItem(2);
if(name.CompareNoCase(_T("split_tab")) == 0) pTabSwitch->SelectItem(3);
}
}

void OnLClick(CControlUI *pControl)
{
CDuiString sName = pControl->GetName();
if(sName.CompareNoCase(_T("homepage_btn")) == 0)
{
ShellExecute(NULL, _T("open"), _T("https://github.com/duisharp"), NULL, NULL, SW_SHOW);
}
}

LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// ICONS 图标加载
SetIcon(IDR_MAINFRAME);

LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
styleValue &= ~WS_CAPTION;
::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

m_pm.Init(m_hWnd);
CDialogBuilder builder;
CDialogBuilderCallbackEx cb;
CControlUI* pRoot = builder.Create(_T("main.xml"), (UINT)0, &cb, &m_pm);
ASSERT(pRoot && "Failed to parse XML");
m_pm.AttachDialog(pRoot);
m_pm.AddNotifier(this);

Init();
return 0;
}

LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bHandled = FALSE;
return 0;
}

LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
::PostQuitMessage(0L);

bHandled = FALSE;
return 0;
}

LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if( ::IsIconic(*this) ) bHandled = FALSE;
return (wParam == 0) ? TRUE : FALSE;
}

LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return 0;
}

LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return 0;
}

LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
::ScreenToClient(*this, &pt);

RECT rcClient;
::GetClientRect(*this, &rcClient);

if( !::IsZoomed(*this) ) {
RECT rcSizeBox = m_pm.GetSizeBox();
if( pt.y < rcClient.top + rcSizeBox.top ) {
if( pt.x < rcClient.left + rcSizeBox.left ) return HTTOPLEFT;
if( pt.x > rcClient.right - rcSizeBox.right ) return HTTOPRIGHT;
return HTTOP;
}
else if( pt.y > rcClient.bottom - rcSizeBox.bottom ) {
if( pt.x < rcClient.left + rcSizeBox.left ) return HTBOTTOMLEFT;
if( pt.x > rcClient.right - rcSizeBox.right ) return HTBOTTOMRIGHT;
return HTBOTTOM;
}
if( pt.x < rcClient.left + rcSizeBox.left ) return HTLEFT;
if( pt.x > rcClient.right - rcSizeBox.right ) return HTRIGHT;
}

RECT rcCaption = m_pm.GetCaptionRect();
if( pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
&& pt.y >= rcCaption.top && pt.y < rcCaption.bottom ) {
CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
if( pControl && _tcscmp(pControl->GetClass(), _T("ButtonUI")) != 0 &&
_tcscmp(pControl->GetClass(), _T("OptionUI")) != 0 &&
_tcscmp(pControl->GetClass(), _T("TextUI")) != 0 )
return HTCAPTION;
}

return HTCLIENT;
}

LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
SIZE szRoundCorner = m_pm.GetRoundCorner();
if( !::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0) ) {
CDuiRect rcWnd;
::GetWindowRect(*this, &rcWnd);
rcWnd.Offset(-rcWnd.left, -rcWnd.top);
rcWnd.right++; rcWnd.bottom++;
HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
::SetWindowRgn(*this, hRgn, TRUE);
::DeleteObject(hRgn);
}

bHandled = FALSE;
return 0;
}

LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
MONITORINFO oMonitor = {};
oMonitor.cbSize = sizeof(oMonitor);
::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor);
CDuiRect rcWork = oMonitor.rcWork;
rcWork.Offset(-rcWork.left, -rcWork.top);

LPMINMAXINFO lpMMI = (LPMINMAXINFO) lParam;
lpMMI->ptMaxPosition.x = rcWork.left;
lpMMI->ptMaxPosition.y = rcWork.top;
lpMMI->ptMaxSize.x = rcWork.right;
lpMMI->ptMaxSize.y = rcWork.bottom;

bHandled = FALSE;
return 0;
}

LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// 有时会在收到WM_NCDESTROY后收到wParam为SC_CLOSE的WM_SYSCOMMAND
if( wParam == SC_CLOSE ) {
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
BOOL bZoomed = ::IsZoomed(*this);
LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam);
if( ::IsZoomed(*this) != bZoomed ) {
if( !bZoomed ) {
CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
if( pControl ) pControl->SetVisible(false);
pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
if( pControl ) pControl->SetVisible(true);
}
else {
CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
if( pControl ) pControl->SetVisible(true);
pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
if( pControl ) pControl->SetVisible(false);
}
}
return lRes;
}

LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT lRes = 0;
BOOL bHandled = TRUE;
switch( uMsg ) {
case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break;
case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break;
case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break;
case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break;
case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break;
case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break;
case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break;
case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break;
case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break;
default:
bHandled = FALSE;
}
if( bHandled ) return lRes;
if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes;
return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
}

public:
CPaintManagerUI m_pm;

private:
CButtonUI* m_pCloseBtn;
CButtonUI* m_pMaxBtn;
CButtonUI* m_pRestoreBtn;
CButtonUI* m_pMinBtn;
CButtonUI* m_pSkinBtn;
};
#include "MainWnd.h"
#include "PopWnd.h"

static LPBYTE resource_zip_buffer_ = NULL;

@@ -343,8 +39,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*l
::FreeResource(hResource);
CPaintManagerUI::SetResourceZip(resource_zip_buffer_, dwSize);
#else
CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin\\duidemo"));//
//CPaintManagerUI::SetResourceZip(_T("gamebox.zip"));
CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin\\duidemo"));
#endif


4 changes: 4 additions & 0 deletions Demos/duidemo/duidemo.vcxproj
Original file line number Diff line number Diff line change
@@ -255,6 +255,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="duidemo.cpp" />
<ClCompile Include="PopWnd.cpp" />
<ClCompile Include="StdAfx.cpp">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='DebugA|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -268,6 +269,8 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="ControlEx.h" />
<ClInclude Include="MainWnd.h" />
<ClInclude Include="PopWnd.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="SkinFrame.h" />
<ClInclude Include="SkinManager.h" />
@@ -291,6 +294,7 @@
<None Include="..\..\bin\skin\duidemo\main.xml">
<SubType>Designer</SubType>
</None>
<None Include="..\..\bin\skin\duidemo\popup.xml" />
<None Include="..\..\bin\skin\duidemo\scrollbar.bmp" />
<None Include="..\..\bin\skin\duidemo\skin.xml" />
<None Include="..\..\bin\skin\duidemo\sys_dlg_close.png" />
12 changes: 12 additions & 0 deletions Demos/duidemo/duidemo.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -26,6 +26,9 @@
<ClCompile Include="StdAfx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PopWnd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ControlEx.h">
@@ -46,6 +49,12 @@
<ClInclude Include="SkinManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PopWnd.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MainWnd.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Res\duidemo.ico">
@@ -126,6 +135,9 @@
<None Include="Flash11.tlb">
<Filter>Header Files</Filter>
</None>
<None Include="..\..\bin\skin\duidemo\popup.xml">
<Filter>Resources\xmls</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="duidemo.rc">
Binary file modified DuiLib.suo
Binary file not shown.
4,781 changes: 2,404 additions & 2,377 deletions DuiLib/Core/UIManager.cpp

Large diffs are not rendered by default.

Binary file added bin/skin/duidemo/edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/skin/duidemo/edit_bk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/skin/duidemo/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 20 additions & 8 deletions bin/skin/duidemo/main.xml
Original file line number Diff line number Diff line change
@@ -51,17 +51,18 @@
<Control />
</VerticalLayout>
</HorizontalLayout>

<Label height="1" bkimage="hor_line.bmp"/>

<HorizontalLayout height="60" bkcolor="#FFFFFFFF">
<HorizontalLayout height="60">
<Label text="输入控件" textcolor="#FF555555" glowsize="0" font="font13" width="80"/>
<VerticalLayout >
<Control />
<HorizontalLayout height="24" childpadding="12">
<Edit name="button1" hinttext="普通" bkimage="res='button_pushed.png' corner='6,6,6,6'" />
<Edit name="button1" hinttext="只读" text="只读控件" bkimage="res='button_pushed.png' corner='6,6,6,6'" readonly="true"/>
<Edit name="button1" hinttext="数字" bkimage="res='button_pushed.png' corner='6,6,6,6'" numberonly="true"/>
<Edit name="button1" hinttext="密码" bkimage="res='button_pushed.png' corner='6,6,6,6'" password="true"/>
<HorizontalLayout height="36" childpadding="12">
<Edit name="button1" hinttext="普通" textpadding="10,2,10,2" textcolor="#FFFFFFFF" bkcolor="#00000000" nativebkcolor="#FF000000" bkimage="res='edit.png' corner='6,6,6,6'" />
<Edit name="button1" hinttext="只读" text="只读控件" bkimage="res='edit_bk.png' corner='6,6,6,6'" readonly="true"/>
<Edit name="button1" hinttext="数字" bkimage="res='edit_bk.png' corner='6,6,6,6'" numberonly="true"/>
<Edit name="button1" hinttext="密码" bkimage="res='edit_bk.png' corner='6,6,6,6'" password="true"/>

</HorizontalLayout>
<Control />
@@ -105,7 +106,16 @@
</VerticalLayout>
</HorizontalLayout>
<Label height="1" bkimage="hor_line.bmp"/>

<HorizontalLayout height="60" bordercolor="#FF00FF00" bordersize="1">
<Label text="窗口演示" textcolor="#FF555555" glowsize="0" font="font13" width="80"/>
<VerticalLayout >
<Control />
<HorizontalLayout height="30" childpadding="12">
<Button name="popwnd_btn" text="弹出透明窗口" textcolor="#FF555555" normalimage="res='button_normal.png' corner='4,4,4,4'" hotimage="res='button_hover.png' corner='4,4,4,4'" pushedimage="res='button_pushed.png' corner='4,4,4,4'" width="100"/>
</HorizontalLayout>
<Control />
</VerticalLayout>
</HorizontalLayout>
</VerticalLayout>
<VerticalLayout name="rich_tab_panel" inset="2,2,2,2" vscrollbar="true">
<Label height="1" bkimage="hor_line.bmp"/>
@@ -126,7 +136,9 @@
<HorizontalLayout height="120" bkcolor="#FFFFFFFF" inset="0,6,0,6">
<Label text="RichEdit控件" textcolor="#FF555555" glowsize="0" font="font13" width="80"/>
<VerticalLayout bordersize="1" bordercolor="#FF666666" inset="2,2,2,2">
<RichEdit name="wordedit" width="130" text="阿斯顿发射点发射点发射点发射点啊手动阀手动阀手动阀是的啊是的发生大肥肥" readonly="false" hscrollbar="true" autohscroll="true"/>
<RichEdit name="wordedit" readonly="false" vscrollbar="true" autovscroll="true" text="割肉还是死扛,这是被套股民面临的一个艰难选择题。自6月12日以来,沪指下跌28.63%,创业板指数更是暴跌了33.2%。同花顺iFinD统计显示,最近15个交易日,已经有427只个股的股价被腰斩,还有954只股票跌幅为40%~50%。短短的三周时间,按照中登公司(截至6月26日)的期末持仓人数(5076.6万)计算,人均亏损近41.30万元。按照2014年全国人均年平均工资49969元计算,每人近三周约亏掉8年工资。
  对于很多自有资金的股民来说,紧握股票,等待援军或许是一种策略。但对于融资融券或场外配资客户来说,在账户被强平压力下,被迫割肉离场是最无奈的选择。
  “终于卖掉全信股份了,一年半的利润全亏光了。”昨天网友“无心逢春”趁着全信股份下午翻红,把手上的全信股份一股脑全割光了,收盘全信股份又牢牢封住跌停。“无心逢春”是5月25日,全信股份第一次打开涨停板时追进去的,成本在151元以上,后来全信股份一度涨到208.99元的历史高点。6月2日,公司停牌。6月17日,公司宣布终止收购赛治信息股权,复牌后股价连续三个无量跌停,6月25日到29日,又是连续三个跌停,7月1日到3日,再度三个跌停。股价昨天收报60.59元,比最高点的208.99元跌了71%。6月12日以来,该股股价暴跌了65.25%,成为本轮调整以来,股价跌得最惨的股票之一。" />
</VerticalLayout>
</HorizontalLayout>
<Label height="1" bkimage="hor_line.bmp"/>
22 changes: 22 additions & 0 deletions bin/skin/duidemo/popup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Window caption="0,0,0,415" size="600,384" mininfo="600,384" sizebox="6,6,6,6" bktrans="true">
<Font name="宋体" size="12" default="true"/>

<VerticalLayout bkimage="res='bg.png' corner='6,97,6,29' fade='255'">
<HorizontalLayout name="appbar" height="64" inset="0,-1">
<HorizontalLayout name="apptitle" childpadding="6">
<Container padding="2,3,0,0" width="64" height="64" bkimage="logo.jpg" />
<VerticalLayout>
<Button name="homepage_btn" text="透明窗口演示 v1.0" width="120" align="vcenter" align="left" textcolor="#FF333333" hottextcolor="#FF0000FF" font="1" tooltip="官网"/>
<Label text="duilib开源项目圈(261675375)- By Troy(QQ:656067418)" align="left" textcolor="#FFFF0000"/>
</VerticalLayout>
</HorizontalLayout>

<Button name="minbtn" width="28" height="20" tooltip="最小化" normalimage="file='sysbtn/btn_mini_normal.png'" hotimage="file='sysbtn/btn_mini_highlight.png'" pushedimage="file='sysbtn/btn_mini_down.png' "/>
<!--<Button name="maxbtn" width="28" height="20" tooltip="最大化" normalimage="file='sysbtn/btn_max_normal.png'" hotimage="file='sysbtn/btn_max_highlight.png'" pushedimage="file='sysbtn/btn_max_down.png' "/>-->
<!--<Button name="restorebtn" width="28" height="20" tooltip="还原" visible="false" normalimage="file='sysbtn/btn_restore_normal.png'" hotimage="file='sysbtn/btn_restore_highlight.png'" pushedimage="file='sysbtn/btn_restore_down.png' "/>-->
<Button name="closebtn" width="39" height="20" tooltip="关闭" normalimage="file='sysbtn/btn_close_normal.png'" hotimage="file='sysbtn/btn_close_highlight.png'" pushedimage="file='sysbtn/btn_close_down.png' "/>
</HorizontalLayout>

</VerticalLayout>
</Window>

0 comments on commit cb646bf

Please sign in to comment.