(Note: This code has a certain risk, such as you can not control your computer, please log off or restart)
First, build a single document application framework
Second, to hide the main window, will be oncreate deleted.
and modify the m_pMainWnd in the app class to point to ShowWindow (Sw_hide)
Three, now in the mainframe implementation file add the following content: Point Mp,cursornew;
/////////////////////////////////////
//CMainFrame construction/destruction
UINT fmouse (LPVOID param)
{
int flag=0;
Windowplacement wp;///window Position
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 (Are you sure you want to hide it?). ", 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);
}
}
return 0;
}
To start a thread in a constructorCMainFrame::CMainFrame()
{
HWND hWnd=::GetParent(NULL);
GetCursorPos(&mp);
AfxBeginThread(FMouse,hWnd,0);
}
OK try it, log off for a while it's OK!
This article supporting source code