|
The question is not clear to me, but let me answer with what I think the question is.
An OnMouseMove handler is called when the mouse is moved over a window.
When SetCursorPos is called, it does not normally call OnMouseMove .
But if the new cursor position as a result of calling SetCursorPos is over the window for which the OnMouseMove handler is created, then it will be invoked.
If that is the case, you will need to set a flag before calling SetCursorPos and then check this flag inside OnMouseMove to distinguish between manually moving the mouse and calling SetCursorPos .
Remember to reset this flag inside OnMouseMove .
|
|
|
|
|
Hello
you got it right.
I am facing the same scenario.
Let me try your way.
Thanks & Regards
Yogesh
|
|
|
|
|
Hello
As U suggested that I need to set a flag before calling setCursorPos to check on MouseMove. Suppose If this flag satisfies the condition on MouseMove that movement is through SeCursorPos then it will return from there and then how will i reset tht flag on MouseMove.
Here is sample Code for this:
void CMarkWnd::OnMouseMove(UINT nFlags, CPoint point)
{
if(GetCapture() != this) return;
SetCursorPos(x,y)
CWnd::OnMouseMove(nFlags, point);
}
Thanks
Yogesh
|
|
|
|
|
Please check the lines in bold.
That should do it.
void CMarkWnd::OnMouseMove(UINT nFlags, CPoint point)
{
if (mouseFlag)
{
mouseFlag = false;
return;
}
if(GetCapture() != this) return;
mouseFlag = true;
SetCursorPos(x,y)
CWnd::OnMouseMove(nFlags, point);
}
|
|
|
|
|
Hello.
I tried as u suggested but still Mouse is keep on Moving on my First move.
Thanks
Yogesh
|
|
|
|
|
Try to debug and find out what is happening.
|
|
|
|
|
I got it. Its Working now.
Thanks Sir ji.
Thanks David For your Info also.I will try your way too.
Regards
Yogesh
|
|
|
|
|
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:
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())
{
}
YourBaseClass::OnMouseMove(nFlags, point);
}
Don't forget to convert client coordinates to screen before calling setcursorposition.
Best Wishes,
-David Delaune
|
|
|
|
|
This is definitely the best approach.
I wish I could rate your post.
JohnCz
|
|
|
|
|
I have to Write Program code in C++ for car Parking system using queues ,In which any VIP car is given Priority,The code should contain some simple graphics also..
|
|
|
|
|
|
Listen here you.
This is the third time I have seen this 'question' posted.
You have not received any answers yet because you refuse to observe the forum guidelines. You will continue to receive no help until your method of enquiry improves.
Some suggestions:
1. Work out what you're trying to do
2. Work out how you intend to do this
3. Implement this plan in code.
You should NOT post a question on CodeProject when it relates to point 1.
Questions that ask about how to realize point 3 will be most favourably answered.
My 1
Consider the following contrived questions:
Q1: "I have to build a shed, with a window and shelves. It should not be very basic."
Q2: "I am building a shed with shelves. I have selected part# XXX to fix the shelves to the wall. I am having trouble attaching this part to the walls with nails. I am trying YYY, is this the correct way to use part XXX?
Is there a better way for me to attach the shelves to the walls?"
|
|
|
|
|
ok leaving this forum,i dont have time to read the guidelines,,,i need urgent help,which is not seen yet in this forum..
|
|
|
|
|
Good!
If your Lordship had taken time to read the guidelines, he would have realized that this forum does NOT supply 'urgent help'
Thanks for giving us the chance to ensure your precious time wasn't wasted, it's always a pleasure serving ingrates..
|
|
|
|
|
Sorry, I'm firmly contrary to giving higher priority to VIP cars.
Veni, vidi, vici.
|
|
|
|
|
|
Bad boy.
Veni, vidi, vici.
|
|
|
|
|
You forgot urinating on the door handles. Always makes me laugh!
==============================
Nothing to say.
|
|
|
|
|
At my age I'm not sure my pressure or aim is up to that. I'm off to the pub later, I'll try it on the way home and text y'all from the cells when I find out how it works
|
|
|
|
|
You useless arse. Who the hell employed you to write code.
And if you are still at college, change courses, you are totally incapable of becoming a programmer.
==============================
Nothing to say.
|
|
|
|
|
Good luck with that!
|
|
|
|
|
ambreen1153 wrote: have to Write Program code in C++ for car Parking system using queues ,In which
any VIP car is given Priority,The code should contain some simple graphics
also..
1. Learn basic C++ programming
2. Learn basic GUI programming in C++
3. Learn how to design an application
4. Learn how to build a queue that supports prioritization
5. Put steps 1-4 together.
6. Unit test 5.
|
|
|
|
|
Is this graphics simple enough?
|
|
|
|
|
That post came in with pure hope, optimism and joy.
I wonder what sort of fantasy dream or vision the poster was expecting from this forum. It reminds of those people that walk around and always ask if you have an extra cigarette.
I guess in the unicorn world, everyone would of pitched in to write the program, and we can all eat candy corn, or simply feed off the rock candy mountain.
I know the poster left with a dead unicorn and a rainbow of fire.
The only thing missing was delete your bookmark on the way out.
Thanks for the humor today
|
|
|
|
|
hello guys... I am trying to return CArray which I create locally in a function. It simply caontains names. Now this array will be modified by other functions. Here is what it looks like
CArray<CString> CMainDlg::GetNames()
{
CArray<CString> arrNames;
arrNames.SetSize(10);
arrNames.SetAt(0, "Ali");
arrNames.SetAt(1, "Salman");
arrNames.SetAt(2, "Zahid");
arrNames.SetAt(3, "Mehmood");
arrNames.SetAt(4, "Tariq");
return arrNames;
}
But the compiler is showing me this error stating - Error C2248: Can not access private member of class CObject . Whats wrong with this code? Thanks for input.
This world is going to explode due to international politics, SOON.
modified 24-May-12 5:17am.
|
|
|
|