/************************************************************************ * 程序名: 精仿QQ主界面 * 制作人: 李克平, 2011年04月11日 * 版本号: 1.0 ************************************************************************/ #include "stdafx.h" #include "SkinWin.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CSkinWin::CSkinWin() { } CSkinWin::~CSkinWin() { } BOOL CSkinWin::InstallSkin(CWnd *wnd) { if ( !wnd ) return FALSE; HookWindow( (HWND)NULL); int r = HookWindow( wnd ); DWORD style = GetWindowLong( m_hWnd, GWL_STYLE ); style &= ~(WS_MINIMIZEBOX); style &= ~WS_MAXIMIZEBOX; style &= ~WS_SYSMENU; SetWindowLong( m_hWnd, GWL_STYLE, style ); return r; } LRESULT CSkinWin::WindowProc(UINT msg, WPARAM wp, LPARAM lp) { if ( !IsWindow(m_hWnd) ) return 0; switch ( msg ) { case WM_NCHITTEST: { Default(); return OnNcHitTest(CPoint(LOWORD(lp), HIWORD(lp))); } default: return Default(); } } UINT CSkinWin::OnNcHitTest(CPoint point) { static int m_TitleHeight = 5; static int m_BorderLeftWidth = 5; static int m_BorderRightWidth=5; static int m_BorderBottomHeight = 5; CWnd *pWnd = CWnd::FromHandle(m_hWnd); CRect wr; pWnd->GetWindowRect(wr); point.x -= wr.left; point.y -= wr.top; CRect rc; int cx = GetSystemMetrics(SM_CXSMICON); int cy = GetSystemMetrics(SM_CYSMICON); rc = CRect( 0, 0, m_BorderLeftWidth, m_TitleHeight ); if ( PtInRect( rc, point )) //!IsZoomed(m_hWnd) ) return HTTOPLEFT; rc = CRect( wr.Width() - m_BorderLeftWidth, 0, wr.Width(), m_TitleHeight ); if ( PtInRect( rc, point ) ) //!IsZoomed(m_hWnd) ) return HTTOPRIGHT; rc = CRect( 0, wr.Height() - m_BorderBottomHeight, m_BorderLeftWidth, wr.Height() ); if ( PtInRect( rc, point ) ) //!IsZoomed(m_hWnd) ) return HTBOTTOMLEFT; rc = CRect( wr.Width()-m_BorderRightWidth, wr.Height() - m_BorderBottomHeight, wr.Width(), wr.Height() ); if ( PtInRect( rc, point )) //!IsZoomed(m_hWnd) ) return HTBOTTOMRIGHT; rc = CRect( 0, m_TitleHeight, m_BorderLeftWidth, wr.Height() - m_BorderBottomHeight ); if ( PtInRect( rc, point )) //!IsZoomed(m_hWnd) ) return HTLEFT; rc = CRect( wr.Width()-m_BorderRightWidth, m_TitleHeight, wr.Width(), wr.Height() - m_BorderBottomHeight ); if ( PtInRect( rc, point ) ) //!IsZoomed(m_hWnd) ) return HTRIGHT; rc = CRect( m_BorderLeftWidth, wr.Height() - m_BorderBottomHeight, wr.Width()-m_BorderRightWidth, wr.Height() ); if ( PtInRect( rc, point ) ) //!IsZoomed(m_hWnd) ) return HTBOTTOM; rc = CRect( m_BorderLeftWidth, 0, wr.Width()-m_BorderRightWidth, m_BorderBottomHeight ); if ( PtInRect( rc, point )) //!IsZoomed(m_hWnd) ) return HTTOP; return HTCLIENT; }