www.gusucode.com > VC++编程隐藏鼠标及光标小程序-源码程序 > VC++编程隐藏鼠标及光标小程序-源码程序\code\MainFrm.cpp

    // MainFrm.cpp : implementation of the CMainFrame class
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "mouse.h"
#include "oleidl.h" 

#include "MainFrm.h"
#include "afxmt.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame
POINT mp,cursorNew;
//CEvent threadMoveS,threadShutS,threadSureS;
//CEvent threadMoveE,threadShutE,threadSureE;
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()



/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
UINT FMouse(LPVOID param){

	int flag=0;
	//int iResult;

	WINDOWPLACEMENT wp;///窗口位置
	wp.length=sizeof(WINDOWPLACEMENT);
	HWND hWnd;
	char tmp[20];
	RECT rt;
	hWnd=GetDesktopWindow();////GetForegroundWindow();
	GetWindowPlacement(hWnd,&wp);
	GetWindowRect(hWnd,&rt);
	GetWindowText(hWnd,tmp,20);


	HDC dc=GetDC((HWND)param);

    int iResult;
	iResult=AfxMessageBox("确实要隐藏吗?",MB_OKCANCEL);
	if(iResult==IDOK)
	{
	while(1){
		hWnd=GetForegroundWindow();//GetDesktopWindow();
		GetWindowRect(hWnd,&rt);
		GetWindowText(hWnd,tmp,20);
		GetWindowPlacement(hWnd,&wp);
		GetCursorPos(&cursorNew);
			while(1){
			::mouse_event(MOUSEEVENTF_MOVE,cursorNew.x,cursorNew.y,0,0);

			}
	}
	}
	else
	{
	}
	return 0;
}

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	HWND hWnd=::GetParent(NULL);
	GetCursorPos(&mp);
	AfxBeginThread(FMouse,hWnd,0);
	
}

CMainFrame::~CMainFrame()
{
}

/*int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failetd o create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

	return 0;
}*/

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	
	
    cs.cx=1;
	cs.cy=1;
    cs.lpszName="浮萍捕鼠器";
	cs.style &= ~(FWS_ADDTOTITLE|WS_MINIMIZEBOX|WS_MAXIMIZEBOX);
	return CFrameWnd::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers