sswnd.cpp
资源名称:ssbase.rar [点击查看]
上传用户:linpin
上传日期:2022-02-22
资源大小:24k
文件大小:4k
源码类别:
屏幕保护
开发平台:
Visual C++
- // ssWnd.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ssbase.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSmallWnd
- CSmallWnd::CSmallWnd()
- {
- m_brBk=NULL;
- }
- CSmallWnd::~CSmallWnd()
- {
- }
- BOOL CSmallWnd::CreateAsShow(CWnd* pParent)
- {
- LPCSTR lpszClassName;
- lpszClassName = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,NULL,m_brBk);
- CRect rect;
- pParent->GetClientRect(rect);
- return CreateEx(0,
- lpszClassName,
- _T(""),
- WS_CHILD|WS_VISIBLE,
- rect.left,
- rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top,
- pParent->GetSafeHwnd(),
- NULL,
- NULL );
- }
- BEGIN_MESSAGE_MAP(CSmallWnd, CWnd)
- //{{AFX_MSG_MAP(CSmallWnd)
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSmallWnd message handlers
- /////////////////////////////////////////////////////////////////////////////
- int CSmallWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if(m_uTimeTick)
- SetTimer(1,m_uTimeTick,NULL);
- return 0;
- }
- // CFullWnd
- CFullWnd::CFullWnd():m_ptLast(-1,-1)
- {
- m_brBk=NULL;
- m_fCanQuit=FALSE;
- }
- CFullWnd::~CFullWnd()
- {
- }
- BOOL CFullWnd::CreateAsTop(void)
- {
- m_iWidthScreen=::GetSystemMetrics(SM_CXSCREEN);
- m_iHeightScreen=::GetSystemMetrics(SM_CYSCREEN);
- CRect rect(0, 0, m_iWidthScreen,m_iHeightScreen);
- LPCSTR lpszClassName;
- lpszClassName = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,NULL,m_brBk);
- return CreateEx(WS_EX_TOPMOST,
- lpszClassName,
- _T(""),
- WS_POPUP|WS_VISIBLE,
- rect.left,
- rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top,
- NULL,
- NULL,
- NULL);
- }
- BEGIN_MESSAGE_MAP(CFullWnd, CWnd)
- //{{AFX_MSG_MAP(CFullWnd)
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONDOWN()
- ON_WM_SYSKEYDOWN()
- ON_WM_SYSCOMMAND()
- ON_WM_RBUTTONDOWN()
- ON_WM_KEYDOWN()
- ON_WM_SETCURSOR()
- ON_WM_MBUTTONDOWN()
- ON_WM_CREATE()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CFullWnd message handlers
- void CFullWnd::OnMouseMove(UINT nFlags, CPoint point)
- {
- if (m_ptLast == CPoint(-1,-1))
- m_ptLast = point;
- else
- if (m_ptLast != point)
- PostMessage(WM_CLOSE);
- CWnd::OnMouseMove(nFlags, point);
- }
- void CFullWnd::OnLButtonDown(UINT nFlags, CPoint point)
- {
- PostMessage(WM_CLOSE);
- CWnd::OnLButtonDown(nFlags, point);
- }
- void CFullWnd::OnMButtonDown(UINT nFlags, CPoint point)
- {
- PostMessage(WM_CLOSE);
- CWnd::OnMButtonDown(nFlags, point);
- }
- void CFullWnd::OnRButtonDown(UINT nFlags, CPoint point)
- {
- PostMessage(WM_CLOSE);
- CWnd::OnRButtonDown(nFlags, point);
- }
- void CFullWnd::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- if(m_fCanQuit)
- PostMessage(WM_CLOSE);
- CWnd::OnSysKeyDown(nChar, nRepCnt, nFlags);
- }
- void CFullWnd::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID == SC_SCREENSAVE))
- return;
- CWnd::OnSysCommand(nID, lParam);
- }
- void CFullWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- if(m_fCanQuit)
- PostMessage(WM_CLOSE);
- CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- BOOL CFullWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
- {
- SetCursor(NULL);
- return CWnd::OnSetCursor(pWnd, nHitTest, message);
- }
- int CFullWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if(m_uTimeTick)
- SetTimer(1,m_uTimeTick,NULL);
- return 0;
- }
- void CFullWnd::OnTimer(UINT nIDEvent)
- {
- static int iEnter=0;
- if(iEnter>10)
- m_fCanQuit=TRUE;
- else
- iEnter++;
- CWnd::OnTimer(nIDEvent);
- }