From 0e0033eb896c7ba7045f6204b9ad0cc1da44c76a Mon Sep 17 00:00:00 2001 From: UMU Date: Tue, 5 Jun 2018 12:16:54 +0800 Subject: [PATCH] =?UTF-8?q?+=20=E6=89=80=E6=9C=89=E5=85=B6=E5=AE=83=20Demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 360SafeDemo/360Safe.cpp | 562 ++++---- 360SafeDemo/360SafeDemo.vcproj | 463 ------ 360SafeDemo/360SafeDemo.vcxproj | 334 +++-- 360SafeDemo/CMakeLists.txt | 15 - 360SafeDemo/StdAfx.h | 3 +- DuiLib.sln | 115 ++ FlashDemo/App.cpp | 314 ++-- FlashDemo/CMakeLists.txt | 16 - FlashDemo/FlashDemo.vcproj | 498 ------- FlashDemo/FlashDemo.vcxproj | 350 +++-- FlashDemo/StdAfx.h | 7 +- GameDemo/CMakeLists.txt | 16 - GameDemo/GameDemo.cpp | 1274 +++++++++-------- GameDemo/GameDemo.sln | 26 - GameDemo/GameDemo.vcproj | 554 ------- GameDemo/GameDemo.vcxproj | 369 +++-- GameDemo/GameDemo.vcxproj.filters | 1 - GameDemo/StdAfx.h | 16 +- ListDemo/CMakeLists.txt | 16 - ListDemo/ListDemo.vcproj | 449 ------ ListDemo/ListDemo.vcxproj | 364 +++-- ListDemo/Main.cpp | 860 +++++------ ListDemo/MenuWnd.h | 535 +++---- MenuDemo/MenuDemo.vcxproj | 12 +- QQDemo/CMakeLists.txt | 17 - QQDemo/ColorPicker.hpp | 2 +- QQDemo/QQDemo.vcproj | 517 ------- QQDemo/QQDemo.vcxproj | 395 +++-- QQDemo/StdAfx.h | 12 +- QQDemo/main.cpp | 76 +- RichListDemo/CMakeLists.txt | 17 - RichListDemo/ReadMe.txt | 47 - RichListDemo/RichListDemo.cpp | 46 +- RichListDemo/RichListDemo.vcproj | 418 ------ RichListDemo/RichListDemo.vcxproj | 228 ++- RichListDemo/RichListDemo.vcxproj.filters | 3 - RichListDemo/stdafx.h | 11 +- ScrCapture/App.cpp | 4 - ScrCapture/ScrCapture.vcxproj | 14 +- ScrCapture/ScrCaptureWnd.h | 86 +- ScrCapture/StdAfx.h | 4 +- {bin/skin => _skin}/360SafeRes.zip | Bin .../FlashRes/frame_btn_close_disable.bmp | Bin .../FlashRes/frame_btn_close_down.bmp | Bin .../FlashRes/frame_btn_close_hot.bmp | Bin .../FlashRes/frame_btn_close_normal.bmp | Bin {bin/skin => _skin}/FlashRes/test.swf | Bin {bin/skin => _skin}/FlashRes/ui.xml | 26 +- {bin/skin => _skin}/FlashRes/winbk.bmp | Bin {bin/skin => _skin}/GameRes.zip | Bin {bin/skin => _skin}/GameRes/Combo_nor.bmp | Bin {bin/skin => _skin}/GameRes/Combo_over.bmp | Bin .../GameRes/Headerctrl_Sperator.bmp | Bin {bin => _skin/GameRes}/button_down.bmp | Bin {bin => _skin/GameRes}/button_nor.bmp | Bin {bin => _skin/GameRes}/button_over.bmp | Bin {bin/skin => _skin}/GameRes/chatmsgbk.png | Bin {bin/skin => _skin}/GameRes/desk.xml | 22 +- .../GameRes/frame_btn_close_disable.bmp | Bin .../GameRes/frame_btn_close_down.bmp | Bin .../GameRes/frame_btn_close_hot.bmp | Bin .../GameRes/frame_btn_close_normal.bmp | Bin {bin/skin => _skin}/GameRes/frame_btn_max.bmp | Bin {bin/skin => _skin}/GameRes/frame_btn_min.bmp | Bin {bin/skin => _skin}/GameRes/gameicons.png | Bin {bin/skin => _skin}/GameRes/hall.xml | 232 +-- .../GameRes/headerctrl_down.bmp | Bin .../skin => _skin}/GameRes/headerctrl_hot.bmp | Bin .../GameRes/headerctrl_normal.bmp | Bin {bin/skin => _skin}/GameRes/login.xml | 52 +- {bin/skin => _skin}/GameRes/scrollbar.bmp | Bin {bin/skin => _skin}/GameRes/tab_back.bmp | Bin {bin/skin => _skin}/GameRes/tab_close.png | Bin {bin/skin => _skin}/GameRes/tab_hot.bmp | Bin {bin/skin => _skin}/GameRes/tab_normal.bmp | Bin {bin/skin => _skin}/GameRes/tab_select.bmp | Bin {bin/skin => _skin}/GameRes/table.png | Bin {bin/skin => _skin}/GameRes/tree_expand.png | Bin {bin/skin => _skin}/GameRes/tree_hot.bmp | Bin {bin/skin => _skin}/GameRes/tree_select.bmp | Bin {bin/skin => _skin}/GameRes/tree_top.png | Bin {bin/skin => _skin}/GameRes/user.png | Bin {bin/skin => _skin}/GameRes/vip.png | Bin {bin/skin => _skin}/GameRes/winbk.bmp | Bin {bin/skin => _skin}/ListRes.zip | Bin {bin/skin => _skin}/ListRes/bg.png | Bin {bin/skin => _skin}/ListRes/button.png | Bin .../skin => _skin}/ListRes/list_header_bg.png | Bin .../ListRes/list_header_hot.png | Bin .../ListRes/list_header_pushed.png | Bin .../ListRes/list_header_sep.png | Bin {bin/skin => _skin}/ListRes/max_min.png | Bin {bin/skin => _skin}/ListRes/max_min_h.png | Bin {bin/skin => _skin}/ListRes/menu.xml | 34 +- {bin/skin => _skin}/ListRes/menu_bk.png | Bin {bin/skin => _skin}/ListRes/menu_hot_bk.png | Bin {bin/skin => _skin}/ListRes/scroll.png | Bin {bin/skin => _skin}/ListRes/search_bg.png | Bin {bin/skin => _skin}/ListRes/skin.xml | 72 +- {bin/skin => _skin}/RichListRes.zip | Bin {bin/skin => _skin}/RichListRes/Common.bmp | Bin {bin/skin => _skin}/RichListRes/MainWnd.xml | 252 ++-- {bin/skin => _skin}/RichListRes/Search.bmp | Bin .../RichListRes/Slide_Progress2.bmp | Bin {bin/skin => _skin}/RichListRes/Sort.bmp | Bin {bin/skin => _skin}/RichListRes/TabButton.png | Bin {bin/skin => _skin}/RichListRes/button.bmp | Bin {bin/skin => _skin}/RichListRes/color_ico.png | Bin .../RichListRes/downlist_app.png | Bin .../RichListRes/downlist_bk.png | Bin .../RichListRes/downlist_fore.png | Bin .../RichListRes/downlist_ok.png | Bin .../RichListRes/downlist_pause.png | Bin .../RichListRes/downlist_run.png | Bin {bin/skin => _skin}/RichListRes/duilib.xml | 252 ++-- {bin/skin => _skin}/RichListRes/func.bmp | Bin .../RichListRes/garbage_ico.png | Bin {bin/skin => _skin}/RichListRes/ico.png | Bin {bin/skin => _skin}/RichListRes/lilbtn.bmp | Bin {bin/skin => _skin}/RichListRes/logo.png | Bin {bin/skin => _skin}/RichListRes/main.png | Bin .../RichListRes/progress_back.png | Bin .../RichListRes/progress_fore.png | Bin {bin/skin => _skin}/RichListRes/resrc_btn.bmp | Bin {bin/skin => _skin}/RichListRes/scrollbar.bmp | Bin .../RichListRes/searchbar_bg.bmp | Bin {bin/skin => _skin}/RichListRes/status.bmp | Bin .../RichListRes/taskdetail_ico.png | Bin .../skin => _skin}/RichListRes/toolbar/bk.bmp | Bin .../RichListRes/toolbar/del.png | Bin .../RichListRes/toolbar/del2.png | Bin .../RichListRes/toolbar/fav.png | Bin .../RichListRes/toolbar/new.png | Bin .../RichListRes/toolbar/ofenuse.png | Bin .../RichListRes/toolbar/offline_down.png | Bin .../RichListRes/toolbar/open.png | Bin .../RichListRes/toolbar/open2.png | Bin .../RichListRes/toolbar/pause.png | Bin .../RichListRes/toolbar/pause2.png | Bin .../RichListRes/toolbar/setting.png | Bin .../RichListRes/toolbar/start.png | Bin .../RichListRes/toolbar/start2.png | Bin .../RichListRes/toolbar/toolbutton.bmp | Bin {bin/skin => _skin}/RichListRes/zoom.bmp | Bin bin/LeftWithFill.png | Bin 7078 -> 0 bytes bin/skin/GameRes/button_down.bmp | Bin 5530 -> 0 bytes bin/skin/GameRes/button_nor.bmp | Bin 5530 -> 0 bytes bin/skin/GameRes/button_over.bmp | Bin 5530 -> 0 bytes 148 files changed, 4163 insertions(+), 5845 deletions(-) delete mode 100644 360SafeDemo/360SafeDemo.vcproj delete mode 100644 360SafeDemo/CMakeLists.txt delete mode 100644 FlashDemo/CMakeLists.txt delete mode 100644 FlashDemo/FlashDemo.vcproj delete mode 100644 GameDemo/CMakeLists.txt delete mode 100644 GameDemo/GameDemo.sln delete mode 100644 GameDemo/GameDemo.vcproj delete mode 100644 ListDemo/CMakeLists.txt delete mode 100644 ListDemo/ListDemo.vcproj delete mode 100644 QQDemo/CMakeLists.txt delete mode 100644 QQDemo/QQDemo.vcproj delete mode 100644 RichListDemo/CMakeLists.txt delete mode 100644 RichListDemo/ReadMe.txt delete mode 100644 RichListDemo/RichListDemo.vcproj rename {bin/skin => _skin}/360SafeRes.zip (100%) rename {bin/skin => _skin}/FlashRes/frame_btn_close_disable.bmp (100%) rename {bin/skin => _skin}/FlashRes/frame_btn_close_down.bmp (100%) rename {bin/skin => _skin}/FlashRes/frame_btn_close_hot.bmp (100%) rename {bin/skin => _skin}/FlashRes/frame_btn_close_normal.bmp (100%) rename {bin/skin => _skin}/FlashRes/test.swf (100%) rename {bin/skin => _skin}/FlashRes/ui.xml (98%) rename {bin/skin => _skin}/FlashRes/winbk.bmp (100%) rename {bin/skin => _skin}/GameRes.zip (100%) rename {bin/skin => _skin}/GameRes/Combo_nor.bmp (100%) rename {bin/skin => _skin}/GameRes/Combo_over.bmp (100%) rename {bin/skin => _skin}/GameRes/Headerctrl_Sperator.bmp (100%) rename {bin => _skin/GameRes}/button_down.bmp (100%) rename {bin => _skin/GameRes}/button_nor.bmp (100%) rename {bin => _skin/GameRes}/button_over.bmp (100%) rename {bin/skin => _skin}/GameRes/chatmsgbk.png (100%) rename {bin/skin => _skin}/GameRes/desk.xml (98%) rename {bin/skin => _skin}/GameRes/frame_btn_close_disable.bmp (100%) rename {bin/skin => _skin}/GameRes/frame_btn_close_down.bmp (100%) rename {bin/skin => _skin}/GameRes/frame_btn_close_hot.bmp (100%) rename {bin/skin => _skin}/GameRes/frame_btn_close_normal.bmp (100%) rename {bin/skin => _skin}/GameRes/frame_btn_max.bmp (100%) rename {bin/skin => _skin}/GameRes/frame_btn_min.bmp (100%) rename {bin/skin => _skin}/GameRes/gameicons.png (100%) rename {bin/skin => _skin}/GameRes/hall.xml (99%) rename {bin/skin => _skin}/GameRes/headerctrl_down.bmp (100%) rename {bin/skin => _skin}/GameRes/headerctrl_hot.bmp (100%) rename {bin/skin => _skin}/GameRes/headerctrl_normal.bmp (100%) rename {bin/skin => _skin}/GameRes/login.xml (99%) rename {bin/skin => _skin}/GameRes/scrollbar.bmp (100%) rename {bin/skin => _skin}/GameRes/tab_back.bmp (100%) rename {bin/skin => _skin}/GameRes/tab_close.png (100%) rename {bin/skin => _skin}/GameRes/tab_hot.bmp (100%) rename {bin/skin => _skin}/GameRes/tab_normal.bmp (100%) rename {bin/skin => _skin}/GameRes/tab_select.bmp (100%) rename {bin/skin => _skin}/GameRes/table.png (100%) rename {bin/skin => _skin}/GameRes/tree_expand.png (100%) rename {bin/skin => _skin}/GameRes/tree_hot.bmp (100%) rename {bin/skin => _skin}/GameRes/tree_select.bmp (100%) rename {bin/skin => _skin}/GameRes/tree_top.png (100%) rename {bin/skin => _skin}/GameRes/user.png (100%) rename {bin/skin => _skin}/GameRes/vip.png (100%) rename {bin/skin => _skin}/GameRes/winbk.bmp (100%) rename {bin/skin => _skin}/ListRes.zip (100%) rename {bin/skin => _skin}/ListRes/bg.png (100%) rename {bin/skin => _skin}/ListRes/button.png (100%) rename {bin/skin => _skin}/ListRes/list_header_bg.png (100%) rename {bin/skin => _skin}/ListRes/list_header_hot.png (100%) rename {bin/skin => _skin}/ListRes/list_header_pushed.png (100%) rename {bin/skin => _skin}/ListRes/list_header_sep.png (100%) rename {bin/skin => _skin}/ListRes/max_min.png (100%) rename {bin/skin => _skin}/ListRes/max_min_h.png (100%) rename {bin/skin => _skin}/ListRes/menu.xml (97%) rename {bin/skin => _skin}/ListRes/menu_bk.png (100%) rename {bin/skin => _skin}/ListRes/menu_hot_bk.png (100%) rename {bin/skin => _skin}/ListRes/scroll.png (100%) rename {bin/skin => _skin}/ListRes/search_bg.png (100%) rename {bin/skin => _skin}/ListRes/skin.xml (99%) rename {bin/skin => _skin}/RichListRes.zip (100%) rename {bin/skin => _skin}/RichListRes/Common.bmp (100%) rename {bin/skin => _skin}/RichListRes/MainWnd.xml (99%) rename {bin/skin => _skin}/RichListRes/Search.bmp (100%) rename {bin/skin => _skin}/RichListRes/Slide_Progress2.bmp (100%) rename {bin/skin => _skin}/RichListRes/Sort.bmp (100%) rename {bin/skin => _skin}/RichListRes/TabButton.png (100%) rename {bin/skin => _skin}/RichListRes/button.bmp (100%) rename {bin/skin => _skin}/RichListRes/color_ico.png (100%) rename {bin/skin => _skin}/RichListRes/downlist_app.png (100%) rename {bin/skin => _skin}/RichListRes/downlist_bk.png (100%) rename {bin/skin => _skin}/RichListRes/downlist_fore.png (100%) rename {bin/skin => _skin}/RichListRes/downlist_ok.png (100%) rename {bin/skin => _skin}/RichListRes/downlist_pause.png (100%) rename {bin/skin => _skin}/RichListRes/downlist_run.png (100%) rename {bin/skin => _skin}/RichListRes/duilib.xml (99%) rename {bin/skin => _skin}/RichListRes/func.bmp (100%) rename {bin/skin => _skin}/RichListRes/garbage_ico.png (100%) rename {bin/skin => _skin}/RichListRes/ico.png (100%) rename {bin/skin => _skin}/RichListRes/lilbtn.bmp (100%) rename {bin/skin => _skin}/RichListRes/logo.png (100%) rename {bin/skin => _skin}/RichListRes/main.png (100%) rename {bin/skin => _skin}/RichListRes/progress_back.png (100%) rename {bin/skin => _skin}/RichListRes/progress_fore.png (100%) rename {bin/skin => _skin}/RichListRes/resrc_btn.bmp (100%) rename {bin/skin => _skin}/RichListRes/scrollbar.bmp (100%) rename {bin/skin => _skin}/RichListRes/searchbar_bg.bmp (100%) rename {bin/skin => _skin}/RichListRes/status.bmp (100%) rename {bin/skin => _skin}/RichListRes/taskdetail_ico.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/bk.bmp (100%) rename {bin/skin => _skin}/RichListRes/toolbar/del.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/del2.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/fav.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/new.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/ofenuse.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/offline_down.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/open.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/open2.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/pause.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/pause2.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/setting.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/start.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/start2.png (100%) rename {bin/skin => _skin}/RichListRes/toolbar/toolbutton.bmp (100%) rename {bin/skin => _skin}/RichListRes/zoom.bmp (100%) delete mode 100644 bin/LeftWithFill.png delete mode 100644 bin/skin/GameRes/button_down.bmp delete mode 100644 bin/skin/GameRes/button_nor.bmp delete mode 100644 bin/skin/GameRes/button_over.bmp diff --git a/360SafeDemo/360Safe.cpp b/360SafeDemo/360Safe.cpp index 1cc7d450..8b91e4d0 100644 --- a/360SafeDemo/360Safe.cpp +++ b/360SafeDemo/360Safe.cpp @@ -1,263 +1,313 @@ #include "stdafx.h" -#include -#include -#include "ControlEx.h" -class C360SafeFrameWnd : public CWindowWnd, public INotifyUI -{ -public: - C360SafeFrameWnd() { }; - LPCTSTR GetWindowClassName() const { return _T("UIMainFrame"); }; - UINT GetClassStyle() const { return CS_DBLCLKS; }; - void OnFinalMessage(HWND /*hWnd*/) { delete this; }; - - void Init() { - m_pCloseBtn = static_cast(m_pm.FindControl(_T("closebtn"))); - m_pMaxBtn = static_cast(m_pm.FindControl(_T("maxbtn"))); - m_pRestoreBtn = static_cast(m_pm.FindControl(_T("restorebtn"))); - m_pMinBtn = static_cast(m_pm.FindControl(_T("minbtn"))); - } - - void OnPrepare() { - } - - void Notify(TNotifyUI& msg) - { - if( msg.sType == _T("windowinit") ) OnPrepare(); - 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.sType==_T("selectchanged")) - { - CDuiString name = msg.pSender->GetName(); - CTabLayoutUI* pControl = static_cast(m_pm.FindControl(_T("switch"))); - if(name==_T("examine")) - pControl->SelectItem(0); - else if(name==_T("trojan")) - pControl->SelectItem(1); - else if(name==_T("plugins")) - pControl->SelectItem(2); - else if(name==_T("vulnerability")) - pControl->SelectItem(3); - else if(name==_T("rubbish")) - pControl->SelectItem(4); - else if(name==_T("cleanup")) - pControl->SelectItem(5); - else if(name==_T("fix")) - pControl->SelectItem(6); - else if(name==_T("tool")) - pControl->SelectItem(7); - } - } - - LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - 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("skin.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(m_pm.FindControl(pt)); - if( pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 && - _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 && - _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 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); - } +#include +#include +#include "ControlEx.h" +#include "umu/apppath_t.h" + +class C360SafeFrameWnd : public CWindowWnd, public INotifyUI { + public: + C360SafeFrameWnd(){}; + LPCTSTR GetWindowClassName() const { return _T("UIMainFrame"); }; + UINT GetClassStyle() const { return CS_DBLCLKS; }; + void OnFinalMessage(HWND /*hWnd*/) { delete this; }; + + void Init() { + m_pCloseBtn = static_cast(m_pm.FindControl(_T("closebtn"))); + m_pMaxBtn = static_cast(m_pm.FindControl(_T("maxbtn"))); + m_pRestoreBtn = static_cast(m_pm.FindControl(_T("restorebtn"))); + m_pMinBtn = static_cast(m_pm.FindControl(_T("minbtn"))); + } + + void OnPrepare() {} + + void Notify(TNotifyUI& msg) { + if (msg.sType == _T("windowinit")) + OnPrepare(); + 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.sType == _T("selectchanged")) { + CDuiString name = msg.pSender->GetName(); + CTabLayoutUI* pControl = + static_cast(m_pm.FindControl(_T("switch"))); + if (name == _T("examine")) + pControl->SelectItem(0); + else if (name == _T("trojan")) + pControl->SelectItem(1); + else if (name == _T("plugins")) + pControl->SelectItem(2); + else if (name == _T("vulnerability")) + pControl->SelectItem(3); + else if (name == _T("rubbish")) + pControl->SelectItem(4); + else if (name == _T("cleanup")) + pControl->SelectItem(5); + else if (name == _T("fix")) + pControl->SelectItem(6); + else if (name == _T("tool")) + pControl->SelectItem(7); + } + } + + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + 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("skin.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(m_pm.FindControl(pt)); + if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 && + _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 && + _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 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(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.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(m_pm.FindControl(_T("maxbtn"))); + if (pControl) + pControl->SetVisible(false); + pControl = static_cast(m_pm.FindControl(_T("restorebtn"))); + if (pControl) + pControl->SetVisible(true); + } else { + CControlUI* pControl = + static_cast(m_pm.FindControl(_T("maxbtn"))); + if (pControl) + pControl->SetVisible(true); + pControl = static_cast(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; - 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(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.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(m_pm.FindControl(_T("maxbtn"))); - if( pControl ) pControl->SetVisible(false); - pControl = static_cast(m_pm.FindControl(_T("restorebtn"))); - if( pControl ) pControl->SetVisible(true); - } - else { - CControlUI* pControl = static_cast(m_pm.FindControl(_T("maxbtn"))); - if( pControl ) pControl->SetVisible(true); - pControl = static_cast(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; - //... + } + 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; + //... }; - -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow) -{ - CPaintManagerUI::SetInstance(hInstance); - CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin")); - CPaintManagerUI::SetResourceZip(_T("360SafeRes.zip")); - - HRESULT Hr = ::CoInitialize(NULL); - if( FAILED(Hr) ) return 0; - - C360SafeFrameWnd* pFrame = new C360SafeFrameWnd(); - if( pFrame == NULL ) return 0; - pFrame->Create(NULL, _T("360��ȫ��ʿ"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 800, 572); - pFrame->CenterWindow(); - ::ShowWindow(*pFrame, SW_SHOW); - - CPaintManagerUI::MessageLoop(); - - ::CoUninitialize(); - return 0; +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE /*hPrevInstance*/, + LPSTR /*lpCmdLine*/, + int nCmdShow) { + CPaintManagerUI::SetInstance(hInstance); + CPaintManagerUI::SetResourcePath(umu::apppath::GetProductDirectory() + + _T("_skin")); + CPaintManagerUI::SetResourceZip(_T("360SafeRes.zip")); + + HRESULT Hr = ::CoInitialize(NULL); + if (FAILED(Hr)) + return 0; + + C360SafeFrameWnd* pFrame = new C360SafeFrameWnd(); + if (pFrame == NULL) + return 0; + pFrame->Create(NULL, _T("360��ȫ��ʿ"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 800, + 572); + pFrame->CenterWindow(); + ::ShowWindow(*pFrame, SW_SHOW); + + CPaintManagerUI::MessageLoop(); + + ::CoUninitialize(); + return 0; } \ No newline at end of file diff --git a/360SafeDemo/360SafeDemo.vcproj b/360SafeDemo/360SafeDemo.vcproj deleted file mode 100644 index 0620b594..00000000 --- a/360SafeDemo/360SafeDemo.vcproj +++ /dev/null @@ -1,463 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/360SafeDemo/360SafeDemo.vcxproj b/360SafeDemo/360SafeDemo.vcxproj index d3ae7027..5deb417d 100644 --- a/360SafeDemo/360SafeDemo.vcxproj +++ b/360SafeDemo/360SafeDemo.vcxproj @@ -1,61 +1,106 @@  - + - + Debug + x64 + + + MbcsDebug Win32 - - Release + + MbcsDebug + x64 + + + MbcsRelease Win32 - - UnicodeDebug + + Debug Win32 - - UnicodeRelease + + MbcsRelease + x64 + + + Release Win32 + + Release + x64 + 360Safe {463FE628-A176-4C58-B005-3924BFD1E4E6} 360 + 10.0.17134.0 - + Application - v120 + v141 false Unicode + true - + Application - v120 + v141 false Unicode + true Application - v120 + v141 + false + Unicode + + + Application + v141 + false + Unicode + + + Application + v141 false MultiByte - + + Application + v141 + false + MultiByte + + Application - v120 + v141 false MultiByte + true + + + Application + v141 + false + MultiByte + true - + - + @@ -63,7 +108,23 @@ - + + + + + + + + + + + + + + + + + @@ -71,27 +132,39 @@ <_ProjectFileVersion>12.0.30501.0 - - $(SolutionDir)\bin\ - .\Release\ + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + + false + + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + false - $(SolutionDir)\bin\ - .\Debug\ false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - - $(SolutionDir)\bin\ - .\Debug_u\ + false - - $(SolutionDir)\bin\ - .\Release_u\ + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - + + false + + NDEBUG;%(PreprocessorDefinitions) true @@ -109,32 +182,54 @@ true Use stdafx.h - .\Release/360Safe.pch - .\Release/ - .\Release/ - .\Release/ Level3 true + ..\;..\include\; NDEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/360Safe.exe true - .\Release/360Safe.pdb Windows MachineX86 - $(SolutionDir)\lib\;%(AdditionalLibraryDirectories) - duilib.lib;%(AdditionalDependencies) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/360Safe.tlb + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + Use + stdafx.h + Level3 true - .\Release/360Safe.bsc - + ..\;..\include\; + + + NDEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + Windows + + - + _DEBUG;%(PreprocessorDefinitions) true @@ -151,37 +246,60 @@ MultiThreadedDebug Use stdafx.h - .\Debug/360Safe.pch - .\Debug/ - .\Debug/ - .\Debug/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/360Safe_d.exe true true - .\Debug/360Safe.pdb true .\Debug/360Safe.map Windows MachineX86 - DuiLib_d.lib;%(AdditionalDependencies) - $(SolutionDir)\lib\;%(AdditionalLibraryDirectories) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/360Safe.tlb + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Use + stdafx.h + Level3 + true + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0406 + + true - .\Debug/360Safe.bsc - + true + true + .\Debug/360Safe.map + Windows + + - + _DEBUG;%(PreprocessorDefinitions) true @@ -198,37 +316,60 @@ MultiThreadedDebug Use stdafx.h - .\Debug_u/360Safe.pch - .\Debug_u/ - .\Debug_u/ - .\Debug_u/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/360Safe_ud.exe true true - .\Debug_u/360Safe.pdb true .\Debug_u/360Safe.map Windows MachineX86 - $(SolutionDir)\lib\;%(AdditionalLibraryDirectories) - duilib_ud.lib;%(AdditionalDependencies) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/360Safe.tlb + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Use + stdafx.h + Level3 true - .\Debug/360Safe.bsc - + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + true + true + .\Debug_u/360Safe.map + Windows + + - + NDEBUG;%(PreprocessorDefinitions) true @@ -246,44 +387,75 @@ true Use stdafx.h - .\Release_u/360Safe.pch - .\Release_u/ - .\Release_u/ - .\Release_u/ Level3 true + ..\;..\include\; NDEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/360Safe_u.exe true - .\Release_u/360Safe.pdb Windows MachineX86 - $(SolutionDir)\lib\;%(AdditionalLibraryDirectories) - duilib_u.lib;%(AdditionalDependencies) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/360Safe.tlb + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + Use + stdafx.h + Level3 true - .\Release/360Safe.bsc - + ..\;..\include\; + + + NDEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + Windows + + + Create + Create + Create + Create Create + Create Create - Create - Create + Create + + + {e106acd7-4e53-4aee-942b-d0dd426db34e} + + diff --git a/360SafeDemo/CMakeLists.txt b/360SafeDemo/CMakeLists.txt deleted file mode 100644 index 7dc33892..00000000 --- a/360SafeDemo/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -#Cmake file for 360SafeDemo -#Author: Qi Gao(monkgau@gmail.com) -#Date: 2012/9/17 - -set(source_files 360safe.cpp stdafx.cpp) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -add_executable(360safedemo ${source_files}) -set_target_properties(360safedemo PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") -add_dependencies(360safedemo duilib) -target_link_libraries(360safedemo duilib) -add_custom_command(TARGET 360safedemo POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${PROJECT_BINARY_DIR}/bin/360safedemo.exe ${PROJECT_SOURCE_DIR}/bin/360safedemo.exe) diff --git a/360SafeDemo/StdAfx.h b/360SafeDemo/StdAfx.h index 901806da..18690ffc 100644 --- a/360SafeDemo/StdAfx.h +++ b/360SafeDemo/StdAfx.h @@ -1,4 +1,3 @@ - #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ @@ -11,7 +10,7 @@ #include #include -#include "..\DuiLib\UIlib.h" +#include "DuiLib/UIlib.h" using namespace DuiLib; diff --git a/DuiLib.sln b/DuiLib.sln index 9907edf9..47a59ca4 100644 --- a/DuiLib.sln +++ b/DuiLib.sln @@ -17,6 +17,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp1", "TestApp1\TestAp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScrCapture", "ScrCapture\ScrCapture.vcxproj", "{41B017E7-7805-40D5-9D96-AABF572F57D2}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ListDemo", "ListDemo\ListDemo.vcxproj", "{223017E7-7805-40D5-9D96-AABF572F57D1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "360Safe", "360SafeDemo\360SafeDemo.vcxproj", "{463FE628-A176-4C58-B005-3924BFD1E4E6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QQDemo", "QQDemo\QQDemo.vcxproj", "{5EEA82DD-05C7-477F-8870-942E8758BFFF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RichListDemo", "RichListDemo\RichListDemo.vcxproj", "{6F77AFCB-2F96-4573-8882-3578EBA8CA1D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameDemo", "GameDemo\GameDemo.vcxproj", "{21B017E7-7805-40D5-9D96-AABF572F57D1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FlashDemo", "FlashDemo\FlashDemo.vcxproj", "{41B017E7-7805-40D5-9D96-AABF572F5700}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -84,6 +96,7 @@ Global {11A20D10-E0D7-447F-A546-8E4662C115C5}.MbcsDebug|Win32.ActiveCfg = MbcsDebug|Win32 {11A20D10-E0D7-447F-A546-8E4662C115C5}.MbcsDebug|Win32.Build.0 = MbcsDebug|Win32 {11A20D10-E0D7-447F-A546-8E4662C115C5}.MbcsDebug|x64.ActiveCfg = MbcsDebug|Win32 + {11A20D10-E0D7-447F-A546-8E4662C115C5}.MbcsDebug|x64.Build.0 = MbcsDebug|Win32 {11A20D10-E0D7-447F-A546-8E4662C115C5}.MbcsRelease|Win32.ActiveCfg = MbcsRelease|Win32 {11A20D10-E0D7-447F-A546-8E4662C115C5}.MbcsRelease|Win32.Build.0 = MbcsRelease|Win32 {11A20D10-E0D7-447F-A546-8E4662C115C5}.MbcsRelease|x64.ActiveCfg = MbcsRelease|Win32 @@ -123,6 +136,102 @@ Global {41B017E7-7805-40D5-9D96-AABF572F57D2}.Release|Win32.Build.0 = Release|Win32 {41B017E7-7805-40D5-9D96-AABF572F57D2}.Release|x64.ActiveCfg = Release|x64 {41B017E7-7805-40D5-9D96-AABF572F57D2}.Release|x64.Build.0 = Release|x64 + {223017E7-7805-40D5-9D96-AABF572F57D1}.Debug|Win32.ActiveCfg = Debug|Win32 + {223017E7-7805-40D5-9D96-AABF572F57D1}.Debug|Win32.Build.0 = Debug|Win32 + {223017E7-7805-40D5-9D96-AABF572F57D1}.Debug|x64.ActiveCfg = Debug|x64 + {223017E7-7805-40D5-9D96-AABF572F57D1}.Debug|x64.Build.0 = Debug|x64 + {223017E7-7805-40D5-9D96-AABF572F57D1}.MbcsDebug|Win32.ActiveCfg = MbcsDebug|Win32 + {223017E7-7805-40D5-9D96-AABF572F57D1}.MbcsDebug|Win32.Build.0 = MbcsDebug|Win32 + {223017E7-7805-40D5-9D96-AABF572F57D1}.MbcsDebug|x64.ActiveCfg = MbcsDebug|x64 + {223017E7-7805-40D5-9D96-AABF572F57D1}.MbcsDebug|x64.Build.0 = MbcsDebug|x64 + {223017E7-7805-40D5-9D96-AABF572F57D1}.MbcsRelease|Win32.ActiveCfg = MbcsRelease|Win32 + {223017E7-7805-40D5-9D96-AABF572F57D1}.MbcsRelease|Win32.Build.0 = MbcsRelease|Win32 + {223017E7-7805-40D5-9D96-AABF572F57D1}.MbcsRelease|x64.ActiveCfg = MbcsRelease|x64 + {223017E7-7805-40D5-9D96-AABF572F57D1}.MbcsRelease|x64.Build.0 = MbcsRelease|x64 + {223017E7-7805-40D5-9D96-AABF572F57D1}.Release|Win32.ActiveCfg = Release|Win32 + {223017E7-7805-40D5-9D96-AABF572F57D1}.Release|Win32.Build.0 = Release|Win32 + {223017E7-7805-40D5-9D96-AABF572F57D1}.Release|x64.ActiveCfg = Release|x64 + {223017E7-7805-40D5-9D96-AABF572F57D1}.Release|x64.Build.0 = Release|x64 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.Debug|Win32.ActiveCfg = Debug|Win32 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.Debug|Win32.Build.0 = Debug|Win32 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.Debug|x64.ActiveCfg = Debug|x64 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.Debug|x64.Build.0 = Debug|x64 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.MbcsDebug|Win32.ActiveCfg = MbcsDebug|Win32 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.MbcsDebug|Win32.Build.0 = MbcsDebug|Win32 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.MbcsDebug|x64.ActiveCfg = MbcsDebug|x64 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.MbcsDebug|x64.Build.0 = MbcsDebug|x64 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.MbcsRelease|Win32.ActiveCfg = MbcsRelease|Win32 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.MbcsRelease|Win32.Build.0 = MbcsRelease|Win32 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.MbcsRelease|x64.ActiveCfg = MbcsRelease|x64 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.MbcsRelease|x64.Build.0 = MbcsRelease|x64 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.Release|Win32.ActiveCfg = Release|Win32 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.Release|Win32.Build.0 = Release|Win32 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.Release|x64.ActiveCfg = Release|x64 + {463FE628-A176-4C58-B005-3924BFD1E4E6}.Release|x64.Build.0 = Release|x64 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.Debug|Win32.ActiveCfg = Debug|Win32 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.Debug|Win32.Build.0 = Debug|Win32 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.Debug|x64.ActiveCfg = Debug|x64 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.Debug|x64.Build.0 = Debug|x64 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.MbcsDebug|Win32.ActiveCfg = MbcsDebug|Win32 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.MbcsDebug|Win32.Build.0 = MbcsDebug|Win32 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.MbcsDebug|x64.ActiveCfg = MbcsDebug|x64 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.MbcsDebug|x64.Build.0 = MbcsDebug|x64 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.MbcsRelease|Win32.ActiveCfg = MbcsRelease|Win32 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.MbcsRelease|Win32.Build.0 = MbcsRelease|Win32 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.MbcsRelease|x64.ActiveCfg = MbcsRelease|x64 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.MbcsRelease|x64.Build.0 = MbcsRelease|x64 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.Release|Win32.ActiveCfg = Release|Win32 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.Release|Win32.Build.0 = Release|Win32 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.Release|x64.ActiveCfg = Release|x64 + {5EEA82DD-05C7-477F-8870-942E8758BFFF}.Release|x64.Build.0 = Release|x64 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.Debug|Win32.ActiveCfg = Debug|Win32 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.Debug|Win32.Build.0 = Debug|Win32 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.Debug|x64.ActiveCfg = Debug|x64 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.Debug|x64.Build.0 = Debug|x64 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.MbcsDebug|Win32.ActiveCfg = MbcsDebug|Win32 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.MbcsDebug|Win32.Build.0 = MbcsDebug|Win32 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.MbcsDebug|x64.ActiveCfg = MbcsDebug|x64 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.MbcsDebug|x64.Build.0 = MbcsDebug|x64 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.MbcsRelease|Win32.ActiveCfg = MbcsRelease|Win32 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.MbcsRelease|Win32.Build.0 = MbcsRelease|Win32 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.MbcsRelease|x64.ActiveCfg = MbcsRelease|x64 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.MbcsRelease|x64.Build.0 = MbcsRelease|x64 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.Release|Win32.ActiveCfg = Release|Win32 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.Release|Win32.Build.0 = Release|Win32 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.Release|x64.ActiveCfg = Release|x64 + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.Release|x64.Build.0 = Release|x64 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.Debug|Win32.ActiveCfg = Debug|Win32 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.Debug|Win32.Build.0 = Debug|Win32 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.Debug|x64.ActiveCfg = Debug|x64 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.Debug|x64.Build.0 = Debug|x64 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.MbcsDebug|Win32.ActiveCfg = MbcsDebug|Win32 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.MbcsDebug|Win32.Build.0 = MbcsDebug|Win32 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.MbcsDebug|x64.ActiveCfg = MbcsDebug|x64 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.MbcsDebug|x64.Build.0 = MbcsDebug|x64 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.MbcsRelease|Win32.ActiveCfg = MbcsRelease|Win32 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.MbcsRelease|Win32.Build.0 = MbcsRelease|Win32 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.MbcsRelease|x64.ActiveCfg = MbcsRelease|x64 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.MbcsRelease|x64.Build.0 = MbcsRelease|x64 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.Release|Win32.ActiveCfg = Release|Win32 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.Release|Win32.Build.0 = Release|Win32 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.Release|x64.ActiveCfg = Release|x64 + {21B017E7-7805-40D5-9D96-AABF572F57D1}.Release|x64.Build.0 = Release|x64 + {41B017E7-7805-40D5-9D96-AABF572F5700}.Debug|Win32.ActiveCfg = Debug|Win32 + {41B017E7-7805-40D5-9D96-AABF572F5700}.Debug|Win32.Build.0 = Debug|Win32 + {41B017E7-7805-40D5-9D96-AABF572F5700}.Debug|x64.ActiveCfg = Debug|x64 + {41B017E7-7805-40D5-9D96-AABF572F5700}.Debug|x64.Build.0 = Debug|x64 + {41B017E7-7805-40D5-9D96-AABF572F5700}.MbcsDebug|Win32.ActiveCfg = MbcsDebug|Win32 + {41B017E7-7805-40D5-9D96-AABF572F5700}.MbcsDebug|Win32.Build.0 = MbcsDebug|Win32 + {41B017E7-7805-40D5-9D96-AABF572F5700}.MbcsDebug|x64.ActiveCfg = MbcsDebug|x64 + {41B017E7-7805-40D5-9D96-AABF572F5700}.MbcsDebug|x64.Build.0 = MbcsDebug|x64 + {41B017E7-7805-40D5-9D96-AABF572F5700}.MbcsRelease|Win32.ActiveCfg = MbcsRelease|Win32 + {41B017E7-7805-40D5-9D96-AABF572F5700}.MbcsRelease|Win32.Build.0 = MbcsRelease|Win32 + {41B017E7-7805-40D5-9D96-AABF572F5700}.MbcsRelease|x64.ActiveCfg = MbcsRelease|x64 + {41B017E7-7805-40D5-9D96-AABF572F5700}.MbcsRelease|x64.Build.0 = MbcsRelease|x64 + {41B017E7-7805-40D5-9D96-AABF572F5700}.Release|Win32.ActiveCfg = Release|Win32 + {41B017E7-7805-40D5-9D96-AABF572F5700}.Release|Win32.Build.0 = Release|Win32 + {41B017E7-7805-40D5-9D96-AABF572F5700}.Release|x64.ActiveCfg = Release|x64 + {41B017E7-7805-40D5-9D96-AABF572F5700}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -133,6 +242,12 @@ Global {11A20D10-E0D7-447F-A546-8E4662C115C5} = {5ABBC10A-DC58-4A8D-AA4D-D1CB2A58FD01} {41B017E7-7805-40D5-9D96-AABF572F57D1} = {5ABBC10A-DC58-4A8D-AA4D-D1CB2A58FD01} {41B017E7-7805-40D5-9D96-AABF572F57D2} = {5ABBC10A-DC58-4A8D-AA4D-D1CB2A58FD01} + {223017E7-7805-40D5-9D96-AABF572F57D1} = {5ABBC10A-DC58-4A8D-AA4D-D1CB2A58FD01} + {463FE628-A176-4C58-B005-3924BFD1E4E6} = {5ABBC10A-DC58-4A8D-AA4D-D1CB2A58FD01} + {5EEA82DD-05C7-477F-8870-942E8758BFFF} = {5ABBC10A-DC58-4A8D-AA4D-D1CB2A58FD01} + {6F77AFCB-2F96-4573-8882-3578EBA8CA1D} = {5ABBC10A-DC58-4A8D-AA4D-D1CB2A58FD01} + {21B017E7-7805-40D5-9D96-AABF572F57D1} = {5ABBC10A-DC58-4A8D-AA4D-D1CB2A58FD01} + {41B017E7-7805-40D5-9D96-AABF572F5700} = {5ABBC10A-DC58-4A8D-AA4D-D1CB2A58FD01} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DDD20D8F-7857-4254-8930-28B1293AB54E} diff --git a/FlashDemo/App.cpp b/FlashDemo/App.cpp index 09ca55a4..493e1320 100644 --- a/FlashDemo/App.cpp +++ b/FlashDemo/App.cpp @@ -1,163 +1,193 @@ // App.cpp : Defines the entry point for the application. // - #include "stdafx.h" -#include "flash10a.tlh" - -class CFrameWnd : public CWindowWnd, public INotifyUI -{ -public: - CFrameWnd() { }; - LPCTSTR GetWindowClassName() const { return _T("UIFrame"); }; - UINT GetClassStyle() const { return UI_CLASSSTYLE_DIALOG; }; - void OnFinalMessage(HWND /*hWnd*/) { delete this; }; - - void Init() - { - } - - void Notify(TNotifyUI& msg) - { - if( msg.sType == _T("click") ) { - if( msg.pSender->GetName() == _T("closebtn") || msg.pSender->GetName() == _T("closebtn2") ) { - PostQuitMessage(0); - return; - } - } - else if( msg.sType == _T("showactivex") ) { - if( msg.pSender->GetName() != _T("flash") ) return; - IShockwaveFlash* pFlash = NULL; - CActiveXUI* pActiveX = static_cast(msg.pSender); - pActiveX->GetControl(IID_IUnknown, (void**)&pFlash); - if( pFlash != NULL ) { - pFlash->put_WMode( _bstr_t(_T("Transparent") ) ); - pFlash->put_Movie( _bstr_t(CPaintManagerUI::GetInstancePath() + _T("\\skin\\FlashRes\\test.swf")) ); - pFlash->DisableLocalSecurity(); - pFlash->put_AllowScriptAccess(L"always"); - BSTR response; - pFlash->CallFunction(L"Click me!", &response); - pFlash->Release(); - } - } - } - LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - 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; - CControlUI* pRoot = builder.Create(_T("ui.xml"), (UINT)0, NULL, &m_pm); - ASSERT(pRoot && "Failed to parse XML"); - m_pm.AttachDialog(pRoot); - m_pm.AddNotifier(this); - - Init(); - return 0; - } - - LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - ::PostQuitMessage(0L); +#include "umu/apppath_t.h" +#include "flash10a.tlh" - bHandled = FALSE; - return 0; +class CFrameWnd : public CWindowWnd, public INotifyUI { + public: + CFrameWnd(){}; + LPCTSTR GetWindowClassName() const { return _T("UIFrame"); }; + UINT GetClassStyle() const { return UI_CLASSSTYLE_DIALOG; }; + void OnFinalMessage(HWND /*hWnd*/) { delete this; }; + + void Init() {} + + void Notify(TNotifyUI& msg) { + if (msg.sType == _T("click")) { + if (msg.pSender->GetName() == _T("closebtn") || + msg.pSender->GetName() == _T("closebtn2")) { + PostQuitMessage(0); + return; + } + } else if (msg.sType == _T("showactivex")) { + if (msg.pSender->GetName() != _T("flash")) + return; + IShockwaveFlash* pFlash = NULL; + CActiveXUI* pActiveX = static_cast(msg.pSender); + pActiveX->GetControl(IID_IUnknown, (void**)&pFlash); + if (pFlash != NULL) { + pFlash->put_WMode(_bstr_t(_T("Transparent"))); + pFlash->put_Movie(_bstr_t(umu::apppath::GetProductDirectory() + + _T("_skin\\FlashRes\\test.swf"))); + pFlash->DisableLocalSecurity(); + pFlash->put_AllowScriptAccess(L"always"); + BSTR response; + pFlash->CallFunction( + L"Click " + L"me!", + &response); + pFlash->Release(); + } } + } + + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + 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; + CControlUI* pRoot = builder.Create(_T("ui.xml"), (UINT)0, NULL, &m_pm); + ASSERT(pRoot && "Failed to parse XML"); + m_pm.AttachDialog(pRoot); + m_pm.AddNotifier(this); + + Init(); + return 0; + } - LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - if( ::IsIconic(*this) ) bHandled = FALSE; - return (wParam == 0) ? TRUE : FALSE; - } + LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + ::PostQuitMessage(0L); - LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - return 0; - } + 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 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); + + 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(m_pm.FindControl(pt)); + if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0) + return HTCAPTION; } - 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); - - 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(m_pm.FindControl(pt)); - if( pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 ) - return HTCAPTION; - } - - return HTCLIENT; + 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); } - 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 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_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; + default: bHandled = FALSE; - return 0; } - - 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_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; - 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; + if (bHandled) + return lRes; + if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes)) + return lRes; + return CWindowWnd::HandleMessage(uMsg, wParam, lParam); + } + + public: + CPaintManagerUI m_pm; }; +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE /*hPrevInstance*/, + LPSTR /*lpCmdLine*/, + int nCmdShow) { + CPaintManagerUI::SetInstance(hInstance); + CPaintManagerUI::SetResourcePath(umu::apppath::GetProductDirectory() + + _T("_skin\\FlashRes")); -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow) -{ - CPaintManagerUI::SetInstance(hInstance); - CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin\\FlashRes")); - - HRESULT Hr = ::CoInitialize(NULL); - if( FAILED(Hr) ) return 0; - - CFrameWnd* pFrame = new CFrameWnd(); - if( pFrame == NULL ) return 0; - pFrame->Create(NULL, NULL, UI_WNDSTYLE_DIALOG, 0); - pFrame->CenterWindow(); - pFrame->ShowWindow(true); - CPaintManagerUI::MessageLoop(); + HRESULT Hr = ::CoInitialize(NULL); + if (FAILED(Hr)) + return 0; - ::CoUninitialize(); + CFrameWnd* pFrame = new CFrameWnd(); + if (pFrame == NULL) return 0; + pFrame->Create(NULL, NULL, UI_WNDSTYLE_DIALOG, 0); + pFrame->CenterWindow(); + pFrame->ShowWindow(true); + CPaintManagerUI::MessageLoop(); + + ::CoUninitialize(); + return 0; } diff --git a/FlashDemo/CMakeLists.txt b/FlashDemo/CMakeLists.txt deleted file mode 100644 index 325229b3..00000000 --- a/FlashDemo/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -#Cmake file for FlashDemo -#Author: Qi Gao(monkgau@gmail.com) -#Created: 2012/9/17 - -set(source_files App.cpp StdAfx.cpp) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -add_executable(FlashDemo ${source_files}) -add_dependencies(FlashDemo duilib) -target_link_libraries(FlashDemo duilib) -set_target_properties(FlashDemo PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") - -add_custom_command(TARGET FlashDemo POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${PROJECT_BINARY_DIR}/bin/FlashDemo.exe ${PROJECT_SOURCE_DIR}/bin/FlashDemo.exe) diff --git a/FlashDemo/FlashDemo.vcproj b/FlashDemo/FlashDemo.vcproj deleted file mode 100644 index aa045536..00000000 --- a/FlashDemo/FlashDemo.vcproj +++ /dev/null @@ -1,498 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FlashDemo/FlashDemo.vcxproj b/FlashDemo/FlashDemo.vcxproj index 2ac83162..33909f29 100644 --- a/FlashDemo/FlashDemo.vcxproj +++ b/FlashDemo/FlashDemo.vcxproj @@ -1,59 +1,104 @@  - + - + Debug + x64 + + + MbcsDebug Win32 - - Release + + MbcsDebug + x64 + + + MbcsRelease Win32 - - UnicodeDebug + + Debug Win32 - - UnicodeRelease + + MbcsRelease + x64 + + + Release Win32 + + Release + x64 + {41B017E7-7805-40D5-9D96-AABF572F5700} + 10.0.17134.0 - + Application - v120 + v141 false Unicode + true - + Application - v120 + v141 false Unicode + true Application - v120 + v141 + false + Unicode + + + Application + v141 + false + Unicode + + + Application + v141 false MultiByte - + + Application + v141 + false + MultiByte + + Application - v120 + v141 false MultiByte + true + + + Application + v141 + false + MultiByte + true - + - + @@ -61,7 +106,23 @@ - + + + + + + + + + + + + + + + + + @@ -69,27 +130,47 @@ <_ProjectFileVersion>12.0.30501.0 - - $(SolutionDir)\bin\ - .\Release\ + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\bin\ - .\Debug\ false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - - $(SolutionDir)\bin\ - .\Debug_u\ + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - - $(SolutionDir)\bin\ - .\Release_u\ + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + NDEBUG;%(PreprocessorDefinitions) true @@ -103,36 +184,60 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Use stdafx.h - .\Release/FlashDemo.pch - .\Release/ - .\Release/ - .\Release/ Level3 true + true + ..\;..\include\; NDEBUG;%(PreprocessorDefinitions) 0x0406 - duilib.lib;comsuppw.lib;%(AdditionalDependencies) - ../bin/FlashDemo.exe true - .\Release/FlashDemo.pdb Windows MachineX86 - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/FlashDemo.tlb + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + Use + stdafx.h + Level3 true - .\Release/FlashDemo.bsc - + true + ..\;..\include\; + + + NDEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + Windows + + - + _DEBUG;%(PreprocessorDefinitions) true @@ -149,37 +254,56 @@ MultiThreadedDebug Use stdafx.h - .\Debug/FlashDemo.pch - .\Debug/ - .\Debug/ - .\Debug/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) 0x0406 - duilib_d.lib;comsuppwd.lib;%(AdditionalDependencies) - ../bin/FlashDemo_d.exe true true - .\Debug/FlashDemo.pdb - true - .\Debug/FlashDemo.map Windows MachineX86 - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true true - .\Debug/FlashDemo.bsc - + .\Debug/FlashDemo.tlb + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Use + stdafx.h + Level3 + true + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + true + Windows + + - + _DEBUG;%(PreprocessorDefinitions) true @@ -196,37 +320,56 @@ MultiThreadedDebug Use stdafx.h - .\Debug_u/FlashDemo.pch - .\Debug_u/ - .\Debug_u/ - .\Debug_u/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) 0x0406 - duilib_ud.lib;comsuppwd.lib;%(AdditionalDependencies) - ../bin/FlashDemo_ud.exe true true - .\Debug_u/FlashDemo.pdb - true - .\Debug_u/FlashDemo.map Windows MachineX86 - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true true - .\Debug/FlashDemo.bsc - + .\Debug/FlashDemo.tlb + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Use + stdafx.h + Level3 + true + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + true + Windows + + - + NDEBUG;%(PreprocessorDefinitions) true @@ -240,42 +383,70 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Use stdafx.h - .\Release_u/FlashDemo.pch - .\Release_u/ - .\Release_u/ - .\Release_u/ Level3 true + true + ..\;..\include\; NDEBUG;%(PreprocessorDefinitions) 0x0406 - duilib_u.lib;comsuppw.lib;%(AdditionalDependencies) - ../bin/FlashDemo_u.exe true - .\Release_u/FlashDemo.pdb Windows MachineX86 - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/FlashDemo.tlb + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + Use + stdafx.h + Level3 + true + true + ..\;..\include\; + + + NDEBUG;%(PreprocessorDefinitions) + 0x0406 + + true - .\Release/FlashDemo.bsc - + Windows + + + Create + Create + Create + Create Create + Create Create - Create - Create + Create @@ -284,6 +455,11 @@ + + + {e106acd7-4e53-4aee-942b-d0dd426db34e} + + diff --git a/FlashDemo/StdAfx.h b/FlashDemo/StdAfx.h index cdd931cf..de261f21 100644 --- a/FlashDemo/StdAfx.h +++ b/FlashDemo/StdAfx.h @@ -1,4 +1,3 @@ - #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ @@ -7,10 +6,10 @@ #define WIN32_LEAN_AND_MEAN #define _CRT_SECURE_NO_DEPRECATE -#include -#include +#include +#include -#include "..\DuiLib\UIlib.h" +#include "DuiLib/UIlib.h" using namespace DuiLib; diff --git a/GameDemo/CMakeLists.txt b/GameDemo/CMakeLists.txt deleted file mode 100644 index 43066243..00000000 --- a/GameDemo/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -#Cmake file for GameDemo -#Author: Qi Gao(monkgau@gmail.com) -#Created: 2012/9/17 - -set(source_files GameDemo.cpp MiniDumper.cpp stdAfx.cpp) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -add_executable(GameDemo ${source_files}) -add_dependencies(GameDemo duilib) -target_link_libraries(GameDemo duilib) -set_target_properties(GameDemo PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") - -add_custom_command(TARGET GameDemo POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${PROJECT_BINARY_DIR}/bin/GameDemo.exe ${PROJECT_SOURCE_DIR}/bin/GameDemo.exe) diff --git a/GameDemo/GameDemo.cpp b/GameDemo/GameDemo.cpp index b416062a..fc3b9d32 100644 --- a/GameDemo/GameDemo.cpp +++ b/GameDemo/GameDemo.cpp @@ -2,638 +2,758 @@ // #include "stdafx.h" -#include -#include - -#include "MiniDumper.h" -CMiniDumper g_miniDumper( true ); #include "ControlEx.h" +#include "MiniDumper.h" -class CLoginFrameWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI -{ -public: - CLoginFrameWnd() { }; - LPCTSTR GetWindowClassName() const { return _T("UILoginFrame"); }; - UINT GetClassStyle() const { return UI_CLASSSTYLE_DIALOG; }; - void OnFinalMessage(HWND /*hWnd*/) - { - m_pm.RemovePreMessageFilter(this); - delete this; - }; - - void Init() { - CComboUI* pAccountCombo = static_cast(m_pm.FindControl(_T("accountcombo"))); - CEditUI* pAccountEdit = static_cast(m_pm.FindControl(_T("accountedit"))); - if( pAccountCombo && pAccountEdit ) pAccountEdit->SetText(pAccountCombo->GetText()); - pAccountEdit->SetFocus(); - } - - void Notify(TNotifyUI& msg) - { - if( msg.sType == _T("click") ) { - if( msg.pSender->GetName() == _T("closebtn") ) { PostQuitMessage(0); return; } - else if( msg.pSender->GetName() == _T("loginBtn") ) { Close(); return; } - } - else if( msg.sType == _T("itemselect") ) { - if( msg.pSender->GetName() == _T("accountcombo") ) { - CEditUI* pAccountEdit = static_cast(m_pm.FindControl(_T("accountedit"))); - if( pAccountEdit ) pAccountEdit->SetText(msg.pSender->GetText()); - } - } - } - - LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); - styleValue &= ~WS_CAPTION; - ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); - - m_pm.Init(m_hWnd); - m_pm.AddPreMessageFilter(this); - CDialogBuilder builder; - CDialogBuilderCallbackEx cb; - CControlUI* pRoot = builder.Create(_T("login.xml"), (UINT)0, &cb, &m_pm); - ASSERT(pRoot && "Failed to parse XML"); - m_pm.AttachDialog(pRoot); - m_pm.AddNotifier(this); - - Init(); - return 0; +#include "umu/apppath_t.h" + +CMiniDumper g_miniDumper(true); + +class CLoginFrameWnd : public CWindowWnd, + public INotifyUI, + public IMessageFilterUI { + public: + CLoginFrameWnd(){}; + LPCTSTR GetWindowClassName() const { return _T("UILoginFrame"); }; + UINT GetClassStyle() const { return UI_CLASSSTYLE_DIALOG; }; + void OnFinalMessage(HWND /*hWnd*/) { + m_pm.RemovePreMessageFilter(this); + delete this; + }; + + void Init() { + CComboUI* pAccountCombo = + static_cast(m_pm.FindControl(_T("accountcombo"))); + CEditUI* pAccountEdit = + static_cast(m_pm.FindControl(_T("accountedit"))); + if (pAccountCombo && pAccountEdit) + pAccountEdit->SetText(pAccountCombo->GetText()); + pAccountEdit->SetFocus(); + } + + void Notify(TNotifyUI& msg) { + if (msg.sType == _T("click")) { + if (msg.pSender->GetName() == _T("closebtn")) { + PostQuitMessage(0); + return; + } else if (msg.pSender->GetName() == _T("loginBtn")) { + Close(); + return; + } + } else if (msg.sType == _T("itemselect")) { + if (msg.pSender->GetName() == _T("accountcombo")) { + CEditUI* pAccountEdit = + static_cast(m_pm.FindControl(_T("accountedit"))); + if (pAccountEdit) + pAccountEdit->SetText(msg.pSender->GetText()); + } } + } + + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); + styleValue &= ~WS_CAPTION; + ::SetWindowLong(*this, GWL_STYLE, + styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); + + m_pm.Init(m_hWnd); + m_pm.AddPreMessageFilter(this); + CDialogBuilder builder; + CDialogBuilderCallbackEx cb; + CControlUI* pRoot = builder.Create(_T("login.xml"), (UINT)0, &cb, &m_pm); + ASSERT(pRoot && "Failed to parse XML"); + m_pm.AttachDialog(pRoot); + m_pm.AddNotifier(this); + + Init(); + 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 OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - if( ::IsIconic(*this) ) bHandled = FALSE; - return (wParam == 0) ? TRUE : FALSE; + 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); + + 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(m_pm.FindControl(pt)); + if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0) + return HTCAPTION; } - LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - return 0; + 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); } - LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - return 0; + bHandled = FALSE; + return 0; + } + + 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_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; + default: + bHandled = FALSE; } - - 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); - - 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(m_pm.FindControl(pt)); - if( pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 ) - return HTCAPTION; + if (bHandled) + return lRes; + if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes)) + return lRes; + return CWindowWnd::HandleMessage(uMsg, wParam, lParam); + } + + LRESULT MessageHandler(UINT uMsg, + WPARAM wParam, + LPARAM lParam, + bool& bHandled) { + if (uMsg == WM_KEYDOWN) { + if (wParam == VK_RETURN) { + CEditUI* pEdit = + static_cast(m_pm.FindControl(_T("accountedit"))); + if (pEdit->GetText().IsEmpty()) + pEdit->SetFocus(); + else { + pEdit = static_cast(m_pm.FindControl(_T("pwdedit"))); + if (pEdit->GetText().IsEmpty()) + pEdit->SetFocus(); + else + Close(); } - - return HTCLIENT; + return true; + } else if (wParam == VK_ESCAPE) { + PostQuitMessage(0); + return true; + } } + return false; + } - 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); - } + public: + CPaintManagerUI m_pm; +}; - bHandled = FALSE; - return 0; +class CGameFrameWnd : public CWindowWnd, + public INotifyUI, + public IListCallbackUI { + public: + CGameFrameWnd(){}; + LPCTSTR GetWindowClassName() const { return _T("UIMainFrame"); }; + UINT GetClassStyle() const { return CS_DBLCLKS; }; + void OnFinalMessage(HWND /*hWnd*/) { delete this; }; + + void Init() { + m_pCloseBtn = static_cast(m_pm.FindControl(_T("closebtn"))); + m_pMaxBtn = static_cast(m_pm.FindControl(_T("maxbtn"))); + m_pRestoreBtn = static_cast(m_pm.FindControl(_T("restorebtn"))); + m_pMinBtn = static_cast(m_pm.FindControl(_T("minbtn"))); + + CActiveXUI* pActiveXUI = + static_cast(m_pm.FindControl(_T("ie"))); + if (pActiveXUI) { + IWebBrowser2* pWebBrowser = NULL; + pActiveXUI->GetControl(IID_IWebBrowser2, (void**)&pWebBrowser); + if (pWebBrowser != NULL) { + pWebBrowser->Navigate(L"https://github.com/UMU618/duilib", NULL, NULL, + NULL, NULL); + // pWebBrowser->Navigate(L"about:blank",NULL,NULL,NULL,NULL); + pWebBrowser->Release(); + } } - - 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_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; - default: - bHandled = FALSE; + } + + void OnPrepare() { + GameListUI* pGameList = + static_cast(m_pm.FindControl(_T("gamelist"))); + GameListUI::Node* pCategoryNode = NULL; + GameListUI::Node* pGameNode = NULL; + GameListUI::Node* pServerNode = NULL; + GameListUI::Node* pRoomNode = NULL; + pCategoryNode = + pGameList->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}�Ƽ���Ϸ")); + for (int i = 0; i < 4; ++i) { + pGameNode = pGameList->AddNode( + _T("{x 4}{i gameicons.png 18 10}{x 4}���˶�����"), pCategoryNode); + for (int i = 0; i < 3; ++i) { + pServerNode = pGameList->AddNode( + _T("{x 4}{i gameicons.png 18 10}{x 4}���Է�����"), pGameNode); + for (int i = 0; i < 3; ++i) { + pRoomNode = pGameList->AddNode( + _T("{x 4}{i gameicons.png 18 10}{x 4}���Է���"), pServerNode); } - if( bHandled ) return lRes; - if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes; - return CWindowWnd::HandleMessage(uMsg, wParam, lParam); + } } - - LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled) - { - if( uMsg == WM_KEYDOWN ) { - if( wParam == VK_RETURN ) { - CEditUI* pEdit = static_cast(m_pm.FindControl(_T("accountedit"))); - if( pEdit->GetText().IsEmpty() ) pEdit->SetFocus(); - else { - pEdit = static_cast(m_pm.FindControl(_T("pwdedit"))); - if( pEdit->GetText().IsEmpty() ) pEdit->SetFocus(); - else Close(); - } - return true; - } - else if( wParam == VK_ESCAPE ) { - PostQuitMessage(0); - return true; - } - - } - return false; + pCategoryNode = pGameList->AddNode( + _T("{x 4}{i gameicons.png 18 3}{x 4}����������Ϸ")); + for (int i = 0; i < 2; ++i) { + pGameList->AddNode(_T("��ȱһ"), pCategoryNode); } - -public: - CPaintManagerUI m_pm; -}; - -class CGameFrameWnd : public CWindowWnd, public INotifyUI, public IListCallbackUI -{ -public: - CGameFrameWnd() { }; - LPCTSTR GetWindowClassName() const { return _T("UIMainFrame"); }; - UINT GetClassStyle() const { return CS_DBLCLKS; }; - void OnFinalMessage(HWND /*hWnd*/) { delete this; }; - - void Init() { - m_pCloseBtn = static_cast(m_pm.FindControl(_T("closebtn"))); - m_pMaxBtn = static_cast(m_pm.FindControl(_T("maxbtn"))); - m_pRestoreBtn = static_cast(m_pm.FindControl(_T("restorebtn"))); - m_pMinBtn = static_cast(m_pm.FindControl(_T("minbtn"))); - - CActiveXUI* pActiveXUI = static_cast(m_pm.FindControl(_T("ie"))); - if( pActiveXUI ) { - IWebBrowser2* pWebBrowser = NULL; - pActiveXUI->GetControl(IID_IWebBrowser2, (void**)&pWebBrowser); - if( pWebBrowser != NULL ) { - pWebBrowser->Navigate(L"https://github.com/duilib/duilib",NULL,NULL,NULL,NULL); - //pWebBrowser->Navigate(L"about:blank",NULL,NULL,NULL,NULL); - pWebBrowser->Release(); - } - } + pCategoryNode = + pGameList->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}������Ϸ")); + for (int i = 0; i < 8; ++i) { + pGameList->AddNode(_T("˫��"), pCategoryNode); } - - void OnPrepare() { - GameListUI* pGameList = static_cast(m_pm.FindControl(_T("gamelist"))); - GameListUI::Node* pCategoryNode = NULL; - GameListUI::Node* pGameNode = NULL; - GameListUI::Node* pServerNode = NULL; - GameListUI::Node* pRoomNode = NULL; - pCategoryNode = pGameList->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}�Ƽ���Ϸ")); - for( int i = 0; i < 4; ++i ) - { - pGameNode = pGameList->AddNode(_T("{x 4}{i gameicons.png 18 10}{x 4}���˶�����"), pCategoryNode); - for( int i = 0; i < 3; ++i ) - { - pServerNode = pGameList->AddNode(_T("{x 4}{i gameicons.png 18 10}{x 4}���Է�����"), pGameNode); - for( int i = 0; i < 3; ++i ) - { - pRoomNode = pGameList->AddNode(_T("{x 4}{i gameicons.png 18 10}{x 4}���Է���"), pServerNode); - } - } - } - pCategoryNode = pGameList->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}����������Ϸ")); - for( int i = 0; i < 2; ++i ) - { - pGameList->AddNode(_T("��ȱһ"), pCategoryNode); - } - pCategoryNode = pGameList->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}������Ϸ")); - for( int i = 0; i < 8; ++i ) - { - pGameList->AddNode(_T("˫��"), pCategoryNode); - } - pCategoryNode = pGameList->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}������Ϸ")); - for( int i = 0; i < 8; ++i ) - { - pGameList->AddNode(_T("������"), pCategoryNode); - } - - CListUI* pUserList = static_cast(m_pm.FindControl(_T("userlist"))); - pUserList->SetTextCallback(this); - for( int i = 0; i < 400; i++ ) { - CListTextElementUI* pListElement = new CListTextElementUI; - pUserList->Add(pListElement); - } - - CLoginFrameWnd* pLoginFrame = new CLoginFrameWnd(); - if( pLoginFrame == NULL ) { Close(); return; } - pLoginFrame->Create(m_hWnd, _T(""), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL); - pLoginFrame->SetIcon(IDI_ICON_DUILIB); - pLoginFrame->CenterWindow(); - pLoginFrame->ShowModal(); + pCategoryNode = + pGameList->AddNode(_T("{x 4}{i gameicons.png 18 3}{x 4}������Ϸ")); + for (int i = 0; i < 8; ++i) { + pGameList->AddNode(_T("������"), pCategoryNode); } - void SendChatMessage() { - CEditUI* pChatEdit = static_cast(m_pm.FindControl(_T("chatEdit"))); - if( pChatEdit == NULL ) return; - pChatEdit->SetFocus(); - if( pChatEdit->GetText().IsEmpty() ) return; - - CRichEditUI* pRichEdit = static_cast(m_pm.FindControl(_T("chatmsglist"))); - if( pRichEdit == NULL ) return; - long lSelBegin = 0, lSelEnd = 0; - CHARFORMAT2 cf; - ZeroMemory(&cf, sizeof(CHARFORMAT2)); - cf.cbSize = sizeof(cf); - cf.dwReserved = 0; - cf.dwMask = CFM_COLOR; - cf.crTextColor = RGB(220, 0, 0); - - lSelEnd = lSelBegin = pRichEdit->GetTextLength(); - pRichEdit->SetSel(lSelEnd, lSelEnd); - pRichEdit->ReplaceSel(_T("ij��"), false); - lSelEnd = pRichEdit->GetTextLength(); - pRichEdit->SetSel(lSelBegin, lSelEnd); - pRichEdit->SetSelectionCharFormat(cf); - - lSelBegin = lSelEnd; - pRichEdit->SetSel(-1, -1); - pRichEdit->ReplaceSel(_T("˵:"), false); - - pRichEdit->SetSel(-1, -1); - pRichEdit->ReplaceSel(pChatEdit->GetText(), false); - pChatEdit->SetText(_T("")); - - pRichEdit->SetSel(-1, -1); - pRichEdit->ReplaceSel(_T("\n"), false); - - cf.crTextColor = RGB(0, 0, 0); - lSelEnd = pRichEdit->GetTextLength(); - pRichEdit->SetSel(lSelBegin, lSelEnd); - pRichEdit->SetSelectionCharFormat(cf); - - pRichEdit->EndDown(); + CListUI* pUserList = + static_cast(m_pm.FindControl(_T("userlist"))); + pUserList->SetTextCallback(this); + for (int i = 0; i < 400; i++) { + CListTextElementUI* pListElement = new CListTextElementUI; + pUserList->Add(pListElement); } - void Notify(TNotifyUI& msg) - { - if( msg.sType == _T("windowinit") ) OnPrepare(); - else if( msg.sType == _T("click") ) { - if( msg.pSender == m_pCloseBtn ) { - COptionUI* pControl = static_cast(m_pm.FindControl(_T("hallswitch"))); - if( pControl && pControl->IsSelected() == false ) { - CControlUI* pFadeControl = m_pm.FindControl(_T("fadeEffect")); - if( pFadeControl ) pFadeControl->SetVisible(true); - } - else { - /*Close()*/PostQuitMessage(0); // ��Ϊactivex��ԭ��ʹ��close���ܻ���ִ��� - } - 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; } - CDuiString name = msg.pSender->GetName(); - if( name == _T("quitbtn") ) { - /*Close()*/PostQuitMessage(0); // ��Ϊactivex��ԭ��ʹ��close���ܻ���ִ��� - } - else if( name == _T("returnhallbtn") ) { - CControlUI* pFadeControl = m_pm.FindControl(_T("fadeEffect")); - if( pFadeControl ) pFadeControl->SetVisible(false); - - COptionUI* pControl = static_cast(m_pm.FindControl(_T("hallswitch"))); - pControl->Activate(); - pControl = static_cast(m_pm.FindControl(_T("roomswitch"))); - if( pControl ) pControl->SetVisible(false); - } - else if( name == _T("fontswitch") ) { - TFontInfo* pFontInfo = m_pm.GetDefaultFontInfo(); - if( pFontInfo->iSize < 18 ) { - TFontInfo* pFontInfo = m_pm.GetFontInfo(0); - if( pFontInfo )m_pm.SetDefaultFont(pFontInfo->sFontName, pFontInfo->iSize, pFontInfo->bBold, - pFontInfo->bUnderline, pFontInfo->bItalic); - } - else { - TFontInfo* pFontInfo = m_pm.GetFontInfo(1); - if( pFontInfo )m_pm.SetDefaultFont(pFontInfo->sFontName, pFontInfo->iSize, pFontInfo->bBold, - pFontInfo->bUnderline, pFontInfo->bItalic); - } - m_pm.GetRoot()->NeedUpdate(); - } - else if( name == _T("leaveBtn") || name == _T("roomclosebtn") ) { - COptionUI* pControl = static_cast(m_pm.FindControl(_T("hallswitch"))); - if( pControl ) { - pControl->Activate(); - pControl = static_cast(m_pm.FindControl(_T("roomswitch"))); - if( pControl ) pControl->SetVisible(false); - } - } - else if( name == _T("sendbtn") ) { - SendChatMessage(); - } + CLoginFrameWnd* pLoginFrame = new CLoginFrameWnd(); + if (pLoginFrame == NULL) { + Close(); + return; + } + pLoginFrame->Create(m_hWnd, _T(""), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, + NULL); + pLoginFrame->SetIcon(IDI_ICON_DUILIB); + pLoginFrame->CenterWindow(); + pLoginFrame->ShowModal(); + } + + void SendChatMessage() { + CEditUI* pChatEdit = + static_cast(m_pm.FindControl(_T("chatEdit"))); + if (pChatEdit == NULL) + return; + pChatEdit->SetFocus(); + if (pChatEdit->GetText().IsEmpty()) + return; + + CRichEditUI* pRichEdit = + static_cast(m_pm.FindControl(_T("chatmsglist"))); + if (pRichEdit == NULL) + return; + long lSelBegin = 0, lSelEnd = 0; + CHARFORMAT2 cf; + ZeroMemory(&cf, sizeof(CHARFORMAT2)); + cf.cbSize = sizeof(cf); + cf.dwReserved = 0; + cf.dwMask = CFM_COLOR; + cf.crTextColor = RGB(220, 0, 0); + + lSelEnd = lSelBegin = pRichEdit->GetTextLength(); + pRichEdit->SetSel(lSelEnd, lSelEnd); + pRichEdit->ReplaceSel(_T("ij��"), false); + lSelEnd = pRichEdit->GetTextLength(); + pRichEdit->SetSel(lSelBegin, lSelEnd); + pRichEdit->SetSelectionCharFormat(cf); + + lSelBegin = lSelEnd; + pRichEdit->SetSel(-1, -1); + pRichEdit->ReplaceSel(_T("˵:"), false); + + pRichEdit->SetSel(-1, -1); + pRichEdit->ReplaceSel(pChatEdit->GetText(), false); + pChatEdit->SetText(_T("")); + + pRichEdit->SetSel(-1, -1); + pRichEdit->ReplaceSel(_T("\n"), false); + + cf.crTextColor = RGB(0, 0, 0); + lSelEnd = pRichEdit->GetTextLength(); + pRichEdit->SetSel(lSelBegin, lSelEnd); + pRichEdit->SetSelectionCharFormat(cf); + + pRichEdit->EndDown(); + } + + void Notify(TNotifyUI& msg) { + if (msg.sType == _T("windowinit")) + OnPrepare(); + else if (msg.sType == _T("click")) { + if (msg.pSender == m_pCloseBtn) { + COptionUI* pControl = + static_cast(m_pm.FindControl(_T("hallswitch"))); + if (pControl && pControl->IsSelected() == false) { + CControlUI* pFadeControl = m_pm.FindControl(_T("fadeEffect")); + if (pFadeControl) + pFadeControl->SetVisible(true); + } else { + /*Close()*/ PostQuitMessage( + 0); // ��Ϊactivex��ԭ��ʹ��close���ܻ���ִ��� } - else if( msg.sType == _T("selectchanged") ) { - CDuiString name = msg.pSender->GetName(); - if( name == _T("hallswitch") ) { - CTabLayoutUI* pControl = static_cast(m_pm.FindControl(_T("switch"))); - if( pControl && pControl->GetCurSel() != 0 ) pControl->SelectItem(0); - } - else if( name == _T("roomswitch") ) { - CTabLayoutUI* pControl = static_cast(m_pm.FindControl(_T("switch"))); - if( pControl && pControl->GetCurSel() != 1 ) { - pControl->SelectItem(1); - DeskListUI* pDeskList = static_cast(m_pm.FindControl(_T("destlist"))); - pDeskList->SetFocus(); - CRichEditUI* pRichEdit = static_cast(m_pm.FindControl(_T("chatmsglist"))); - if( pRichEdit ) { - pRichEdit->SetText(_T("��ӭ����XXX��Ϸ��ף��Ϸ��죡\n\n")); - long lSelBegin = 0, lSelEnd = 0; - CHARFORMAT2 cf; - ZeroMemory(&cf, sizeof(CHARFORMAT2)); - cf.cbSize = sizeof(cf); - cf.dwReserved = 0; - cf.dwMask = CFM_COLOR; - cf.crTextColor = RGB(255, 0, 0); - lSelEnd = pRichEdit->GetTextLength(); - pRichEdit->SetSel(lSelBegin, lSelEnd); - pRichEdit->SetSelectionCharFormat(cf); - } - } - } + 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; + } + CDuiString name = msg.pSender->GetName(); + if (name == _T("quitbtn")) { + /*Close()*/ PostQuitMessage( + 0); // ��Ϊactivex��ԭ��ʹ��close���ܻ���ִ��� + } else if (name == _T("returnhallbtn")) { + CControlUI* pFadeControl = m_pm.FindControl(_T("fadeEffect")); + if (pFadeControl) + pFadeControl->SetVisible(false); + + COptionUI* pControl = + static_cast(m_pm.FindControl(_T("hallswitch"))); + pControl->Activate(); + pControl = static_cast(m_pm.FindControl(_T("roomswitch"))); + if (pControl) + pControl->SetVisible(false); + } else if (name == _T("fontswitch")) { + TFontInfo* pFontInfo = m_pm.GetDefaultFontInfo(); + if (pFontInfo->iSize < 18) { + TFontInfo* pFontInfo = m_pm.GetFontInfo(0); + if (pFontInfo) + m_pm.SetDefaultFont(pFontInfo->sFontName, pFontInfo->iSize, + pFontInfo->bBold, pFontInfo->bUnderline, + pFontInfo->bItalic); + } else { + TFontInfo* pFontInfo = m_pm.GetFontInfo(1); + if (pFontInfo) + m_pm.SetDefaultFont(pFontInfo->sFontName, pFontInfo->iSize, + pFontInfo->bBold, pFontInfo->bUnderline, + pFontInfo->bItalic); } - else if( msg.sType == _T("itemclick") ) { - GameListUI* pGameList = static_cast(m_pm.FindControl(_T("gamelist"))); - if( pGameList->GetItemIndex(msg.pSender) != -1 ) - { - if( _tcscmp(msg.pSender->GetClass(), DUI_CTR_LISTLABELELEMENT) == 0 ) { - GameListUI::Node* node = (GameListUI::Node*)msg.pSender->GetTag(); - - POINT pt = { 0 }; - ::GetCursorPos(&pt); - ::ScreenToClient(m_pm.GetPaintWindow(), &pt); - pt.x -= msg.pSender->GetX(); - SIZE sz = pGameList->GetExpanderSizeX(node); - if( pt.x >= sz.cx && pt.x < sz.cy ) - pGameList->ExpandNode(node, !node->data()._expand); - } - } + m_pm.GetRoot()->NeedUpdate(); + } else if (name == _T("leaveBtn") || name == _T("roomclosebtn")) { + COptionUI* pControl = + static_cast(m_pm.FindControl(_T("hallswitch"))); + if (pControl) { + pControl->Activate(); + pControl = + static_cast(m_pm.FindControl(_T("roomswitch"))); + if (pControl) + pControl->SetVisible(false); } - else if( msg.sType == _T("itemactivate") ) { - GameListUI* pGameList = static_cast(m_pm.FindControl(_T("gamelist"))); - if( pGameList->GetItemIndex(msg.pSender) != -1 ) - { - if( _tcscmp(msg.pSender->GetClass(), DUI_CTR_LISTLABELELEMENT) == 0 ) { - GameListUI::Node* node = (GameListUI::Node*)msg.pSender->GetTag(); - pGameList->ExpandNode(node, !node->data()._expand); - if( node->data()._level == 3 ) { - COptionUI* pControl = static_cast(m_pm.FindControl(_T("roomswitch"))); - if( pControl ) { - pControl->SetVisible(true); - pControl->SetText(node->parent()->parent()->data()._text); - pControl->Activate(); - - } - } - } - } + } else if (name == _T("sendbtn")) { + SendChatMessage(); + } + } else if (msg.sType == _T("selectchanged")) { + CDuiString name = msg.pSender->GetName(); + if (name == _T("hallswitch")) { + CTabLayoutUI* pControl = + static_cast(m_pm.FindControl(_T("switch"))); + if (pControl && pControl->GetCurSel() != 0) + pControl->SelectItem(0); + } else if (name == _T("roomswitch")) { + CTabLayoutUI* pControl = + static_cast(m_pm.FindControl(_T("switch"))); + if (pControl && pControl->GetCurSel() != 1) { + pControl->SelectItem(1); + DeskListUI* pDeskList = + static_cast(m_pm.FindControl(_T("destlist"))); + pDeskList->SetFocus(); + CRichEditUI* pRichEdit = + static_cast(m_pm.FindControl(_T("chatmsglist"))); + if (pRichEdit) { + pRichEdit->SetText(_T("��ӭ����XXX��Ϸ��ף��Ϸ��죡\n\n")); + long lSelBegin = 0, lSelEnd = 0; + CHARFORMAT2 cf; + ZeroMemory(&cf, sizeof(CHARFORMAT2)); + cf.cbSize = sizeof(cf); + cf.dwReserved = 0; + cf.dwMask = CFM_COLOR; + cf.crTextColor = RGB(255, 0, 0); + lSelEnd = pRichEdit->GetTextLength(); + pRichEdit->SetSel(lSelBegin, lSelEnd); + pRichEdit->SetSelectionCharFormat(cf); + } } - else if( msg.sType == _T("itemselect") ) { - if( msg.pSender->GetName() == _T("chatCombo") ) { - CEditUI* pChatEdit = static_cast(m_pm.FindControl(_T("chatEdit"))); - if( pChatEdit ) pChatEdit->SetText(msg.pSender->GetText()); - static_cast(msg.pSender)->SelectItem(-1); - } + } + } else if (msg.sType == _T("itemclick")) { + GameListUI* pGameList = + static_cast(m_pm.FindControl(_T("gamelist"))); + if (pGameList->GetItemIndex(msg.pSender) != -1) { + if (_tcscmp(msg.pSender->GetClass(), DUI_CTR_LISTLABELELEMENT) == 0) { + GameListUI::Node* node = (GameListUI::Node*)msg.pSender->GetTag(); + + POINT pt = {0}; + ::GetCursorPos(&pt); + ::ScreenToClient(m_pm.GetPaintWindow(), &pt); + pt.x -= msg.pSender->GetX(); + SIZE sz = pGameList->GetExpanderSizeX(node); + if (pt.x >= sz.cx && pt.x < sz.cy) + pGameList->ExpandNode(node, !node->data()._expand); } - else if( msg.sType == _T("return") ) { - if( msg.pSender->GetName() == _T("chatEdit") ) { - SendChatMessage(); + } + } else if (msg.sType == _T("itemactivate")) { + GameListUI* pGameList = + static_cast(m_pm.FindControl(_T("gamelist"))); + if (pGameList->GetItemIndex(msg.pSender) != -1) { + if (_tcscmp(msg.pSender->GetClass(), DUI_CTR_LISTLABELELEMENT) == 0) { + GameListUI::Node* node = (GameListUI::Node*)msg.pSender->GetTag(); + pGameList->ExpandNode(node, !node->data()._expand); + if (node->data()._level == 3) { + COptionUI* pControl = + static_cast(m_pm.FindControl(_T("roomswitch"))); + if (pControl) { + pControl->SetVisible(true); + pControl->SetText(node->parent()->parent()->data()._text); + pControl->Activate(); } + } } + } + } else if (msg.sType == _T("itemselect")) { + if (msg.pSender->GetName() == _T("chatCombo")) { + CEditUI* pChatEdit = + static_cast(m_pm.FindControl(_T("chatEdit"))); + if (pChatEdit) + pChatEdit->SetText(msg.pSender->GetText()); + static_cast(msg.pSender)->SelectItem(-1); + } + } else if (msg.sType == _T("return")) { + if (msg.pSender->GetName() == _T("chatEdit")) { + SendChatMessage(); + } } - - LPCTSTR GetItemText(CControlUI* pControl, int iIndex, int iSubItem) - { - if( pControl->GetParent()->GetParent()->GetName() == _T("userlist") ) { - if( iSubItem == 0 ) return _T(""); - if( iSubItem == 1 ) return _T(""); - if( iSubItem == 2 ) return _T("�����dz�"); - if( iSubItem == 3 ) return _T("5"); - if( iSubItem == 4 ) return _T("50%"); - if( iSubItem == 5 ) return _T("0%"); - if( iSubItem == 6 ) return _T("100"); - } - - return _T(""); + } + + LPCTSTR GetItemText(CControlUI* pControl, int iIndex, int iSubItem) { + if (pControl->GetParent()->GetParent()->GetName() == _T("userlist")) { + if (iSubItem == 0) + return _T(""); + if (iSubItem == 1) + return _T(""); + if (iSubItem == 2) + return _T("�����dz�"); + if (iSubItem == 3) + return _T("5"); + if (iSubItem == 4) + return _T("50%"); + if (iSubItem == 5) + return _T("0%"); + if (iSubItem == 6) + return _T("100"); } - LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - 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("hall.xml"), (UINT)0, &cb, &m_pm); - ASSERT(pRoot && "Failed to parse XML"); - m_pm.AttachDialog(pRoot); - m_pm.AddNotifier(this); - - Init(); - return 0; - } + return _T(""); + } - LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - bHandled = FALSE; - return 0; - } + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); + styleValue &= ~WS_CAPTION; + ::SetWindowLong(*this, GWL_STYLE, + styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); - LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - ::PostQuitMessage(0L); + m_pm.Init(m_hWnd); + CDialogBuilder builder; + CDialogBuilderCallbackEx cb; + CControlUI* pRoot = builder.Create(_T("hall.xml"), (UINT)0, &cb, &m_pm); + ASSERT(pRoot && "Failed to parse XML"); + m_pm.AttachDialog(pRoot); + m_pm.AddNotifier(this); - 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); + Init(); + return 0; + } - RECT rcClient; - ::GetClientRect(*this, &rcClient); + LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + bHandled = FALSE; + return 0; + } - 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; - } + LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + ::PostQuitMessage(0L); - 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(m_pm.FindControl(pt)); - if( pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 && - _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 && - _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 0 ) - return HTCAPTION; - } + 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; + } - return HTCLIENT; + 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; } - 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; + 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(m_pm.FindControl(pt)); + if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 && + _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 && + _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 0) + return HTCAPTION; } - LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - int primaryMonitorWidth = ::GetSystemMetrics(SM_CXSCREEN); - int primaryMonitorHeight = ::GetSystemMetrics(SM_CYSCREEN); - MONITORINFO oMonitor = {}; - oMonitor.cbSize = sizeof(oMonitor); - ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor); - CDuiRect rcWork = oMonitor.rcWork; - rcWork.Offset(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.top); - if (rcWork.right > primaryMonitorWidth) rcWork.right = primaryMonitorWidth; - if (rcWork.bottom > primaryMonitorHeight) rcWork.right = primaryMonitorHeight; - 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; + 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); } - 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(m_pm.FindControl(_T("maxbtn"))); - if( pControl ) pControl->SetVisible(false); - pControl = static_cast(m_pm.FindControl(_T("restorebtn"))); - if( pControl ) pControl->SetVisible(true); - } - else { - CControlUI* pControl = static_cast(m_pm.FindControl(_T("maxbtn"))); - if( pControl ) pControl->SetVisible(true); - pControl = static_cast(m_pm.FindControl(_T("restorebtn"))); - if( pControl ) pControl->SetVisible(false); - } - } - return lRes; + bHandled = FALSE; + return 0; + } + + LRESULT OnGetMinMaxInfo(UINT uMsg, + WPARAM wParam, + LPARAM lParam, + BOOL& bHandled) { + int primaryMonitorWidth = ::GetSystemMetrics(SM_CXSCREEN); + int primaryMonitorHeight = ::GetSystemMetrics(SM_CYSCREEN); + MONITORINFO oMonitor = {}; + oMonitor.cbSize = sizeof(oMonitor); + ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), + &oMonitor); + CDuiRect rcWork = oMonitor.rcWork; + rcWork.Offset(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.top); + if (rcWork.right > primaryMonitorWidth) + rcWork.right = primaryMonitorWidth; + if (rcWork.bottom > primaryMonitorHeight) + rcWork.right = primaryMonitorHeight; + 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; } - - 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); + BOOL bZoomed = ::IsZoomed(*this); + LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam); + if (::IsZoomed(*this) != bZoomed) { + if (!bZoomed) { + CControlUI* pControl = + static_cast(m_pm.FindControl(_T("maxbtn"))); + if (pControl) + pControl->SetVisible(false); + pControl = static_cast(m_pm.FindControl(_T("restorebtn"))); + if (pControl) + pControl->SetVisible(true); + } else { + CControlUI* pControl = + static_cast(m_pm.FindControl(_T("maxbtn"))); + if (pControl) + pControl->SetVisible(true); + pControl = static_cast(m_pm.FindControl(_T("restorebtn"))); + if (pControl) + pControl->SetVisible(false); + } } - -public: - CPaintManagerUI m_pm; - -private: - CButtonUI* m_pCloseBtn; - CButtonUI* m_pMaxBtn; - CButtonUI* m_pRestoreBtn; - CButtonUI* m_pMinBtn; - //... + 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; + //... }; - -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow) -{ - CPaintManagerUI::SetInstance(hInstance); +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE /*hPrevInstance*/, + LPSTR /*lpCmdLine*/, + int nCmdShow) { + CPaintManagerUI::SetInstance(hInstance); #if 0 - CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin")); - CPaintManagerUI::SetResourceZip(_T("GameRes.zip")); + CPaintManagerUI::SetResourcePath(umu::apppath::GetProductDirectory() + + _T("_skin")); + CPaintManagerUI::SetResourceZip(_T("GameRes.zip")); #else - CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin/GameRes")); + CPaintManagerUI::SetResourcePath(umu::apppath::GetProductDirectory() + + _T("_skin\\GameRes")); #endif - HRESULT Hr = ::CoInitialize(NULL); - if( FAILED(Hr) ) return 0; + HRESULT Hr = ::CoInitialize(NULL); + if (FAILED(Hr)) + return 0; - CGameFrameWnd* pFrame = new CGameFrameWnd(); - if( pFrame == NULL ) return 0; - pFrame->SetIcon(IDI_ICON_DUILIB); - pFrame->Create(NULL, _T("��Ϸ����"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 1024, 738); - pFrame->CenterWindow(); - ::ShowWindow(*pFrame, SW_SHOWMAXIMIZED); + CGameFrameWnd* pFrame = new CGameFrameWnd(); + if (pFrame == NULL) + return 0; + pFrame->SetIcon(IDI_ICON_DUILIB); + pFrame->Create(NULL, _T("��Ϸ����"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 1024, 738); + pFrame->CenterWindow(); + ::ShowWindow(*pFrame, SW_SHOWMAXIMIZED); - CPaintManagerUI::MessageLoop(); + CPaintManagerUI::MessageLoop(); - ::CoUninitialize(); - return 0; + ::CoUninitialize(); + return 0; } diff --git a/GameDemo/GameDemo.sln b/GameDemo/GameDemo.sln deleted file mode 100644 index 2dcb0081..00000000 --- a/GameDemo/GameDemo.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameDemo", "GameDemo.vcproj", "{21B017E7-7805-40D5-9D96-AABF572F57D1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - UnicodeDebug|Win32 = UnicodeDebug|Win32 - UnicodeRelease|Win32 = UnicodeRelease|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {21B017E7-7805-40D5-9D96-AABF572F57D1}.Debug|Win32.ActiveCfg = Debug|Win32 - {21B017E7-7805-40D5-9D96-AABF572F57D1}.Debug|Win32.Build.0 = Debug|Win32 - {21B017E7-7805-40D5-9D96-AABF572F57D1}.Release|Win32.ActiveCfg = Release|Win32 - {21B017E7-7805-40D5-9D96-AABF572F57D1}.Release|Win32.Build.0 = Release|Win32 - {21B017E7-7805-40D5-9D96-AABF572F57D1}.UnicodeDebug|Win32.ActiveCfg = UnicodeDebug|Win32 - {21B017E7-7805-40D5-9D96-AABF572F57D1}.UnicodeDebug|Win32.Build.0 = UnicodeDebug|Win32 - {21B017E7-7805-40D5-9D96-AABF572F57D1}.UnicodeRelease|Win32.ActiveCfg = UnicodeRelease|Win32 - {21B017E7-7805-40D5-9D96-AABF572F57D1}.UnicodeRelease|Win32.Build.0 = UnicodeRelease|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/GameDemo/GameDemo.vcproj b/GameDemo/GameDemo.vcproj deleted file mode 100644 index 2616cf78..00000000 --- a/GameDemo/GameDemo.vcproj +++ /dev/null @@ -1,554 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/GameDemo/GameDemo.vcxproj b/GameDemo/GameDemo.vcxproj index 4fc55c46..c1c1da41 100644 --- a/GameDemo/GameDemo.vcxproj +++ b/GameDemo/GameDemo.vcxproj @@ -1,59 +1,104 @@  - + - + Debug + x64 + + + MbcsDebug Win32 - - Release + + MbcsDebug + x64 + + + MbcsRelease Win32 - - UnicodeDebug + + Debug Win32 - - UnicodeRelease + + MbcsRelease + x64 + + + Release Win32 + + Release + x64 + {21B017E7-7805-40D5-9D96-AABF572F57D1} + 10.0.17134.0 - + Application - v120 + v141 false Unicode + true - + Application - v120 + v141 false Unicode + true Application - v120 + v141 + false + Unicode + + + Application + v141 + false + Unicode + + + Application + v141 false MultiByte - + + Application + v141 + false + MultiByte + + Application - v120 + v141 false MultiByte + true + + + Application + v141 + false + MultiByte + true - + - + @@ -61,7 +106,23 @@ - + + + + + + + + + + + + + + + + + @@ -69,27 +130,39 @@ <_ProjectFileVersion>12.0.30501.0 - - $(SolutionDir)\bin\ - .\Release\ + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + + false + + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + false - $(SolutionDir)\bin\ - .\Debug\ false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - - $(SolutionDir)\bin\ - .\Debug_u\ + false - - $(SolutionDir)\bin\ - .\Release_u\ + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - + + false + + NDEBUG;%(PreprocessorDefinitions) true @@ -103,36 +176,60 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Use stdafx.h - .\Release/GameDemo.pch - .\Release/ - .\Release/ - .\Release/ Level3 true + ..\;..\include\; + true NDEBUG;%(PreprocessorDefinitions) - 0x0406 + 0x0409 - ../bin/GameDemo.exe true - .\Release/GameDemo.pdb Windows MachineX86 - duilib.lib;%(AdditionalDependencies) - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/GameDemo.tlb + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + Use + stdafx.h + Level3 true - .\Release/GameDemo.bsc - + ..\;..\include\; + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + + - + _DEBUG;%(PreprocessorDefinitions) true @@ -146,40 +243,59 @@ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug + MultiThreadedDebugDLL Use stdafx.h - .\Debug/GameDemo.pch - .\Debug/ - .\Debug/ - .\Debug/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) - 0x0406 + 0x0409 - ../bin/GameDemo_d.exe true true - .\Debug/GameDemo.pdb - true - .\Debug/GameDemo.map Windows MachineX86 - duilib_d.lib;%(AdditionalDependencies) - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true true - .\Debug/GameDemo.bsc - + .\Debug/GameDemo.tlb + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + true + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + true + Windows + + - + _DEBUG;%(PreprocessorDefinitions) true @@ -193,40 +309,59 @@ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug + MultiThreadedDebugDLL Use stdafx.h - .\Debug_u/GameDemo.pch - .\Debug_u/ - .\Debug_u/ - .\Debug_u/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) - 0x0406 + 0x0409 - ../bin/GameDemo_ud.exe true true - .\Debug_u/GameDemo.pdb - true - .\Debug_u/GameDemo.map Windows MachineX86 - duilib_ud.lib;%(AdditionalDependencies) - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/GameDemo.tlb + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 true - .\Debug/GameDemo.bsc - + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + true + Windows + + - + NDEBUG;%(PreprocessorDefinitions) true @@ -240,52 +375,88 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Use stdafx.h - .\Release_u/GameDemo.pch - .\Release_u/ - .\Release_u/ - .\Release_u/ Level3 true + ..\;..\include\; + true NDEBUG;%(PreprocessorDefinitions) - 0x0406 + 0x0409 - ../bin/GameDemo_u.exe true - .\Release_u/GameDemo.pdb Windows MachineX86 - duilib_u.lib;%(AdditionalDependencies) - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/GameDemo.tlb + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + Use + stdafx.h + Level3 + true + ..\;..\include\; + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + true - .\Release/GameDemo.bsc - + Windows + + + + + + + + + + - + - + - + + Create + Create + Create + Create Create + Create Create - Create - Create + Create @@ -299,7 +470,11 @@ - + + + + {e106acd7-4e53-4aee-942b-d0dd426db34e} + diff --git a/GameDemo/GameDemo.vcxproj.filters b/GameDemo/GameDemo.vcxproj.filters index 78ee5d39..801370ea 100644 --- a/GameDemo/GameDemo.vcxproj.filters +++ b/GameDemo/GameDemo.vcxproj.filters @@ -45,6 +45,5 @@ - \ No newline at end of file diff --git a/GameDemo/StdAfx.h b/GameDemo/StdAfx.h index 3acd2570..47fa26bf 100644 --- a/GameDemo/StdAfx.h +++ b/GameDemo/StdAfx.h @@ -1,27 +1,27 @@ - #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ #pragma once -#define WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN #define _CRT_SECURE_NO_DEPRECATE // Required for VS 2008 (fails on XP and Win2000 without this fix) #ifndef _WIN32_WINNT - #define _WIN32_WINNT 0x0500 +#define _WIN32_WINNT 0x0500 #endif -#include -#include +#include +#include -#include "..\DuiLib\UIlib.h" +#include "DuiLib/UIlib.h" using namespace DuiLib; #include "resource.h" //{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. +// Microsoft Visual C++ will insert additional declarations immediately before +// the previous line. -#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) +#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) diff --git a/ListDemo/CMakeLists.txt b/ListDemo/CMakeLists.txt deleted file mode 100644 index 1e41906b..00000000 --- a/ListDemo/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -#Cmake file for ListDemo -#Author: Qi Gao(monkgau@gmail.com) -#Created: 2012/9/17 - -set(source_files Main.cpp) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -add_executable(ListDemo ${source_files}) -add_dependencies(ListDemo duilib) -target_link_libraries(ListDemo duilib) -set_target_properties(ListDemo PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") - -add_custom_command(TARGET ListDemo POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${PROJECT_BINARY_DIR}/bin/ListDemo.exe ${PROJECT_SOURCE_DIR}/bin/ListDemo.exe) diff --git a/ListDemo/ListDemo.vcproj b/ListDemo/ListDemo.vcproj deleted file mode 100644 index 6725de17..00000000 --- a/ListDemo/ListDemo.vcproj +++ /dev/null @@ -1,449 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ListDemo/ListDemo.vcxproj b/ListDemo/ListDemo.vcxproj index 693f2685..b08a1b2a 100644 --- a/ListDemo/ListDemo.vcxproj +++ b/ListDemo/ListDemo.vcxproj @@ -1,59 +1,104 @@  - + - + Debug + x64 + + + MbcsDebug Win32 - - Release + + MbcsDebug + x64 + + + MbcsRelease Win32 - - UnicodeDebug + + Debug Win32 - - UnicodeRelease + + MbcsRelease + x64 + + + Release Win32 + + Release + x64 + {223017E7-7805-40D5-9D96-AABF572F57D1} + 10.0.17134.0 - + Application - v120 + v141 false Unicode + true - + Application - v120 + v141 false Unicode + true Application - v120 + v141 + false + Unicode + + + Application + v141 + false + Unicode + + + Application + v141 false MultiByte - + Application - v120 + v141 false MultiByte + + Application + v141 + false + MultiByte + true + + + Application + v141 + false + MultiByte + true + - + - + @@ -61,7 +106,23 @@ - + + + + + + + + + + + + + + + + + @@ -69,27 +130,39 @@ <_ProjectFileVersion>12.0.30501.0 - - $(SolutionDir)\bin\ - .\Release\ + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + + false + + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + false - $(SolutionDir)\bin\ - .\Debug\ false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - - $(SolutionDir)\bin\ - .\Debug_u\ + false - - $(SolutionDir)\bin\ - .\Release_u\ + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - + + false + + NDEBUG;%(PreprocessorDefinitions) true @@ -103,36 +176,58 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Use stdafx.h - .\Release/ListDemo.pch - .\Release/ - .\Release/ - .\Release/ Level3 true + ..\;..\include\; NDEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/ListDemo.exe true - .\Release/ListDemo.pdb Windows MachineX86 - duilib.lib;%(AdditionalDependencies) - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true true - .\Release/ListDemo.bsc - + .\Release/ListDemo.tlb + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + Use + stdafx.h + Level3 + true + ..\;..\include\; + + + NDEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + Windows + + - + _DEBUG;%(PreprocessorDefinitions) true @@ -146,40 +241,59 @@ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug + MultiThreadedDebugDLL Use stdafx.h - .\Debug/ListDemo.pch - .\Debug/ - .\Debug/ - .\Debug/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/ListDemo_d.exe true true - .\Debug/ListDemo.pdb - true - .\Debug/ListDemo.map Windows MachineX86 - duilib_d.lib;%(AdditionalDependencies) - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/ListDemo.tlb + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + true + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0406 + + true - .\Debug/ListDemo.bsc - + true + Windows + + - + _DEBUG;%(PreprocessorDefinitions) true @@ -193,40 +307,59 @@ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug + MultiThreadedDebugDLL Use stdafx.h - .\Debug_u/ListDemo.pch - .\Debug_u/ - .\Debug_u/ - .\Debug_u/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/ListDemo_ud.exe true true - .\Debug_u/ListDemo.pdb - true - .\Debug_u/ListDemo.map Windows MachineX86 - duilib_ud.lib;%(AdditionalDependencies) - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/ListDemo.tlb + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 true - .\Debug/ListDemo.bsc - + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + true + Windows + + - + NDEBUG;%(PreprocessorDefinitions) true @@ -240,58 +373,101 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true Use stdafx.h - .\Release_u/ListDemo.pch - .\Release_u/ - .\Release_u/ - .\Release_u/ Level3 true + ..\;..\include\; NDEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/ListDemo_u.exe true - .\Release_u/ListDemo.pdb Windows MachineX86 - duilib_u.lib;%(AdditionalDependencies) - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/ListDemo.tlb + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + Use + stdafx.h + Level3 true - .\Release/ListDemo.bsc - + ..\;..\include\; + + + NDEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + Windows + + + + + + + + + + + + + + + + + + + + + + - - - + - + - - - + + + + {e106acd7-4e53-4aee-942b-d0dd426db34e} + + diff --git a/ListDemo/Main.cpp b/ListDemo/Main.cpp index b0467362..9fecb5dd 100644 --- a/ListDemo/Main.cpp +++ b/ListDemo/Main.cpp @@ -1,460 +1,480 @@ /* -* Code By Tojen (qq:342269237) -* �������ͼƬ��Դ80%ԭ����������ȫԭ��,ѧϰ��Ʒ����������ש -*/ -#include -#include -#include -#include -#include + * Code By Tojen (qq:342269237) + * �������ͼƬ��Դ80%ԭ����������ȫԭ��,ѧϰ��Ʒ����������ש + */ +#include +#include + #include +#include -#include "..\DuiLib\UIlib.h" +#include "umu/apppath_t.h" +#include "DuiLib/UIlib.h" using namespace DuiLib; #define WM_ADDLISTITEM WM_USER + 50 /* -* ��ŵڶ������� -*/ + * ��ŵڶ������� + */ std::vector domain; /* -* ��ŵ��������� -*/ + * ��ŵ��������� + */ std::vector desc; /* -* �̺߳����д���Ľṹ�������ʹ���߳�Ϊ��ʹ�����߳��������أ���ֹ��ס�����Ƕ��á� -*/ -struct Prama -{ - HWND hWnd; - CListUI* pList; - CButtonUI* pSearch; - CDuiString tDomain; + * �̺߳����д���Ľṹ�������ʹ���߳�Ϊ��ʹ�����߳��������أ���ֹ��ס�����Ƕ��á� + */ +struct Prama { + HWND hWnd; + CListUI* pList; + CButtonUI* pSearch; + CDuiString tDomain; }; #include "MenuWnd.h" -class ListMainForm : public CWindowWnd, public INotifyUI, public IListCallbackUI -{ -public: - ListMainForm() { - }; - - LPCTSTR GetWindowClassName() const - { - return _T("ScanMainForm"); - }; - - UINT GetClassStyle() const - { - return CS_DBLCLKS; - }; - - void OnFinalMessage(HWND /*hWnd*/) - { - delete this; - }; - - void Init() - { - m_pCloseBtn = static_cast(m_pm.FindControl(_T("closebtn"))); - m_pMaxBtn = static_cast(m_pm.FindControl(_T("maxbtn"))); - m_pRestoreBtn = static_cast(m_pm.FindControl(_T("restorebtn"))); - m_pMinBtn = static_cast(m_pm.FindControl(_T("minbtn"))); - m_pSearch = static_cast(m_pm.FindControl(_T("btn"))); - } - - void OnPrepare(TNotifyUI& msg) - { - - } - static DWORD WINAPI Search(LPVOID lpParameter) - { - try - { - struct Prama* prama = (struct Prama *)lpParameter; - CListUI* pList = prama->pList; - CButtonUI* pSearch = prama->pSearch; - CDuiString tDomain = prama->tDomain; - //------------------------------------- - /* - * ��������ѭ�� - */ - for(int i=0; i<100; i++) - { - std::stringstream ss; - ss << "www." << i << ".com"; - domain.push_back(ss.str()); - ss.clear(); - ss << "it's " << i; - desc.push_back(ss.str()); - CListTextElementUI* pListElement = new CListTextElementUI; - pListElement->SetTag(i); - if (pListElement != NULL) - { - ::PostMessage(prama->hWnd, WM_ADDLISTITEM, 0L, (LPARAM)pListElement); - } - /* - * Sleep Ϊ��չʾ���ӵĶ�̬Ч�����ʷ����������ٶȣ�ͬʱ���Կ������ӹ����н�����Ȼ������Ӧ - */ - ::Sleep(100); - } - //------------------------------------------ - delete prama; - - pSearch->SetEnabled(true); - return 0; +class ListMainForm : public CWindowWnd, + public INotifyUI, + public IListCallbackUI { + public: + ListMainForm(){}; + + LPCTSTR GetWindowClassName() const { return _T("ScanMainForm"); }; + + UINT GetClassStyle() const { return CS_DBLCLKS; }; + + void OnFinalMessage(HWND /*hWnd*/) { delete this; }; + + void Init() { + m_pCloseBtn = static_cast(m_pm.FindControl(_T("closebtn"))); + m_pMaxBtn = static_cast(m_pm.FindControl(_T("maxbtn"))); + m_pRestoreBtn = static_cast(m_pm.FindControl(_T("restorebtn"))); + m_pMinBtn = static_cast(m_pm.FindControl(_T("minbtn"))); + m_pSearch = static_cast(m_pm.FindControl(_T("btn"))); + } + + void OnPrepare(TNotifyUI& msg) {} + static DWORD WINAPI Search(LPVOID lpParameter) { + try { + struct Prama* prama = (struct Prama*)lpParameter; + CListUI* pList = prama->pList; + CButtonUI* pSearch = prama->pSearch; + CDuiString tDomain = prama->tDomain; + //------------------------------------- + /* + * ��������ѭ�� + */ + for (int i = 0; i < 100; i++) { + std::stringstream ss; + ss << "www." << i << ".com"; + domain.push_back(ss.str()); + ss.clear(); + ss << "it's " << i; + desc.push_back(ss.str()); + CListTextElementUI* pListElement = new CListTextElementUI; + pListElement->SetTag(i); + if (pListElement != NULL) { + ::PostMessage(prama->hWnd, WM_ADDLISTITEM, 0L, (LPARAM)pListElement); } - catch(...) - { - return 0; - } - } - void OnSearch() - { - struct Prama *prama = new Prama; - - CListUI* pList = static_cast(m_pm.FindControl(_T("domainlist"))); - CEditUI* pEdit = static_cast(m_pm.FindControl(_T("input"))); - pEdit->SetEnabled(false); - CDuiString input = pEdit->GetText(); - m_pSearch->SetEnabled(false); - pList->RemoveAll(); - domain.empty(); - domain.resize(0); - desc.empty(); - desc.resize(0); - DWORD dwThreadID = 0; - pList->SetTextCallback(this);//[1] - - prama->hWnd = GetHWND(); - prama->pList = pList; - prama->pSearch = m_pSearch; - prama->tDomain = input; - - HANDLE hThread = CreateThread(NULL,0,&ListMainForm::Search, (LPVOID)prama, 0,&dwThreadID); + /* + * Sleep + *Ϊ��չʾ���ӵĶ�̬Ч�����ʷ����������ٶȣ�ͬʱ���Կ������ӹ����н�����Ȼ������Ӧ + */ + ::Sleep(100); + } + //------------------------------------------ + delete prama; + + pSearch->SetEnabled(true); + return 0; + } catch (...) { + return 0; } - /* - * �ؼ��Ļص�������IListCallbackUI �е�һ���麯������Ⱦʱ������,��[1]�������˻ص����� - */ - LPCTSTR GetItemText(CControlUI* pControl, int iIndex, int iSubItem) - { - TCHAR szBuf[MAX_PATH] = {0}; - switch (iSubItem) - { - case 0: - _stprintf(szBuf, _T("%d"), iIndex); - break; - case 1: - { -#ifdef _UNICODE - int iLen = domain[iIndex].length(); - LPWSTR lpText = new WCHAR[iLen + 1]; - ::ZeroMemory(lpText, (iLen + 1) * sizeof(WCHAR)); - ::MultiByteToWideChar(CP_ACP, 0, domain[iIndex].c_str(), -1, (LPWSTR)lpText, iLen) ; - _stprintf(szBuf, lpText); - delete[] lpText; + } + void OnSearch() { + struct Prama* prama = new Prama; + + CListUI* pList = static_cast(m_pm.FindControl(_T("domainlist"))); + CEditUI* pEdit = static_cast(m_pm.FindControl(_T("input"))); + pEdit->SetEnabled(false); + CDuiString input = pEdit->GetText(); + m_pSearch->SetEnabled(false); + pList->RemoveAll(); + domain.empty(); + domain.resize(0); + desc.empty(); + desc.resize(0); + DWORD dwThreadID = 0; + pList->SetTextCallback(this); //[1] + + prama->hWnd = GetHWND(); + prama->pList = pList; + prama->pSearch = m_pSearch; + prama->tDomain = input; + + HANDLE hThread = CreateThread(NULL, 0, &ListMainForm::Search, (LPVOID)prama, + 0, &dwThreadID); + } + /* + * �ؼ��Ļص�������IListCallbackUI + * �е�һ���麯������Ⱦʱ������,��[1]�������˻ص����� + */ + LPCTSTR GetItemText(CControlUI* pControl, int iIndex, int iSubItem) { + TCHAR szBuf[MAX_PATH] = {0}; + switch (iSubItem) { + case 0: + _stprintf_s(szBuf, _T("%d"), iIndex); + break; + case 1: { +#ifdef _UNICODE + int iLen = domain[iIndex].length(); + LPWSTR lpText = new WCHAR[iLen + 1]; + ::ZeroMemory(lpText, (iLen + 1) * sizeof(WCHAR)); + ::MultiByteToWideChar(CP_ACP, 0, domain[iIndex].c_str(), -1, + (LPWSTR)lpText, iLen); + _stprintf_s(szBuf, lpText); + delete[] lpText; #else - _stprintf(szBuf, domain[iIndex].c_str()); + _stprintf(szBuf, domain[iIndex].c_str()); #endif - } - break; - case 2: - { -#ifdef _UNICODE - int iLen = desc[iIndex].length(); - LPWSTR lpText = new WCHAR[iLen + 1]; - ::ZeroMemory(lpText, (iLen + 1) * sizeof(WCHAR)); - ::MultiByteToWideChar(CP_ACP, 0, desc[iIndex].c_str(), -1, (LPWSTR)lpText, iLen) ; - _stprintf(szBuf, lpText); - delete[] lpText; + } break; + case 2: { +#ifdef _UNICODE + int iLen = desc[iIndex].length(); + LPWSTR lpText = new WCHAR[iLen + 1]; + ::ZeroMemory(lpText, (iLen + 1) * sizeof(WCHAR)); + ::MultiByteToWideChar(CP_ACP, 0, desc[iIndex].c_str(), -1, + (LPWSTR)lpText, iLen); + _stprintf_s(szBuf, lpText); + delete[] lpText; #else - _stprintf(szBuf, desc[iIndex].c_str()); + _stprintf_s(szBuf, desc[iIndex].c_str()); #endif - } - break; - } - pControl->SetUserData(szBuf); - return pControl->GetUserData(); + } break; } - - void Notify(TNotifyUI& msg) - { - if( msg.sType == _T("windowinit") ) - OnPrepare(msg); - 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_pSearch) - { - OnSearch(); - } - } - else if(msg.sType==_T("setfocus")) - { - } - else if( msg.sType == _T("itemclick") ) - { - } - else if( msg.sType == _T("itemactivate") ) - { - int iIndex = msg.pSender->GetTag(); - CDuiString sMessage = _T("Click: ");; -#ifdef _UNICODE - int iLen = domain[iIndex].length(); - LPWSTR lpText = new WCHAR[iLen + 1]; - ::ZeroMemory(lpText, (iLen + 1) * sizeof(WCHAR)); - ::MultiByteToWideChar(CP_ACP, 0, domain[iIndex].c_str(), -1, (LPWSTR)lpText, iLen) ; - sMessage += lpText; - delete[] lpText; + pControl->SetUserData(szBuf); + return pControl->GetUserData(); + } + + void Notify(TNotifyUI& msg) { + if (msg.sType == _T("windowinit")) + OnPrepare(msg); + 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_pSearch) { + OnSearch(); + } + } else if (msg.sType == _T("setfocus")) { + } else if (msg.sType == _T("itemclick")) { + } else if (msg.sType == _T("itemactivate")) { + int iIndex = msg.pSender->GetTag(); + CDuiString sMessage = _T("Click: "); + ; +#ifdef _UNICODE + int iLen = domain[iIndex].length(); + LPWSTR lpText = new WCHAR[iLen + 1]; + ::ZeroMemory(lpText, (iLen + 1) * sizeof(WCHAR)); + ::MultiByteToWideChar(CP_ACP, 0, domain[iIndex].c_str(), -1, + (LPWSTR)lpText, iLen); + sMessage += lpText; + delete[] lpText; #else - sMessage += domain[iIndex].c_str(); + sMessage += domain[iIndex].c_str(); #endif - ::MessageBox(NULL, sMessage.GetData(), _T("��ʾ(by tojen)"), MB_OK); - } - else if(msg.sType == _T("menu")) - { - if( msg.pSender->GetName() != _T("domainlist") ) return; - CMenuWnd* pMenu = new CMenuWnd(); - if( pMenu == NULL ) { return; } - POINT pt = {msg.ptMouse.x, msg.ptMouse.y}; - ::ClientToScreen(*this, &pt); - pMenu->Init(msg.pSender, pt); - } - else if( msg.sType == _T("menu_Delete") ) { - CListUI* pList = static_cast(msg.pSender); - int nSel = pList->GetCurSel(); - if( nSel < 0 ) return; - pList->RemoveAt(nSel); - domain.erase(domain.begin() + nSel); - desc.erase(desc.begin() + nSel); - } + ::MessageBox(NULL, sMessage.GetData(), _T("��ʾ(by tojen)"), MB_OK); + } else if (msg.sType == _T("menu")) { + if (msg.pSender->GetName() != _T("domainlist")) + return; + CMyMenuWnd* pMenu = new CMyMenuWnd(); + if (pMenu == NULL) { + return; + } + POINT pt = {msg.ptMouse.x, msg.ptMouse.y}; + ::ClientToScreen(*this, &pt); + pMenu->Init(msg.pSender, pt); + } else if (msg.sType == _T("menu_Delete")) { + CListUI* pList = static_cast(msg.pSender); + int nSel = pList->GetCurSel(); + if (nSel < 0) + return; + pList->RemoveAt(nSel); + domain.erase(domain.begin() + nSel); + desc.erase(desc.begin() + nSel); } - - LRESULT OnAddListItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - CListTextElementUI* pListElement = (CListTextElementUI*)lParam; - CListUI* pList = static_cast(m_pm.FindControl(_T("domainlist"))); - if( pList ) pList->Add(pListElement); - return 0; + } + + LRESULT OnAddListItem(UINT uMsg, + WPARAM wParam, + LPARAM lParam, + BOOL& bHandled) { + CListTextElementUI* pListElement = (CListTextElementUI*)lParam; + CListUI* pList = static_cast(m_pm.FindControl(_T("domainlist"))); + if (pList) + pList->Add(pListElement); + return 0; + } + + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); + styleValue &= ~WS_CAPTION; + ::SetWindowLong(*this, GWL_STYLE, + styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); + m_pm.Init(m_hWnd); + // m_pm.SetTransparent(100); + CDialogBuilder builder; + CControlUI* pRoot = builder.Create(_T("skin.xml"), (UINT)0, NULL, &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; } - LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - LONG styleValue = ::GetWindowLong(*this, GWL_STYLE); - styleValue &= ~WS_CAPTION; - ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); - m_pm.Init(m_hWnd); - //m_pm.SetTransparent(100); - CDialogBuilder builder; - CControlUI* pRoot = builder.Create(_T("skin.xml"), (UINT)0, NULL, &m_pm); - ASSERT(pRoot && "Failed to parse XML"); - m_pm.AttachDialog(pRoot); - m_pm.AddNotifier(this); - Init(); - return 0; + 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(m_pm.FindControl(pt)); + if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 && + _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 && + _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 0) + return HTCAPTION; } - LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - bHandled = FALSE; - return 0; + 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++; + RECT rc = {rcWnd.left, rcWnd.top + szRoundCorner.cx, rcWnd.right, + rcWnd.bottom}; + HRGN hRgn1 = ::CreateRectRgnIndirect(&rc); + HRGN hRgn2 = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, + rcWnd.bottom - szRoundCorner.cx, + szRoundCorner.cx, szRoundCorner.cy); + ::CombineRgn(hRgn1, hRgn1, hRgn2, RGN_OR); + ::SetWindowRgn(*this, hRgn1, TRUE); + ::DeleteObject(hRgn1); + ::DeleteObject(hRgn2); } - LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - ::PostQuitMessage(0L); - bHandled = FALSE; - return 0; + 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(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.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; } - - 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; + BOOL bZoomed = ::IsZoomed(*this); + LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam); + if (::IsZoomed(*this) != bZoomed) { + if (!bZoomed) { + CControlUI* pControl = + static_cast(m_pm.FindControl(_T("maxbtn"))); + if (pControl) + pControl->SetVisible(false); + pControl = static_cast(m_pm.FindControl(_T("restorebtn"))); + if (pControl) + pControl->SetVisible(true); + } else { + CControlUI* pControl = + static_cast(m_pm.FindControl(_T("maxbtn"))); + if (pControl) + pControl->SetVisible(true); + pControl = static_cast(m_pm.FindControl(_T("restorebtn"))); + if (pControl) + pControl->SetVisible(false); + } } - - 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(m_pm.FindControl(pt)); - if( pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 && - _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 && - _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 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++; - RECT rc = { rcWnd.left, rcWnd.top + szRoundCorner.cx, rcWnd.right, rcWnd.bottom }; - HRGN hRgn1 = ::CreateRectRgnIndirect( &rc ); - HRGN hRgn2 = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom - szRoundCorner.cx, szRoundCorner.cx, szRoundCorner.cy); - ::CombineRgn( hRgn1, hRgn1, hRgn2, RGN_OR ); - ::SetWindowRgn(*this, hRgn1, TRUE); - ::DeleteObject(hRgn1); - ::DeleteObject(hRgn2); - } - - 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(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.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; - + return lRes; + } + + LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { + LRESULT lRes = 0; + BOOL bHandled = TRUE; + switch (uMsg) { + case WM_ADDLISTITEM: + lRes = OnAddListItem(uMsg, wParam, lParam, bHandled); + break; + 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; - 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(m_pm.FindControl(_T("maxbtn"))); - if( pControl ) pControl->SetVisible(false); - pControl = static_cast(m_pm.FindControl(_T("restorebtn"))); - if( pControl ) pControl->SetVisible(true); - } - else { - CControlUI* pControl = static_cast(m_pm.FindControl(_T("maxbtn"))); - if( pControl ) pControl->SetVisible(true); - pControl = static_cast(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_ADDLISTITEM: lRes = OnAddListItem(uMsg, wParam, lParam, bHandled); break; - 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_pSearch; - - //... + 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_pSearch; + + //... }; -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow) -{ - CPaintManagerUI::SetInstance(hInstance); - CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin")); - CPaintManagerUI::SetResourceZip(_T("ListRes.zip")); - - ListMainForm* pFrame = new ListMainForm(); - if( pFrame == NULL ) return 0; - pFrame->Create(NULL, _T("ListDemo"), UI_WNDSTYLE_FRAME, WS_EX_STATICEDGE | WS_EX_APPWINDOW , 0, 0, 600, 320); - pFrame->CenterWindow(); - ::ShowWindow(*pFrame, SW_SHOW); - - CPaintManagerUI::MessageLoop(); - - return 0; +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE /*hPrevInstance*/, + LPTSTR /*lpCmdLine*/, + int nCmdShow) { + CPaintManagerUI::SetInstance(hInstance); + CPaintManagerUI::SetResourcePath(umu::apppath::GetProductDirectory() + _T("_skin")); + CPaintManagerUI::SetResourceZip(_T("ListRes.zip")); + + ListMainForm* pFrame = new ListMainForm(); + if (pFrame == NULL) + return 0; + pFrame->Create(NULL, _T("ListDemo"), UI_WNDSTYLE_FRAME, + WS_EX_STATICEDGE | WS_EX_APPWINDOW, 0, 0, 600, 320); + pFrame->CenterWindow(); + ::ShowWindow(*pFrame, SW_SHOW); + + CPaintManagerUI::MessageLoop(); + + return 0; } \ No newline at end of file diff --git a/ListDemo/MenuWnd.h b/ListDemo/MenuWnd.h index 65fcea9f..e54e1e1e 100644 --- a/ListDemo/MenuWnd.h +++ b/ListDemo/MenuWnd.h @@ -1,278 +1,313 @@ #pragma once -inline HBITMAP CreateMyBitmap(HDC hDC, int cx, int cy, COLORREF** pBits) -{ - LPBITMAPINFO lpbiSrc = NULL; - lpbiSrc = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER)]; - if (lpbiSrc == NULL) return NULL; - - lpbiSrc->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - lpbiSrc->bmiHeader.biWidth = cx; - lpbiSrc->bmiHeader.biHeight = cy; - lpbiSrc->bmiHeader.biPlanes = 1; - lpbiSrc->bmiHeader.biBitCount = 32; - lpbiSrc->bmiHeader.biCompression = BI_RGB; - lpbiSrc->bmiHeader.biSizeImage = cx * cy; - lpbiSrc->bmiHeader.biXPelsPerMeter = 0; - lpbiSrc->bmiHeader.biYPelsPerMeter = 0; - lpbiSrc->bmiHeader.biClrUsed = 0; - lpbiSrc->bmiHeader.biClrImportant = 0; - - HBITMAP hBitmap = CreateDIBSection (hDC, lpbiSrc, DIB_RGB_COLORS, (void **)pBits, NULL, NULL); - delete [] lpbiSrc; - return hBitmap; +inline HBITMAP CreateMyBitmap(HDC hDC, int cx, int cy, COLORREF** pBits) { + LPBITMAPINFO lpbiSrc = NULL; + lpbiSrc = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER)]; + if (lpbiSrc == NULL) + return NULL; + + lpbiSrc->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + lpbiSrc->bmiHeader.biWidth = cx; + lpbiSrc->bmiHeader.biHeight = cy; + lpbiSrc->bmiHeader.biPlanes = 1; + lpbiSrc->bmiHeader.biBitCount = 32; + lpbiSrc->bmiHeader.biCompression = BI_RGB; + lpbiSrc->bmiHeader.biSizeImage = cx * cy; + lpbiSrc->bmiHeader.biXPelsPerMeter = 0; + lpbiSrc->bmiHeader.biYPelsPerMeter = 0; + lpbiSrc->bmiHeader.biClrUsed = 0; + lpbiSrc->bmiHeader.biClrImportant = 0; + + HBITMAP hBitmap = + CreateDIBSection(hDC, lpbiSrc, DIB_RGB_COLORS, (void**)pBits, NULL, NULL); + delete[] lpbiSrc; + return hBitmap; } -class CShadowWnd : public CWindowWnd -{ -private: - bool m_bNeedUpdate; - TDrawInfo m_di; - CPaintManagerUI m_pm; - -public: - CShadowWnd() { - m_di.sDrawString = _T("file='menu_bk.png' corner='40,8,8,8'"); - }; - LPCTSTR GetWindowClassName() const { return _T("UIShadow"); }; - UINT GetClassStyle() const { return UI_CLASSSTYLE_FRAME; }; - void OnFinalMessage(HWND /*hWnd*/) { delete this; }; - - void RePaint() - { - RECT rcClient = { 0 }; - ::GetClientRect(m_hWnd, &rcClient); - DWORD dwWidth = rcClient.right - rcClient.left; - DWORD dwHeight = rcClient.bottom - rcClient.top; - - HDC hDcPaint = ::GetDC(m_hWnd); - HDC hDcBackground = ::CreateCompatibleDC(hDcPaint); - COLORREF* pBackgroundBits; - HBITMAP hbmpBackground = CreateMyBitmap(hDcPaint, dwWidth, dwHeight, &pBackgroundBits); - ::ZeroMemory(pBackgroundBits, dwWidth * dwHeight * 4); - HBITMAP hOldBitmap = (HBITMAP) ::SelectObject(hDcBackground, hbmpBackground); - - CRenderEngine::DrawImage(hDcBackground, &m_pm, rcClient, rcClient, m_di); - - RECT rcWnd = { 0 }; - ::GetWindowRect(m_hWnd, &rcWnd); - - BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; - POINT ptPos = { rcWnd.left, rcWnd.top }; - SIZE sizeWnd = { dwWidth, dwHeight }; - POINT ptSrc = { 0, 0 }; - UpdateLayeredWindow(m_hWnd, hDcPaint, &ptPos, &sizeWnd, hDcBackground, &ptSrc, 0, &bf, ULW_ALPHA); - - ::SelectObject(hDcBackground, hOldBitmap); - if( hDcBackground != NULL ) ::DeleteDC(hDcBackground); - if( hbmpBackground != NULL ) ::DeleteObject(hbmpBackground); - ::ReleaseDC(m_hWnd, hDcPaint); - - m_bNeedUpdate = false; - } - - LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) - { - if( uMsg == WM_CREATE ) SetTimer(m_hWnd, 9000, 10, NULL); - else if( uMsg == WM_SIZE ) m_bNeedUpdate = true; - else if( uMsg == WM_CLOSE ) KillTimer(m_hWnd, 9000); - else if( uMsg == WM_TIMER ) { - if( LOWORD(wParam) == 9000 && m_bNeedUpdate == true) { - if( !::IsIconic(m_hWnd) ) RePaint(); - } - } - - return CWindowWnd::HandleMessage(uMsg, wParam, lParam); +class CShadowWnd : public CWindowWnd { + private: + bool m_bNeedUpdate; + TDrawInfo m_di; + CPaintManagerUI m_pm; + + public: + CShadowWnd() { + m_di.sDrawString = _T("file='menu_bk.png' corner='40,8,8,8'"); + }; + LPCTSTR GetWindowClassName() const { return _T("UIShadow"); }; + UINT GetClassStyle() const { return UI_CLASSSTYLE_FRAME; }; + void OnFinalMessage(HWND /*hWnd*/) { delete this; }; + + void RePaint() { + RECT rcClient = {0}; + ::GetClientRect(m_hWnd, &rcClient); + long width = rcClient.right - rcClient.left; + long height = rcClient.bottom - rcClient.top; + + HDC hDcPaint = ::GetDC(m_hWnd); + HDC hDcBackground = ::CreateCompatibleDC(hDcPaint); + COLORREF* pBackgroundBits; + HBITMAP hbmpBackground = + CreateMyBitmap(hDcPaint, width, height, &pBackgroundBits); + ::ZeroMemory(pBackgroundBits, width * height * 4); + HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hDcBackground, hbmpBackground); + + CRenderEngine::DrawImage(hDcBackground, &m_pm, rcClient, rcClient, m_di); + + RECT rcWnd = {0}; + ::GetWindowRect(m_hWnd, &rcWnd); + + BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA}; + POINT ptPos = {rcWnd.left, rcWnd.top}; + SIZE sizeWnd = {width, height}; + POINT ptSrc = {0, 0}; + UpdateLayeredWindow(m_hWnd, hDcPaint, &ptPos, &sizeWnd, hDcBackground, + &ptSrc, 0, &bf, ULW_ALPHA); + + ::SelectObject(hDcBackground, hOldBitmap); + if (hDcBackground != NULL) + ::DeleteDC(hDcBackground); + if (hbmpBackground != NULL) + ::DeleteObject(hbmpBackground); + ::ReleaseDC(m_hWnd, hDcPaint); + + m_bNeedUpdate = false; + } + + LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { + if (uMsg == WM_CREATE) + SetTimer(m_hWnd, 9000, 10, NULL); + else if (uMsg == WM_SIZE) + m_bNeedUpdate = true; + else if (uMsg == WM_CLOSE) + KillTimer(m_hWnd, 9000); + else if (uMsg == WM_TIMER) { + if (LOWORD(wParam) == 9000 && m_bNeedUpdate == true) { + if (!::IsIconic(m_hWnd)) + RePaint(); + } } + + return CWindowWnd::HandleMessage(uMsg, wParam, lParam); + } }; -class CMenuWnd : public CWindowWnd, public INotifyUI -{ -public: - CMenuWnd() : m_pOwner(NULL), m_pShadowWnd(NULL) { }; - - void Init(CControlUI* pOwner, POINT pt) { - if( pOwner == NULL ) return; - m_pOwner = pOwner; - m_ptPos = pt; - Create(pOwner->GetManager()->GetPaintWindow(), NULL, WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_TOOLWINDOW); - HWND hWndParent = m_hWnd; - while( ::GetParent(hWndParent) != NULL ) hWndParent = ::GetParent(hWndParent); - ::ShowWindow(m_hWnd, SW_SHOW); - ::SendMessage(hWndParent, WM_NCACTIVATE, TRUE, 0L); - } +class CMyMenuWnd : public CWindowWnd, public INotifyUI { + public: + CMyMenuWnd() : m_pOwner(NULL), m_pShadowWnd(NULL){}; - void AdjustPostion() { - CDuiRect rcWnd; - GetWindowRect(m_hWnd, &rcWnd); - int nWidth = rcWnd.GetWidth(); - int nHeight = rcWnd.GetHeight(); - rcWnd.left = m_ptPos.x; - rcWnd.top = m_ptPos.y; - rcWnd.right = rcWnd.left + nWidth; - rcWnd.bottom = rcWnd.top + nHeight; - MONITORINFO oMonitor = {}; - oMonitor.cbSize = sizeof(oMonitor); - ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor); - CDuiRect rcWork = oMonitor.rcWork; - - if( rcWnd.bottom > rcWork.bottom ) { - if( nHeight >= rcWork.GetHeight() ) { - rcWnd.top = 0; - rcWnd.bottom = nHeight; - } - else { - rcWnd.bottom = rcWork.bottom; - rcWnd.top = rcWnd.bottom - nHeight; - } - } - if( rcWnd.right > rcWork.right ) { - if( nWidth >= rcWork.GetWidth() ) { - rcWnd.left = 0; - rcWnd.right = nWidth; - } - else { - rcWnd.right = rcWork.right; - rcWnd.left = rcWnd.right - nWidth; - } - } - ::SetWindowPos(m_hWnd, NULL, rcWnd.left, rcWnd.top, rcWnd.GetWidth(), rcWnd.GetHeight(), SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); - } + void Init(CControlUI* pOwner, POINT pt) { + if (pOwner == NULL) + return; + m_pOwner = pOwner; + m_ptPos = pt; + Create(pOwner->GetManager()->GetPaintWindow(), NULL, + WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + WS_EX_TOOLWINDOW); + HWND hWndParent = m_hWnd; + while (::GetParent(hWndParent) != NULL) + hWndParent = ::GetParent(hWndParent); + ::ShowWindow(m_hWnd, SW_SHOW); + ::SendMessage(hWndParent, WM_NCACTIVATE, TRUE, 0L); + } - LPCTSTR GetWindowClassName() const { return _T("MenuWnd"); }; - void OnFinalMessage(HWND /*hWnd*/) { delete this; }; - - void Notify(TNotifyUI& msg) - { - if( msg.sType == _T("itemselect") ) { - Close(); - } - else if( msg.sType == _T("itemclick") ) { - if( msg.pSender->GetName() == _T("menu_Delete") ) { - if( m_pOwner ) m_pOwner->GetManager()->SendNotify(m_pOwner, _T("menu_Delete"), 0, 0, true); - } - } + void AdjustPostion() { + CDuiRect rcWnd; + GetWindowRect(m_hWnd, &rcWnd); + int nWidth = rcWnd.GetWidth(); + int nHeight = rcWnd.GetHeight(); + rcWnd.left = m_ptPos.x; + rcWnd.top = m_ptPos.y; + rcWnd.right = rcWnd.left + nWidth; + rcWnd.bottom = rcWnd.top + nHeight; + MONITORINFO oMonitor = {}; + oMonitor.cbSize = sizeof(oMonitor); + ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), + &oMonitor); + CDuiRect rcWork = oMonitor.rcWork; + + if (rcWnd.bottom > rcWork.bottom) { + if (nHeight >= rcWork.GetHeight()) { + rcWnd.top = 0; + rcWnd.bottom = nHeight; + } else { + rcWnd.bottom = rcWork.bottom; + rcWnd.top = rcWnd.bottom - nHeight; + } + } + if (rcWnd.right > rcWork.right) { + if (nWidth >= rcWork.GetWidth()) { + rcWnd.left = 0; + rcWnd.right = nWidth; + } else { + rcWnd.right = rcWork.right; + rcWnd.left = rcWnd.right - nWidth; + } } + ::SetWindowPos(m_hWnd, NULL, rcWnd.left, rcWnd.top, rcWnd.GetWidth(), + rcWnd.GetHeight(), + SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); + } - HWND Create(HWND hwndParent, LPCTSTR pstrName, DWORD dwStyle, DWORD dwExStyle, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int cx = CW_USEDEFAULT, int cy = CW_USEDEFAULT, HMENU hMenu = NULL) - { - if( m_pShadowWnd == NULL ) m_pShadowWnd = new CShadowWnd; - m_pShadowWnd->Create(hwndParent, _T(""), WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS, WS_EX_LAYERED | WS_EX_TOOLWINDOW, x, y, cx, cy, NULL); + LPCTSTR GetWindowClassName() const { return _T("MenuWnd"); }; + void OnFinalMessage(HWND /*hWnd*/) { delete this; }; - dwExStyle |= WS_EX_TOOLWINDOW; - return CWindowWnd::Create(hwndParent, pstrName, dwStyle, dwExStyle, x, y, cx, cy, hMenu); + void Notify(TNotifyUI& msg) { + if (msg.sType == _T("itemselect")) { + Close(); + } else if (msg.sType == _T("itemclick")) { + if (msg.pSender->GetName() == _T("menu_Delete")) { + if (m_pOwner) + m_pOwner->GetManager()->SendNotify(m_pOwner, _T("menu_Delete"), 0, 0, + true); + } } + } - void ShowWindow(bool bShow = true, bool bTakeFocus = true) - { - if( m_pShadowWnd != NULL ) m_pShadowWnd->ShowWindow(bShow, false); - CWindowWnd::ShowWindow(bShow, bTakeFocus); - } + HWND Create(HWND hwndParent, + LPCTSTR pstrName, + DWORD dwStyle, + DWORD dwExStyle, + int x = CW_USEDEFAULT, + int y = CW_USEDEFAULT, + int cx = CW_USEDEFAULT, + int cy = CW_USEDEFAULT, + HMENU hMenu = NULL) { + if (m_pShadowWnd == NULL) + m_pShadowWnd = new CShadowWnd; + m_pShadowWnd->Create(hwndParent, _T(""), + WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS, + WS_EX_LAYERED | WS_EX_TOOLWINDOW, x, y, cx, cy, NULL); - LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - m_pm.Init(m_hWnd); - CDialogBuilder builder; - CControlUI* pRoot = builder.Create(_T("menu.xml"), (UINT)0, NULL, &m_pm); - ASSERT(pRoot && "Failed to parse XML"); - m_pm.AttachDialog(pRoot); - m_pm.AddNotifier(this); - m_pm.SetRoundCorner(3, 3); - - CListUI* pList = static_cast(m_pOwner); - int nSel = pList->GetCurSel(); - if( nSel < 0 ) { - CControlUI* pControl = m_pm.FindControl(_T("menu_Delete")); - if( pControl ) pControl->SetEnabled(false); - } - - AdjustPostion(); - return 0; - } + dwExStyle |= WS_EX_TOOLWINDOW; + return CWindowWnd::Create(hwndParent, pstrName, dwStyle, dwExStyle, x, y, + cx, cy, hMenu); + } - LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - if( m_pShadowWnd != NULL ) m_pShadowWnd->Close(); - bHandled = FALSE; - return 0; - } + void ShowWindow(bool bShow = true, bool bTakeFocus = true) { + if (m_pShadowWnd != NULL) + m_pShadowWnd->ShowWindow(bShow, false); + CWindowWnd::ShowWindow(bShow, bTakeFocus); + } + + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + m_pm.Init(m_hWnd); + CDialogBuilder builder; + CControlUI* pRoot = builder.Create(_T("menu.xml"), (UINT)0, NULL, &m_pm); + ASSERT(pRoot && "Failed to parse XML"); + m_pm.AttachDialog(pRoot); + m_pm.AddNotifier(this); + m_pm.SetRoundCorner(3, 3); - LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - if( (HWND)wParam == m_hWnd ) bHandled = TRUE; - else if( m_pShadowWnd != NULL && (HWND)wParam == m_pShadowWnd->GetHWND() ) { - CWindowWnd::HandleMessage(uMsg, wParam, lParam); - ::SetFocus( m_hWnd ); - bHandled = TRUE; - } - else { - Close(); - bHandled = FALSE; - } - return 0; + CListUI* pList = static_cast(m_pOwner); + int nSel = pList->GetCurSel(); + if (nSel < 0) { + CControlUI* pControl = m_pm.FindControl(_T("menu_Delete")); + if (pControl) + pControl->SetEnabled(false); } - LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - if( wParam == VK_ESCAPE ) Close(); - return 0; + AdjustPostion(); + return 0; + } + + LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + if (m_pShadowWnd != NULL) + m_pShadowWnd->Close(); + bHandled = FALSE; + return 0; + } + + LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + if ((HWND)wParam == m_hWnd) + bHandled = TRUE; + else if (m_pShadowWnd != NULL && (HWND)wParam == m_pShadowWnd->GetHWND()) { + CWindowWnd::HandleMessage(uMsg, wParam, lParam); + ::SetFocus(m_hWnd); + bHandled = TRUE; + } else { + Close(); + bHandled = FALSE; } + return 0; + } - LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - if( !::IsIconic(*this) ) { - CDuiRect rcWnd; - ::GetWindowRect(*this, &rcWnd); - rcWnd.Offset(-rcWnd.left, -rcWnd.top); - HRGN hRgn = ::CreateRectRgn(rcWnd.left + 8, rcWnd.top + 8, rcWnd.right - 8, rcWnd.bottom - 8); - ::SetWindowRgn(*this, hRgn, TRUE); - ::DeleteObject(hRgn); - } - if( m_pShadowWnd != NULL ) { - RECT rcWnd = { 0 }; - ::GetWindowRect(m_hWnd, &rcWnd ); - ::SetWindowPos(*m_pShadowWnd, m_hWnd, rcWnd.left, rcWnd.top, rcWnd.right -rcWnd.left, - rcWnd.bottom -rcWnd.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); - } - bHandled = FALSE; - return 0; + LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + if (wParam == VK_ESCAPE) + Close(); + return 0; + } + + LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + if (!::IsIconic(*this)) { + CDuiRect rcWnd; + ::GetWindowRect(*this, &rcWnd); + rcWnd.Offset(-rcWnd.left, -rcWnd.top); + HRGN hRgn = ::CreateRectRgn(rcWnd.left + 8, rcWnd.top + 8, + rcWnd.right - 8, rcWnd.bottom - 8); + ::SetWindowRgn(*this, hRgn, TRUE); + ::DeleteObject(hRgn); } + if (m_pShadowWnd != NULL) { + RECT rcWnd = {0}; + ::GetWindowRect(m_hWnd, &rcWnd); + ::SetWindowPos(*m_pShadowWnd, m_hWnd, rcWnd.left, rcWnd.top, + rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); + } + bHandled = FALSE; + return 0; + } - LRESULT OnMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) - { - if( m_pShadowWnd != NULL ) { - RECT rcWnd = { 0 }; - ::GetWindowRect(m_hWnd, &rcWnd ); - ::SetWindowPos(*m_pShadowWnd, m_hWnd, rcWnd.left, rcWnd.top, rcWnd.right -rcWnd.left, - rcWnd.bottom -rcWnd.top, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); - } - bHandled = FALSE; - return 0; + LRESULT OnMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + if (m_pShadowWnd != NULL) { + RECT rcWnd = {0}; + ::GetWindowRect(m_hWnd, &rcWnd); + ::SetWindowPos(*m_pShadowWnd, m_hWnd, rcWnd.left, rcWnd.top, + rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top, + SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); } + bHandled = FALSE; + return 0; + } - 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_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break; - case WM_KEYDOWN: lRes = OnKeyDown(uMsg, wParam, lParam, bHandled); break; - case WM_MOUSEWHEEL: break; - case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break; - case WM_MOVE: lRes = OnMove(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); + 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_KILLFOCUS: + lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); + break; + case WM_KEYDOWN: + lRes = OnKeyDown(uMsg, wParam, lParam, bHandled); + break; + case WM_MOUSEWHEEL: + break; + case WM_SIZE: + lRes = OnSize(uMsg, wParam, lParam, bHandled); + break; + case WM_MOVE: + lRes = OnMove(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; - CControlUI* m_pOwner; - POINT m_ptPos; - CShadowWnd* m_pShadowWnd; + public: + CPaintManagerUI m_pm; + CControlUI* m_pOwner; + POINT m_ptPos; + CShadowWnd* m_pShadowWnd; }; diff --git a/MenuDemo/MenuDemo.vcxproj b/MenuDemo/MenuDemo.vcxproj index 2241f1ca..1e3c141c 100644 --- a/MenuDemo/MenuDemo.vcxproj +++ b/MenuDemo/MenuDemo.vcxproj @@ -177,7 +177,7 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true @@ -214,7 +214,7 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true @@ -255,7 +255,6 @@ stdafx.h - true Level3 true ProgramDatabase @@ -293,7 +292,6 @@ stdafx.h - true Level3 true ProgramDatabase @@ -332,7 +330,6 @@ stdafx.h - true Level3 true ProgramDatabase @@ -370,7 +367,6 @@ stdafx.h - true Level3 true ProgramDatabase @@ -405,7 +401,7 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true @@ -443,7 +439,7 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true diff --git a/QQDemo/CMakeLists.txt b/QQDemo/CMakeLists.txt deleted file mode 100644 index e8df60e0..00000000 --- a/QQDemo/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -#Cmake file for QQDemo -#Author: Qi Gao(monkgau@gmail.com) -#Created: 2012/9/17 - -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - - -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -add_executable(QQDemo ${SRC} QQDemo.rc) -set_target_properties(QQDemo PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") -target_link_libraries(QQDemo duilib) - - -add_custom_command(TARGET QQDemo POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${PROJECT_BINARY_DIR}/bin/QQDemo.exe ${PROJECT_SOURCE_DIR}/bin/QQDemo.exe) diff --git a/QQDemo/ColorPicker.hpp b/QQDemo/ColorPicker.hpp index f76de999..0c8e4c2f 100644 --- a/QQDemo/ColorPicker.hpp +++ b/QQDemo/ColorPicker.hpp @@ -1,6 +1,6 @@ #ifndef COLORPICKER_HPP #define COLORPICKER_HPP -#include "..\DuiLib\Utils\WinImplBase.h" +#include "DuiLib/Utils/WinImplBase.h" class ChatDialog; class CColorPicker : public WindowImplBase diff --git a/QQDemo/QQDemo.vcproj b/QQDemo/QQDemo.vcproj deleted file mode 100644 index 06543413..00000000 --- a/QQDemo/QQDemo.vcproj +++ /dev/null @@ -1,517 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/QQDemo/QQDemo.vcxproj b/QQDemo/QQDemo.vcxproj index 96218eb3..fe74e877 100644 --- a/QQDemo/QQDemo.vcxproj +++ b/QQDemo/QQDemo.vcxproj @@ -1,59 +1,104 @@  - + + + MbcsDebug + Win32 + + + MbcsDebug + x64 + + + MbcsRelease + Win32 + + + MbcsRelease + x64 + Debug Win32 + + Debug + x64 + Release Win32 - - UnicodeDebug - Win32 - - - UnicodeRelease - Win32 + + Release + x64 {5EEA82DD-05C7-477F-8870-942E8758BFFF} + 10.0.17134.0 - + Application - v120 + v141 false Unicode + true - + Application - v120 + v141 false Unicode + true Application - v120 + v141 + false + Unicode + + + Application + v141 + false + Unicode + + + Application + v141 false MultiByte - + Application - v120 + v141 false MultiByte + + Application + v141 + false + MultiByte + true + + + Application + v141 + false + MultiByte + true + - + - + @@ -61,7 +106,23 @@ - + + + + + + + + + + + + + + + + + @@ -69,25 +130,45 @@ <_ProjectFileVersion>12.0.30501.0 - - $(SolutionDir)\bin\ - .\Release\ + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)\bin\ - .\Debug\ false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - - $(SolutionDir)\bin\ - .\Debug_u\ + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ - - $(SolutionDir)\bin\ - .\Release_u\ + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ + + false + $(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\ + $(SolutionDir)tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\ @@ -95,7 +176,6 @@ true true Win32 - .\Release/QQDemo.tlb @@ -107,30 +187,52 @@ true stdafx.h - .\Release/QQDemo.pch - .\Release/ - .\Release/ - .\Release/ Level3 true + ..\;..\include\; NDEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/QQDemo.exe true - .\Release/QQDemo.pdb Windows MachineX86 - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - duilib.lib;%(AdditionalDependencies) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + stdafx.h + Level3 true - .\Release/QQDemo.bsc - + ..\;..\include\; + + + NDEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + Windows + + @@ -138,7 +240,6 @@ true true Win32 - .\Debug/QQDemo.tlb @@ -149,43 +250,61 @@ MultiThreadedDebug stdafx.h - .\Debug/QQDemo.pch - .\Debug/ - .\Debug/ - .\Debug/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) 0x0406 - ../bin/QQDemo_d.exe true true - .\Debug/QQDemo.pdb - true - .\Debug/QQDemo.map Windows MachineX86 - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - duilib_d.lib;%(AdditionalDependencies) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true true - .\Debug/QQDemo.bsc - + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + stdafx.h + Level3 + true + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0406 + + + true + true + Windows + + - + _DEBUG;%(PreprocessorDefinitions) true true Win32 - .\Debug/QQDemo.tlb @@ -193,46 +312,63 @@ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug - + MultiThreadedDebugDLL + Use stdafx.h - .\Debug_u/QQDemo.pch - .\Debug_u/ - .\Debug_u/ - .\Debug_u/ - true Level3 true ProgramDatabase + ..\;..\include\; _DEBUG;%(PreprocessorDefinitions) - 0x0406 + 0x0409 - ../bin/QQDemo_ud.exe true true - .\Debug_u/QQDemo.pdb - true - .\Debug_u/QQDemo.map Windows MachineX86 - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - duilib_ud.lib;%(AdditionalDependencies) - + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + stdafx.h + Level3 + true + ProgramDatabase + ..\;..\include\; + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + true - .\Debug/QQDemo.bsc - + true + Windows + + - + NDEBUG;%(PreprocessorDefinitions) true true Win32 - .\Release/QQDemo.tlb @@ -240,34 +376,95 @@ OnlyExplicitInline WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - MultiThreaded + MultiThreadedDLL true - + Use stdafx.h - .\Release_u/QQDemo.pch - .\Release_u/ - .\Release_u/ - .\Release_u/ Level3 true + ..\;..\include\; NDEBUG;%(PreprocessorDefinitions) - 0x0406 + 0x0409 - ../bin/QQDemo_u.exe true - .\Release_u/QQDemo.pdb Windows MachineX86 - $(SolutionDir)lib;%(AdditionalLibraryDirectories) - duilib_u.lib;%(AdditionalDependencies) - + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + + + + + MinSpace + OnlyExplicitInline + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + Use + stdafx.h + Level3 true - .\Release/QQDemo.bsc - + ..\;..\include\; + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + + + + + + 0x0409 + + + ..\;..\include\; + Use + MultiThreadedDebugDLL + + + + + 0x0409 + + + ..\;..\include\; + Use + MultiThreadedDLL + + + + + 0x0409 + + + ..\;..\include\; + Use + MultiThreadedDebugDLL + + + + + 0x0409 + + + ..\;..\include\; + Use + MultiThreadedDLL + @@ -277,7 +474,16 @@ - + + Create + Create + Create + Create + Create + Create + Create + Create + @@ -301,6 +507,11 @@ + + + {e106acd7-4e53-4aee-942b-d0dd426db34e} + + diff --git a/QQDemo/StdAfx.h b/QQDemo/StdAfx.h index a1369356..9169d9a2 100644 --- a/QQDemo/StdAfx.h +++ b/QQDemo/StdAfx.h @@ -1,4 +1,3 @@ - #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ @@ -26,18 +25,15 @@ #define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_DEPRECATE -#include -#include +#include +#include + #include #include #include -#include -#include -#include -#include #include -#include "..\DuiLib\UIlib.h" +#include "DuiLib/UIlib.h" #ifndef NO_USING_DUILIB_NAMESPACE using namespace DuiLib; diff --git a/QQDemo/main.cpp b/QQDemo/main.cpp index 56f3a5b7..e41c159f 100644 --- a/QQDemo/main.cpp +++ b/QQDemo/main.cpp @@ -2,12 +2,13 @@ // win_impl_base.hpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2011 achellies (achellies at 163 dot com), wangchyz (wangchyz at gmail dot com) +// Copyright (c) 2011 achellies (achellies at 163 dot com), wangchyz (wangchyz +// at gmail dot com) // // This code may be used in compiled form in any way you desire. This -// source file may be redistributed by any means PROVIDING it is -// not sold for profit without the authors written consent, and -// providing that this notice and the authors name is included. +// source file may be redistributed by any means PROVIDING it is +// not sold for profit without the authors written consent, and +// providing that this notice and the authors name is included. // // This file is provided "as is" with no expressed or implied warranty. // The author accepts no liability if it causes any damage to you or your @@ -17,55 +18,60 @@ // #include "stdafx.h" -#include "..\DuiLib\Utils\WinImplBase.h" + +#include + +#include "DuiLib/Utils/WinImplBase.h" #include "main_frame.hpp" +#include "umu/apppath_t.h" -#include CComModule _Module; -#include -#if defined(WIN32) && !defined(UNDER_CE) -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow) -#else -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int nCmdShow) -#endif -{ - CPaintManagerUI::SetInstance(hInstance); - CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath()); +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE /*hPrevInstance*/, + LPTSTR lpCmdLine, + int nCmdShow) { + CPaintManagerUI::SetInstance(hInstance); + CPaintManagerUI::SetResourcePath(umu::apppath::GetProductDirectory() + + _T("_skin")); - HINSTANCE hInstRich = ::LoadLibrary(_T("Riched20.dll")); + HINSTANCE hInstRich = ::LoadLibrary(_T("Riched20.dll")); - ::CoInitialize(NULL); - ::OleInitialize(NULL); + ::CoInitialize(NULL); + ::OleInitialize(NULL); - _Module.Init( 0, hInstance ); + _Module.Init(0, hInstance); #if defined(WIN32) && !defined(UNDER_CE) - HRESULT Hr = ::CoInitialize(NULL); + HRESULT Hr = ::CoInitialize(NULL); #else - HRESULT Hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); + HRESULT Hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); #endif - if( FAILED(Hr) ) return 0; + if (FAILED(Hr)) + return 0; - MainFrame* pFrame = new MainFrame(); - if( pFrame == NULL ) return 0; + MainFrame* pFrame = new MainFrame(); + if (pFrame == NULL) + return 0; #if defined(WIN32) && !defined(UNDER_CE) - pFrame->Create(NULL, _T("QQ2011"), UI_WNDSTYLE_FRAME, WS_EX_STATICEDGE | WS_EX_APPWINDOW, 0, 0, 600, 800); + pFrame->Create(NULL, _T("QQ2011"), UI_WNDSTYLE_FRAME, + WS_EX_STATICEDGE | WS_EX_APPWINDOW, 0, 0, 600, 800); #else - pFrame->Create(NULL, _T("QQ2011"), UI_WNDSTYLE_FRAME, WS_EX_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); + pFrame->Create(NULL, _T("QQ2011"), UI_WNDSTYLE_FRAME, WS_EX_TOPMOST, 0, 0, + GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); #endif - pFrame->CenterWindow(); - ::ShowWindow(*pFrame, SW_SHOW); + pFrame->CenterWindow(); + ::ShowWindow(*pFrame, SW_SHOW); - CPaintManagerUI::MessageLoop(); - CPaintManagerUI::Term(); + CPaintManagerUI::MessageLoop(); + CPaintManagerUI::Term(); - _Module.Term(); + _Module.Term(); - ::OleUninitialize(); - ::CoUninitialize(); + ::OleUninitialize(); + ::CoUninitialize(); - ::FreeLibrary(hInstRich); + ::FreeLibrary(hInstRich); - return 0; + return 0; } \ No newline at end of file diff --git a/RichListDemo/CMakeLists.txt b/RichListDemo/CMakeLists.txt deleted file mode 100644 index 8407d96e..00000000 --- a/RichListDemo/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -#Cmake file for RichListDemo -#Author: Qi Gao(monkgau@gmail.com) -#Created: 2012/9/17 - -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC_LIST) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - - -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) - -add_executable(RichListDemo ${SRC_LIST} RichListDemo.rc) -set_target_properties(RichListDemo PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") -target_link_libraries(RichListDemo duilib) - -add_custom_command(TARGET RichListDemo POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${PROJECT_BINARY_DIR}/bin/RichListDemo.exe ${PROJECT_SOURCE_DIR}/bin/RichListDemo.exe) diff --git a/RichListDemo/ReadMe.txt b/RichListDemo/ReadMe.txt deleted file mode 100644 index f0db8ab5..00000000 --- a/RichListDemo/ReadMe.txt +++ /dev/null @@ -1,47 +0,0 @@ -======================================================================== - WIN32 应用程序:RichListDemo 项目概述 -======================================================================== - -应用程序向导已为您创建了此 RichListDemo 应用程序。 - -本文件概要介绍组成 RichListDemo 应用程序的 -的每个文件的内容。 - - -RichListDemo.vcproj - 这是使用应用程序向导生成的 VC++ 项目的主项目文件, - 其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 - -RichListDemo.cpp - 这是主应用程序源文件。 - -///////////////////////////////////////////////////////////////////////////// -应用程序向导创建了下列资源: - -RichListDemo.rc -这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。 -此文件可以直接在 Microsoft Visual C++ 中进行编辑。 - -Resource.h - 这是标准头文件,可用于定义新的资源 ID。 - Microsoft Visual C++ 将读取并更新此文件。 - -RichListDemo.ico - 这是一个图标文件,可用作应用程序的图标 (32x32)。 - 此图标包括在主资源文件 RichListDemo.rc 中。 - -small.ico - 这是一个图标文件,其中包含应用程序的图标的较小版本 (16x16)。此图标包括在主资源文件 RichListDemo.rc 中。 - -///////////////////////////////////////////////////////////////////////////// -其他标准文件: - -StdAfx.h, StdAfx.cpp - 这些文件用于生成名为 RichListDemo.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 - -///////////////////////////////////////////////////////////////////////////// -其他注释: - -应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 - -///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/RichListDemo/RichListDemo.cpp b/RichListDemo/RichListDemo.cpp index a2a14b60..39a512f2 100644 --- a/RichListDemo/RichListDemo.cpp +++ b/RichListDemo/RichListDemo.cpp @@ -1,30 +1,34 @@ // RichListDemo.cpp : ����Ӧ�ó������ڵ㡣 // - #include "stdafx.h" -#include -#include -#include "RichListWnd.h" -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow) -{ - CPaintManagerUI::SetInstance(hInstance); - //CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("\\skin")); - //CPaintManagerUI::SetResourceZip(_T("RichListRes.zip")); - - HRESULT Hr = ::CoInitialize(NULL); - if( FAILED(Hr) ) return 0; +#include "RichListWnd.h" +#include "umu/apppath_t.h" - CRichListWnd* pFrame = new CRichListWnd(); - if( pFrame == NULL ) return 0; - pFrame->Create(NULL, _T("DuiLib Demo from mbstudio.cn / meineson"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 500, 400); - pFrame->CenterWindow(); - ::ShowWindow(*pFrame, SW_SHOW); +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE /*hPrevInstance*/, + LPSTR /*lpCmdLine*/, + int nCmdShow) { + CPaintManagerUI::SetInstance(hInstance); + CPaintManagerUI::SetResourcePath(umu::apppath::GetProductDirectory() + + _T("_skin")); + CPaintManagerUI::SetResourceZip(_T("RichListRes.zip")); - //::MessageBox(NULL, _T("alert!"), _T("Duilib Demo"), MB_OK); + HRESULT hr = ::CoInitialize(NULL); + if (FAILED(hr)) { + return hr; + } - CPaintManagerUI::MessageLoop(); + CRichListWnd* pFrame = new CRichListWnd(); + if (pFrame == nullptr) { + return ERROR_NOT_ENOUGH_MEMORY; + } + pFrame->Create(nullptr, _T("DuiLib Demo from mbstudio.cn / meineson"), + UI_WNDSTYLE_FRAME, 0L, 0, 0, 500, 400); + pFrame->CenterWindow(); + ::ShowWindow(*pFrame, SW_SHOW); - ::CoUninitialize(); - return 0; + int result = CPaintManagerUI::MessageLoop(); + ::CoUninitialize(); + return result; } diff --git a/RichListDemo/RichListDemo.vcproj b/RichListDemo/RichListDemo.vcproj deleted file mode 100644 index e0b9cb88..00000000 --- a/RichListDemo/RichListDemo.vcproj +++ /dev/null @@ -1,418 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/RichListDemo/RichListDemo.vcxproj b/RichListDemo/RichListDemo.vcxproj index 1924bcef..abea57de 100644 --- a/RichListDemo/RichListDemo.vcxproj +++ b/RichListDemo/RichListDemo.vcxproj @@ -1,182 +1,311 @@  + + MbcsDebug + Win32 + + + MbcsDebug + x64 + + + MbcsRelease + Win32 + + + MbcsRelease + x64 + Debug Win32 + + Debug + x64 + Release Win32 - - UnicodeDebug - Win32 - - - UnicodeRelease - Win32 + + Release + x64 {6F77AFCB-2F96-4573-8882-3578EBA8CA1D} RichListDemo Win32Proj + 10.0.17134.0 - + Application v110 Unicode - v120_xp + v141 - + Application v110 Unicode - true - v120_xp + v141 + Application + v110 + Unicode + true + v141 + + + Application + v110 + Unicode + true + v141 + + Application v110 MultiByte true - v120_xp + v141 - + + Application + v110 + MultiByte + true + v141 + + Application v110 MultiByte - v120_xp + v141 + + + Application + v110 + MultiByte + v141 - + - + - + + + + + + + + + + + + + <_ProjectFileVersion>11.0.61030.0 - - $(SolutionDir)bin\ - $(Configuration)\ + + false + + + false + + + false + + false - $(SolutionDir)bin\ - $(Configuration)\ false - - $(SolutionDir)bin\ - $(Configuration)\ + false - - $(SolutionDir)bin\ - $(Configuration)\ + false - + + false + + Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug - + MultiThreadedDebugDLL + Use Level3 ProgramDatabase + ..\;..\include\; - $(OutDir)$(ProjectName)_d.exe true - .\$(Configuration)\$(TargetName).pdb Windows MachineX86 - + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + ProgramDatabase + ..\;..\include\; + + + true + Windows + + + MaxSpeed true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreaded + MultiThreadedDLL true Use Level3 ProgramDatabase + ..\;..\include\; - $(OutDir)$(ProjectName).exe true - .\$(Configuration)\$(TargetName).pdb Windows true true MachineX86 - + + + MaxSpeed + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level3 + ProgramDatabase + ..\;..\include\; + + + true + Windows + true + true + + + MaxSpeed true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreaded + MultiThreadedDLL true Use Level3 ProgramDatabase + ..\;..\include\; - $(OutDir)$(ProjectName)_u.exe true - .\$(Configuration)\$(TargetName).pdb Windows true true MachineX86 - + + + MaxSpeed + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level3 + ProgramDatabase + ..\;..\include\; + + + true + Windows + true + true + + + Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebug + MultiThreadedDebugDLL Use Level3 ProgramDatabase + ..\;..\include\; - $(OutDir)$(ProjectName)_ud.exe true - .\$(Configuration)\$(TargetName).pdb Windows MachineX86 + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + ProgramDatabase + ..\;..\include\; + + + true + Windows + + + Create + Create + Create + Create Create + Create Create - Create - Create + Create @@ -192,9 +321,6 @@ - - - {e106acd7-4e53-4aee-942b-d0dd426db34e} diff --git a/RichListDemo/RichListDemo.vcxproj.filters b/RichListDemo/RichListDemo.vcxproj.filters index 26f8532f..60eff65d 100644 --- a/RichListDemo/RichListDemo.vcxproj.filters +++ b/RichListDemo/RichListDemo.vcxproj.filters @@ -52,7 +52,4 @@ 资源文件 - - - \ No newline at end of file diff --git a/RichListDemo/stdafx.h b/RichListDemo/stdafx.h index 8275dc54..49ea02c7 100644 --- a/RichListDemo/stdafx.h +++ b/RichListDemo/stdafx.h @@ -24,8 +24,9 @@ #endif #define WIN32_LEAN_AND_MEAN // �� Windows ͷ���ų�����ʹ�õ����� -// Windows ͷ�ļ�: -#include + +#include +#include // C ����ʱͷ�ļ� #include @@ -34,10 +35,6 @@ #include #include -// TODO: �ڴ˴����ó�����Ҫ������ͷ�ļ� - -#include - -#include "..\DuiLib\UIlib.h" +#include "DuiLib/UIlib.h" using namespace DuiLib; diff --git a/ScrCapture/App.cpp b/ScrCapture/App.cpp index f3222987..f21e5732 100644 --- a/ScrCapture/App.cpp +++ b/ScrCapture/App.cpp @@ -4,10 +4,6 @@ #include "stdafx.h" #include "ScrCaptureWnd.h" - -#include -#include - #include "umu/apppath_t.h" int APIENTRY _tWinMain(HINSTANCE hInstance, diff --git a/ScrCapture/ScrCapture.vcxproj b/ScrCapture/ScrCapture.vcxproj index 232c8277..18babde3 100644 --- a/ScrCapture/ScrCapture.vcxproj +++ b/ScrCapture/ScrCapture.vcxproj @@ -176,7 +176,6 @@ true true Win32 - .\Release/ScrCapture.tlb @@ -208,7 +207,6 @@ NDEBUG;%(PreprocessorDefinitions) true true - .\Release/ScrCapture.tlb @@ -241,7 +239,6 @@ true true Win32 - .\Debug/ScrCapture.tlb @@ -252,7 +249,6 @@ MultiThreadedDebugDLL Use stdafx.h - true Level3 true ProgramDatabase @@ -275,7 +271,6 @@ _DEBUG;%(PreprocessorDefinitions) true true - .\Debug/ScrCapture.tlb @@ -286,7 +281,6 @@ MultiThreadedDebugDLL Use stdafx.h - true Level3 true ProgramDatabase @@ -309,7 +303,6 @@ true true Win32 - .\Debug/ScrCapture.tlb @@ -320,7 +313,6 @@ MultiThreadedDebugDLL Use stdafx.h - true Level3 true ProgramDatabase @@ -343,7 +335,6 @@ _DEBUG;%(PreprocessorDefinitions) true true - .\Debug/ScrCapture.tlb @@ -354,7 +345,6 @@ MultiThreadedDebugDLL Use stdafx.h - true Level3 true ProgramDatabase @@ -377,7 +367,6 @@ true true Win32 - .\Release/ScrCapture.tlb @@ -395,7 +384,7 @@ NDEBUG;%(PreprocessorDefinitions) - 0x0406 + 0x0409 true @@ -409,7 +398,6 @@ NDEBUG;%(PreprocessorDefinitions) true true - .\Release/ScrCapture.tlb diff --git a/ScrCapture/ScrCaptureWnd.h b/ScrCapture/ScrCaptureWnd.h index 63b32990..d9edb520 100644 --- a/ScrCapture/ScrCaptureWnd.h +++ b/ScrCapture/ScrCaptureWnd.h @@ -1,44 +1,48 @@ #pragma once -class CScrCaptureWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI -{ -private: - CScrCaptureWnd(); - ~CScrCaptureWnd(); - -public: - static CScrCaptureWnd* Instance(); - - LPCTSTR GetWindowClassName() const; - UINT GetClassStyle() const; - void OnFinalMessage(HWND /*hWnd*/); - - void Init(); - void OnPrepare(); - void Notify(TNotifyUI& msg); - - RECT GetWindowRect() const; - RECT GetClipPadding() const; - void SetClipPadding(RECT rc); - RECT GetClipRect() const; - RECT GetCanvasContainerRect() const; - - LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled); - LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); - -private: - static CScrCaptureWnd* m_pInstance; - CPaintManagerUI m_pm; - HMENU m_hEditMenu; - - CControlUI* m_pDesktopImage; - CControlUI* m_pDesktopMask; - CControlUI* m_pDesktopMaskBorder; - CContainerUI* m_pDesktopCanvasContainer; - - RECT m_rcWindow; - RECT m_rcClipPadding; - POINT m_ptClipBasePoint; // ������׼�� - bool m_bClipChoiced; // �Ƿ���ѡ���ͼ���� - TCHAR m_sClipDrawStringBuf[MAX_PATH]; +class CScrCaptureWnd : public CWindowWnd, + public INotifyUI, + public IMessageFilterUI { + private: + CScrCaptureWnd(); + ~CScrCaptureWnd(); + + public: + static CScrCaptureWnd* Instance(); + + LPCTSTR GetWindowClassName() const; + UINT GetClassStyle() const; + void OnFinalMessage(HWND /*hWnd*/); + + void Init(); + void OnPrepare(); + void Notify(TNotifyUI& msg); + + RECT GetWindowRect() const; + RECT GetClipPadding() const; + void SetClipPadding(RECT rc); + RECT GetClipRect() const; + RECT GetCanvasContainerRect() const; + + LRESULT MessageHandler(UINT uMsg, + WPARAM wParam, + LPARAM lParam, + bool& bHandled); + LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); + + private: + static CScrCaptureWnd* m_pInstance; + CPaintManagerUI m_pm; + HMENU m_hEditMenu; + + CControlUI* m_pDesktopImage; + CControlUI* m_pDesktopMask; + CControlUI* m_pDesktopMaskBorder; + CContainerUI* m_pDesktopCanvasContainer; + + RECT m_rcWindow; + RECT m_rcClipPadding; + POINT m_ptClipBasePoint; // ������׼�� + bool m_bClipChoiced; // �Ƿ���ѡ���ͼ���� + TCHAR m_sClipDrawStringBuf[MAX_PATH]; }; diff --git a/ScrCapture/StdAfx.h b/ScrCapture/StdAfx.h index 35fb6e81..879e5496 100644 --- a/ScrCapture/StdAfx.h +++ b/ScrCapture/StdAfx.h @@ -6,8 +6,8 @@ #define WIN32_LEAN_AND_MEAN #define _CRT_SECURE_NO_DEPRECATE -#include -#include +#include +#include #include "DuiLib\UIlib.h" diff --git a/bin/skin/360SafeRes.zip b/_skin/360SafeRes.zip similarity index 100% rename from bin/skin/360SafeRes.zip rename to _skin/360SafeRes.zip diff --git a/bin/skin/FlashRes/frame_btn_close_disable.bmp b/_skin/FlashRes/frame_btn_close_disable.bmp similarity index 100% rename from bin/skin/FlashRes/frame_btn_close_disable.bmp rename to _skin/FlashRes/frame_btn_close_disable.bmp diff --git a/bin/skin/FlashRes/frame_btn_close_down.bmp b/_skin/FlashRes/frame_btn_close_down.bmp similarity index 100% rename from bin/skin/FlashRes/frame_btn_close_down.bmp rename to _skin/FlashRes/frame_btn_close_down.bmp diff --git a/bin/skin/FlashRes/frame_btn_close_hot.bmp b/_skin/FlashRes/frame_btn_close_hot.bmp similarity index 100% rename from bin/skin/FlashRes/frame_btn_close_hot.bmp rename to _skin/FlashRes/frame_btn_close_hot.bmp diff --git a/bin/skin/FlashRes/frame_btn_close_normal.bmp b/_skin/FlashRes/frame_btn_close_normal.bmp similarity index 100% rename from bin/skin/FlashRes/frame_btn_close_normal.bmp rename to _skin/FlashRes/frame_btn_close_normal.bmp diff --git a/bin/skin/FlashRes/test.swf b/_skin/FlashRes/test.swf similarity index 100% rename from bin/skin/FlashRes/test.swf rename to _skin/FlashRes/test.swf diff --git a/bin/skin/FlashRes/ui.xml b/_skin/FlashRes/ui.xml similarity index 98% rename from bin/skin/FlashRes/ui.xml rename to _skin/FlashRes/ui.xml index 1238b3f4..7b0c40b9 100644 --- a/bin/skin/FlashRes/ui.xml +++ b/_skin/FlashRes/ui.xml @@ -1,14 +1,14 @@ - - - - -