基本信息
源码名称:C++ 仿新版360安全卫士 示例源码(界面)
源码大小:0.65M
文件格式:.rar
开发语言:C/C++
更新时间:2018-01-30
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 3 元×
微信扫码支付:3 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
C winform版 《仿360杀毒》页面切换动画效果
C winform版 《仿360杀毒》页面切换动画效果
#include "StdAfx.h"
#include "BaseDialog.h"
#include <memory>
void BaseDialog::Notify(TNotifyUI& msg)
{
if ( msg.sType == _T("click"))
{
if( msg.pSender == static_cast<CButtonUI*>(m_pm.FindControl(_T("minbtn"))) )
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
if( msg.pSender == static_cast<CButtonUI*>(m_pm.FindControl(_T("closebtn"))) )
PostQuitMessage(0);
if( msg.pSender == static_cast<CButtonUI*>(m_pm.FindControl(_T("maxbtn"))) )
::IsZoomed(*this) ? SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0) : SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
}
LRESULT BaseDialog::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static std::auto_ptr<MessageMap> customMessageMap(InitMessageMap());
BOOL bHandled = TRUE;
LRESULT lRes = 0;
if ( customMessageMap->find(uMsg) != customMessageMap->end() )
{
CustomMsgHandler handler = (*customMessageMap)[uMsg];
lRes = (this->*handler)(wParam, lParam, bHandled);
if ( bHandled ) return lRes;
}
if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes;
return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
}
BaseDialog::MessageMap* BaseDialog::InitMessageMap()
{
MessageMap* map = new MessageMap;
(*map)[WM_CREATE] = &BaseDialog::OnCreate;
(*map)[WM_DESTROY] = &BaseDialog::OnDestory;
(*map)[WM_ERASEBKGND] = &BaseDialog::OnErasebkgnd;
(*map)[WM_SIZE] = &BaseDialog::OnSize;
(*map)[WM_NCPAINT] = &BaseDialog::OnNcPaint;
(*map)[WM_NCACTIVATE] = &BaseDialog::OnNcActive;
(*map)[WM_NCCALCSIZE] = &BaseDialog::OnNcCalSize;
(*map)[WM_NCHITTEST] = &BaseDialog::OnNcHitTest;
(*map)[WM_SYSCOMMAND] = &BaseDialog::OnSysCommand;
(*map)[WM_GETMINMAXINFO] = &BaseDialog::OnGetMinMaxInfo;
return map;
}
HRESULT BaseDialog::OnCreate( 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("main_dlg.xml"), (UINT)0, NULL, &m_pm);
m_pm.AttachDialog(pRoot);
m_pm.AddNotifier(this);
return 0;
}
HRESULT BaseDialog::OnDestory( WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
::PostQuitMessage(0L);
return 0;
}
HRESULT BaseDialog::OnErasebkgnd( WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
return 1;
}
HRESULT BaseDialog::OnSize( WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
SIZE szRoundCorner = m_pm.GetRoundCorner();
if( !::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0) )
{
CRect 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;
}
HRESULT BaseDialog::OnNcPaint( WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
return 0;
}
HRESULT BaseDialog::OnNcActive( WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
if( ::IsIconic(*this) ) bHandled = FALSE;
return (wParam == 0) ? TRUE : FALSE;
}
HRESULT BaseDialog::OnNcCalSize( WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
return 0;
}
HRESULT BaseDialog::OnNcHitTest( WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
POINT pt;
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
::ScreenToClient(*this, &pt);
RECT rcClient;
::GetClientRect(*this, &rcClient);
if( !::IsZoomed(*this) )
{
RECT rcSizeBox = m_pm.GetSizeBox();
if( pt.y < rcClient.top rcSizeBox.top )
{
if( pt.x < rcClient.left rcSizeBox.left ) return HTTOPLEFT;
if( pt.x > rcClient.right - rcSizeBox.right ) return HTTOPRIGHT;
return HTTOP;
}
else if( pt.y > rcClient.bottom - rcSizeBox.bottom )
{
if( pt.x < rcClient.left rcSizeBox.left ) return HTBOTTOMLEFT;
if( pt.x > rcClient.right - rcSizeBox.right ) return HTBOTTOMRIGHT;
return HTBOTTOM;
}
if( pt.x < rcClient.left rcSizeBox.left ) return HTLEFT;
if( pt.x > rcClient.right - rcSizeBox.right ) return HTRIGHT;
}
RECT rcCaption = m_pm.GetCaptionRect();
if( pt.x >= rcClient.left rcCaption.left
&& pt.x < rcClient.right - rcCaption.right
&& pt.y >= rcCaption.top
&& pt.y < rcCaption.bottom )
{
CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
if( pControl
&& _tcscmp(pControl->GetClass(), _T("ButtonUI")) != 0
&& _tcscmp(pControl->GetClass(), _T("OptionUI")) != 0 )
{
return HTCAPTION;
}
}
return HTCLIENT;
}
LRESULT BaseDialog::OnSysCommand(WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if( wParam == SC_CLOSE )
{
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
BOOL bZoomed = ::IsZoomed(*this);
LRESULT lRes = CWindowWnd::HandleMessage(WM_SYSCOMMAND, wParam, lParam);
return 1L;
}
LRESULT BaseDialog::OnGetMinMaxInfo(WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
MONITORINFO oMonitor = {};
oMonitor.cbSize = sizeof(oMonitor);
::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor);
CRect rcWork = oMonitor.rcWork;
rcWork.Offset(-rcWork.left, -rcWork.top);
/// 窗口最大化时裁剪阴影所占区域
LPMINMAXINFO lpMMI = (LPMINMAXINFO) lParam;
lpMMI->ptMaxPosition.x = rcWork.left-5;
lpMMI->ptMaxPosition.y = rcWork.top-3;
lpMMI->ptMaxSize.x = rcWork.right 10;
lpMMI->ptMaxSize.y = rcWork.bottom 10;
bHandled = FALSE;
return 0;
}