Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/duilib/duilib
Browse files Browse the repository at this point in the history
  • Loading branch information
AtaLuZiK committed Mar 25, 2016
2 parents 9005bbc + 3fa8930 commit 664275b
Show file tree
Hide file tree
Showing 117 changed files with 9,812 additions and 3,185 deletions.
6 changes: 3 additions & 3 deletions 360SafeDemo/360Safe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ class C360SafeFrameWnd : public CWindowWnd, public INotifyUI
if( pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
&& pt.y >= rcCaption.top && pt.y < rcCaption.bottom ) {
CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
if( pControl && _tcscmp(pControl->GetClass(), _T("ButtonUI")) != 0 &&
_tcscmp(pControl->GetClass(), _T("OptionUI")) != 0 &&
_tcscmp(pControl->GetClass(), _T("TextUI")) != 0 )
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;
}

Expand Down
56 changes: 21 additions & 35 deletions DuiLib.sln
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuiLib", "DuiLib\DuiLib.vcproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuiLib", "DuiLib\DuiLib.vcxproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameDemo", "GameDemo\GameDemo.vcproj", "{21B017E7-7805-40D5-9D96-AABF572F57D1}"
ProjectSection(ProjectDependencies) = postProject
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameDemo", "GameDemo\GameDemo.vcxproj", "{21B017E7-7805-40D5-9D96-AABF572F57D1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp1", "TestApp1\TestApp1.vcproj", "{41B017E7-7805-40D5-9D96-AABF572F57D1}"
ProjectSection(ProjectDependencies) = postProject
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp1", "TestApp1\TestApp1.vcxproj", "{41B017E7-7805-40D5-9D96-AABF572F57D1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ListDemo", "ListDemo\ListDemo.vcproj", "{223017E7-7805-40D5-9D96-AABF572F57D1}"
ProjectSection(ProjectDependencies) = postProject
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
EndProjectSection
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.vcproj", "{463FE628-A176-4C58-B005-3924BFD1E4E6}"
ProjectSection(ProjectDependencies) = postProject
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "360Safe", "360SafeDemo\360SafeDemo.vcxproj", "{463FE628-A176-4C58-B005-3924BFD1E4E6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FlashDemo", "FlashDemo\FlashDemo.vcproj", "{41B017E7-7805-40D5-9D96-AABF572F5700}"
ProjectSection(ProjectDependencies) = postProject
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FlashDemo", "FlashDemo\FlashDemo.vcxproj", "{41B017E7-7805-40D5-9D96-AABF572F5700}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QQDemo", "QQDemo\QQDemo.vcproj", "{5EEA82DD-05C7-477F-8870-942E8758BFFF}"
ProjectSection(ProjectDependencies) = postProject
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QQDemo", "QQDemo\QQDemo.vcxproj", "{5EEA82DD-05C7-477F-8870-942E8758BFFF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MenuDemo", "MenuDemo\MenuDemo.vcproj", "{11A20D10-E0D7-447F-A546-8E4662C115C5}"
ProjectSection(ProjectDependencies) = postProject
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MenuDemo", "MenuDemo\MenuDemo.vcxproj", "{11A20D10-E0D7-447F-A546-8E4662C115C5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RichListDemo", "RichListDemo\RichListDemo.vcproj", "{6F77AFCB-2F96-4573-8882-3578EBA8CA1D}"
ProjectSection(ProjectDependencies) = postProject
{E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
EndProjectSection
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RichListDemo", "RichListDemo\RichListDemo.vcxproj", "{6F77AFCB-2F96-4573-8882-3578EBA8CA1D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScrCapture", "ScrCapture\ScrCapture.vcxproj", "{41B017E7-7805-40D5-9D96-AABF572F57D2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -123,6 +101,14 @@ Global
{6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.UnicodeDebug|Win32.Build.0 = UnicodeDebug|Win32
{6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.UnicodeRelease|Win32.ActiveCfg = UnicodeRelease|Win32
{6F77AFCB-2F96-4573-8882-3578EBA8CA1D}.UnicodeRelease|Win32.Build.0 = UnicodeRelease|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D2}.Debug|Win32.ActiveCfg = Debug|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D2}.Debug|Win32.Build.0 = Debug|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D2}.Release|Win32.ActiveCfg = Release|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D2}.Release|Win32.Build.0 = Release|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D2}.UnicodeDebug|Win32.ActiveCfg = UnicodeDebug|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D2}.UnicodeDebug|Win32.Build.0 = UnicodeDebug|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D2}.UnicodeRelease|Win32.ActiveCfg = UnicodeRelease|Win32
{41B017E7-7805-40D5-9D96-AABF572F57D2}.UnicodeRelease|Win32.Build.0 = UnicodeRelease|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
88 changes: 83 additions & 5 deletions DuiLib/Control/UIActiveX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CActiveXCtrl;
class CActiveXWnd : public CWindowWnd
{
public:
CActiveXWnd() : m_iLayeredTick(0), m_bDrawCaret(false) {}
HWND Init(CActiveXCtrl* pOwner, HWND hWndParent);

LPCTSTR GetWindowClassName() const;
Expand All @@ -26,14 +27,23 @@ class CActiveXWnd : public CWindowWnd
protected:
void DoVerb(LONG iVerb);

LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnPrint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

protected:
enum {
DEFAULT_TIMERID = 20,
};

CActiveXCtrl* m_pOwner;
int m_iLayeredTick;
bool m_bDrawCaret;
};


Expand Down Expand Up @@ -768,6 +778,7 @@ LPCTSTR CActiveXWnd::GetWindowClassName() const

void CActiveXWnd::OnFinalMessage(HWND hWnd)
{
m_pOwner->m_pOwner->GetManager()->RemoveNativeWindow(hWnd);
//delete this; // 这里不需要清理,CActiveXUI会清理的
}

Expand All @@ -790,7 +801,10 @@ LRESULT CActiveXWnd::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_TIMER: lRes = OnTimer(uMsg, wParam, lParam, bHandled); break;
case WM_PAINT: lRes = OnPaint(uMsg, wParam, lParam, bHandled); break;
case WM_PRINT: lRes = OnPrint(uMsg, wParam, lParam, bHandled); break;
case WM_SETFOCUS: lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break;
case WM_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break;
case WM_ERASEBKGND: lRes = OnEraseBkgnd(uMsg, wParam, lParam, bHandled); break;
Expand All @@ -803,6 +817,32 @@ LRESULT CActiveXWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
return lRes;
}

LRESULT CActiveXWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
m_pOwner->m_pOwner->GetManager()->AddNativeWindow(m_pOwner->m_pOwner, m_hWnd);
if( m_pOwner->m_pOwner->GetManager()->IsLayered() ) {
::SetTimer(m_hWnd, DEFAULT_TIMERID, 50, NULL);
}
return 0;
}

LRESULT CActiveXWnd::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (wParam == DEFAULT_TIMERID) {
if (m_pOwner->m_pOwner->GetManager()->IsLayered()) {
m_pOwner->m_pOwner->GetManager()->AddNativeWindow(m_pOwner->m_pOwner, m_hWnd);
m_iLayeredTick += 1;
if (m_iLayeredTick >= 10) {
m_iLayeredTick = 0;
m_bDrawCaret = !m_bDrawCaret;
}
}
return 0;
}
bHandled = FALSE;
return 0;
}

LRESULT CActiveXWnd::OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if( m_pOwner->m_pViewObject == NULL ) bHandled = FALSE;
Expand Down Expand Up @@ -846,6 +886,34 @@ LRESULT CActiveXWnd::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
return 1;
}

LRESULT CActiveXWnd::OnPrint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
RECT rcClient;
::GetClientRect(m_hWnd, &rcClient);
m_pOwner->m_pViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL, (HDC)wParam, (RECTL*) &rcClient, NULL, NULL, NULL);

if (m_bDrawCaret ) {
RECT rcPos = m_pOwner->m_pOwner->GetPos();
GUITHREADINFO guiThreadInfo;
guiThreadInfo.cbSize = sizeof(GUITHREADINFO);
::GetGUIThreadInfo(NULL, &guiThreadInfo);
if (guiThreadInfo.hwndCaret) {
POINT ptCaret;
ptCaret.x = guiThreadInfo.rcCaret.left;
ptCaret.y = guiThreadInfo.rcCaret.top;
::ClientToScreen(guiThreadInfo.hwndCaret, &ptCaret);
::ScreenToClient(m_pOwner->m_pOwner->GetManager()->GetPaintWindow(), &ptCaret);
if( ::PtInRect(&rcPos, ptCaret) ) {
RECT rcCaret;
rcCaret = guiThreadInfo.rcCaret;
rcCaret.right = rcCaret.left;
CRenderEngine::DrawLine((HDC)wParam, rcCaret, 1, 0xFF000000);
}
}
}

return 1;
}

/////////////////////////////////////////////////////////////////////////////////////
//
Expand All @@ -854,16 +922,18 @@ LRESULT CActiveXWnd::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
CActiveXUI::CActiveXUI() : m_pUnk(NULL), m_pControl(NULL), m_hwndHost(NULL), m_bCreated(false), m_bDelayCreate(true)
{
m_clsid = IID_NULL;
::CoInitialize(NULL);
}

CActiveXUI::~CActiveXUI()
{
ReleaseControl();
::CoUninitialize();
}

LPCTSTR CActiveXUI::GetClass() const
{
return _T("ActiveXUI");
return DUI_CTR_ACTIVEX;
}

LPVOID CActiveXUI::GetInterface(LPCTSTR pstrName)
Expand All @@ -872,7 +942,12 @@ LPVOID CActiveXUI::GetInterface(LPCTSTR pstrName)
return CControlUI::GetInterface(pstrName);
}

HWND CActiveXUI::GetHostWindow() const
UINT CActiveXUI::GetControlFlags() const
{
return UIFLAG_TABSTOP;
}

HWND CActiveXUI::GetNativeWindow() const
{
return m_hwndHost;
}
Expand Down Expand Up @@ -944,14 +1019,13 @@ void CActiveXUI::Move(SIZE szOffset, bool bNeedInvalidate)
}
}

void CActiveXUI::DoPaint(HDC hDC, const RECT& rcPaint)
bool CActiveXUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return;

if( m_pControl != NULL && m_pControl->m_bWindowless && m_pControl->m_pViewObject != NULL )
{
m_pControl->m_pViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL, hDC, (RECTL*) &m_rcItem, (RECTL*) &m_rcItem, NULL, NULL);
}
return true;
}

void CActiveXUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
Expand Down Expand Up @@ -984,6 +1058,10 @@ LRESULT CActiveXUI::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool
}
if( dwHitResult != HITRESULT_HIT ) return 0;
if( uMsg == WM_SETCURSOR ) bWasHandled = false;
else if( uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONDBLCLK || uMsg == WM_RBUTTONDOWN ) {
if (!GetManager()->IsNoActivate()) ::SetFocus(GetManager()->GetPaintWindow());
SetFocus();
}
}
else if( uMsg >= WM_KEYFIRST && uMsg <= WM_KEYLAST ) {
// Keyboard messages just go when we have focus
Expand Down
8 changes: 4 additions & 4 deletions DuiLib/Control/UIActiveX.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CSafeRelease
/////////////////////////////////////////////////////////////////////////////////////
//

class UILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI
class DUILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI
{
friend class CActiveXCtrl;
public:
Expand All @@ -34,8 +34,8 @@ class UILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI

LPCTSTR GetClass() const;
LPVOID GetInterface(LPCTSTR pstrName);

HWND GetHostWindow() const;
UINT GetControlFlags() const;
HWND GetNativeWindow() const;

bool IsDelayCreate() const;
void SetDelayCreate(bool bDelayCreate = true);
Expand All @@ -51,7 +51,7 @@ class UILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI
void SetInternVisible(bool bVisible = true);
void SetPos(RECT rc, bool bNeedInvalidate = true);
void Move(SIZE szOffset, bool bNeedInvalidate = true);
void DoPaint(HDC hDC, const RECT& rcPaint);
bool DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);

void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);

Expand Down
Loading

0 comments on commit 664275b

Please sign in to comment.