Click here to Skip to main content
15,886,110 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Is SetCursorPos() Calling MouseMove ? Pin
«_Superman_»24-May-12 20:12
professional«_Superman_»24-May-12 20:12 
GeneralRe: Is SetCursorPos() Calling MouseMove ? Pin
002comp24-May-12 20:40
002comp24-May-12 20:40 
GeneralRe: Is SetCursorPos() Calling MouseMove ? Pin
002comp24-May-12 21:19
002comp24-May-12 21:19 
GeneralRe: Is SetCursorPos() Calling MouseMove ? Pin
«_Superman_»24-May-12 21:42
professional«_Superman_»24-May-12 21:42 
GeneralRe: Is SetCursorPos() Calling MouseMove ? Pin
002comp24-May-12 23:52
002comp24-May-12 23:52 
GeneralRe: Is SetCursorPos() Calling MouseMove ? Pin
«_Superman_»25-May-12 0:00
professional«_Superman_»25-May-12 0:00 
GeneralRe: Is SetCursorPos() Calling MouseMove ? [Working] Pin
002comp25-May-12 2:55
002comp25-May-12 2:55 
AnswerRe: Is SetCursorPos() Calling MouseMove ? Pin
Randor 25-May-12 1:25
professional Randor 25-May-12 1:25 
Hi,

Rather than using SetCursorPos you could use the SendInput function[^]. This would allow you to set some 'extra info' for marking simulated user input.

For example:

C++
BOOL setcursorposition(long x, long y)
{
	INPUT input = {0};
	input.type = INPUT_MOUSE;
	input.mi.dx = ((x - GetSystemMetrics(SM_XVIRTUALSCREEN)) * 65535) / (GetSystemMetrics(SM_CXVIRTUALSCREEN)-1);
	input.mi.dy = ((y - GetSystemMetrics(SM_YVIRTUALSCREEN)) * 65535) / (GetSystemMetrics(SM_CYVIRTUALSCREEN)-1);
	input.mi.dwFlags = MOUSEEVENTF_VIRTUALDESK | MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
	input.mi.dwExtraInfo = 0xC0DEDBAD;
	return SendInput(1, &input, sizeof(input));
}

void YourClass::OnMouseMove(UINT nFlags, CPoint point)
{
	if(0xC0DEDBAD != GetMessageExtraInfo())
	{
		//You would ignore the simulated input and do your processing here
	}
	YourBaseClass::OnMouseMove(nFlags, point);
}


Don't forget to convert client coordinates to screen before calling setcursorposition.

Best Wishes,
-David Delaune
GeneralRe: Is SetCursorPos() Calling MouseMove ? Pin
JohnCz27-May-12 8:31
JohnCz27-May-12 8:31 
Questionneed your help,to all programmers!!! Pin
ambreen115324-May-12 0:54
ambreen115324-May-12 0:54 
AnswerRe: need your help,to all programmers!!! Pin
Chris Losinger24-May-12 1:24
professionalChris Losinger24-May-12 1:24 
AnswerRe: need your help,to all programmers!!! Pin
enhzflep24-May-12 1:27
enhzflep24-May-12 1:27 
GeneralRe: need your help,to all programmers!!! Pin
ambreen115324-May-12 1:32
ambreen115324-May-12 1:32 
GeneralRe: need your help,to all programmers!!! Pin
enhzflep24-May-12 1:38
enhzflep24-May-12 1:38 
AnswerRe: need your help,to all programmers!!! Pin
CPallini24-May-12 2:06
mveCPallini24-May-12 2:06 
GeneralRe: need your help,to all programmers!!! Pin
Aescleal24-May-12 2:22
Aescleal24-May-12 2:22 
GeneralRe: need your help,to all programmers!!! Pin
CPallini24-May-12 3:51
mveCPallini24-May-12 3:51 
GeneralRe: need your help,to all programmers!!! Pin
Erudite_Eric24-May-12 4:36
Erudite_Eric24-May-12 4:36 
GeneralRe: need your help,to all programmers!!! Pin
Aescleal24-May-12 6:45
Aescleal24-May-12 6:45 
AnswerRe: need your help,to all programmers!!! Pin
Erudite_Eric24-May-12 4:37
Erudite_Eric24-May-12 4:37 
AnswerRe: need your help,to all programmers!!! Pin
Albert Holguin24-May-12 5:15
professionalAlbert Holguin24-May-12 5:15 
AnswerRe: need your help,to all programmers!!! Pin
jschell24-May-12 8:33
jschell24-May-12 8:33 
AnswerRe: need your help,to all programmers!!! Pin
Vaclav_24-May-12 22:45
Vaclav_24-May-12 22:45 
AnswerUnicorns and Rainbows Pin
jkirkerx25-May-12 8:49
professionaljkirkerx25-May-12 8:49 
Question[SOLVED]: Error Returning CArray Pin
AmbiguousName23-May-12 21:30
AmbiguousName23-May-12 21:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.