ScreenWnd.cpp
上传用户:liuhua
上传日期:2022-07-19
资源大小:27k
文件大小:3k
- // ScreenWnd.cpp : implementation file
- // Download by http://www.codefans.net
- #include "stdafx.h"
- #include "screensaveprograme.h"
- ////ADd the *.h function
- #include "DrawWnd.h"
- //////////
- #include "ScreenWnd.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CScreenWnd
- CScreenWnd::CScreenWnd()
- {
- m_ptLast=CPoint(-1,-1);
- }
- CScreenWnd::~CScreenWnd()
- {
- }
- BEGIN_MESSAGE_MAP(CScreenWnd, CDrawWnd)
- //{{AFX_MSG_MAP(CScreenWnd)
- ON_WM_ACTIVATE()
- ON_WM_ACTIVATEAPP()
- ON_WM_DESTROY()
- ON_WM_KEYDOWN()
- ON_WM_LBUTTONDOWN()
- ON_WM_MOUSEMOVE()
- ON_WM_NCACTIVATE()
- ON_WM_RBUTTONDOWN()
- ON_WM_SETCURSOR()
- ON_WM_SYSCOMMAND()
- ON_WM_SYSKEYDOWN()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CScreenWnd message handlers
- BOOL CScreenWnd::Create()
- {
- CRect rect(0, 0, ::GetSystemMetrics(SM_CXSCREEN),
- ::GetSystemMetrics(SM_CYSCREEN));
- return CDrawWnd::Create(WS_EX_TOPMOST, WS_VISIBLE|WS_POPUP, rect, NULL,
- 0, NULL);
- }
- void CScreenWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
- {if(nState==WA_INACTIVE) PostMessage(WM_CLOSE);
- CDrawWnd::OnActivate(nState, pWndOther, bMinimized);
-
- // TODO: Add your message handler code here
-
- }
- void CScreenWnd::OnActivateApp(BOOL bActive, HTASK hTask)
- {
- if(!bActive) PostMessage(WM_CLOSE);
- CDrawWnd::OnActivateApp(bActive, hTask);
-
- // TODO: Add your message handler code here
-
- }
- void CScreenWnd::OnDestroy()
- {
- PostQuitMessage(0);
- CDrawWnd::OnDestroy();
-
- // TODO: Add your message handler code here
-
- }
- void CScreenWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- PostMessage(WM_CLOSE);
- CDrawWnd::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- void CScreenWnd::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- PostMessage(WM_CLOSE);
- CDrawWnd::OnLButtonDown(nFlags, point);
- }
- void CScreenWnd::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- if(m_ptLast==CPoint(-1,-1))m_ptLast=point;
- else if (m_ptLast!=point)PostMessage(WM_CLOSE);
- CDrawWnd::OnMouseMove(nFlags, point);
- }
- BOOL CScreenWnd::OnNcActivate(BOOL bActive)
- {
- // TODO: Add your message handler code here and/or call default
- if(!bActive) return FALSE;
- return CDrawWnd::OnNcActivate(bActive);
- }
- void CScreenWnd::OnRButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
-
- CDrawWnd::OnRButtonDown(nFlags, point);
- }
- BOOL CScreenWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
- {
- // TODO: Add your message handler code here and/or call default
- SetCursor(NULL);
- return CDrawWnd::OnSetCursor(pWnd, nHitTest, message);
- }
- void CScreenWnd::OnSysCommand(UINT nID, LPARAM lParam)
- {
- // TODO: Add your message handler code here and/or call default
- if ((nID == SC_SCREENSAVE) || (nID == SC_CLOSE))
- return;
- CDrawWnd::OnSysCommand(nID, lParam);
- }
- void CScreenWnd::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- PostMessage(WM_CLOSE);
- CDrawWnd::OnSysKeyDown(nChar, nRepCnt, nFlags);
- }