Archived

This topic is now archived and is closed to further replies.

wise_Guy

SendMessage

Recommended Posts

wise_Guy    122
Hi, I just have a quick question regarding the SendMessage function. To send a message for the left mouse button being clicked, you need to submit both the x and y coords of the mouse, right? but you only get 1 integer to use SendMessage(WM_LBUTTONDOWN, nFlags, *data goes here*); I have tried doing the following: my_point = point.x | (point.y << 16); to try and set the hi/lo words, but that doesn''t work Any suggestions?

Share this post


Link to post
Share on other sites
felisandria    739
Um... first I''d better just ask why you''re using SendMessage. Are you trying to spoof mouse movement?

As for conversion there''s a MAKEPOINTS macro that converts the lparam into a POINT, take a look at its implementation and then just do the reverse, I suppose.

The problem might not be your conversion, did you set the wparam to MK_LBUTTON to reiterate the indication that the left mouse button is down so as not to confuse your app utterly?

-fel

Share this post


Link to post
Share on other sites
wise_Guy    122
Thanks guys ever so much.. Yorvik''s MAKELPARAM works like a treat

Fel - What I need this for: I have my function OnLButtonDown, which places a tile in my level editor. When you drag the mouse, I want to send the LBUTTONDOWN message, so that I don''t have to rewrite my code for both functions... this seemed to be the best way... is there a more "standard" way that I am unaware of?

Anyway.. thanks again!

Share this post


Link to post
Share on other sites
felisandria    739
*blink*

How do you intend to tell the difference between moving the mouse normally and moving the mouse while dragging then?

There are two standard ways, one is to check the mousemove for an LBUTTONDOWN setting as suggested. The other is to process both the button down and the button up command messages for the left mouse button, and set a flag between them, like so:

- User clicks, you process WM_LBUTTONDOWN command and set a m_bDragging flag to TRUE
- User moves mouse, you process according to dragging logic, as the flag is currently set
- User releases, you process WM_LBUTTONUP command and set m_bDragging flag to FALSE

I usually use the second one, because I find it necessary in pretty much all cases to actually do something on WM_LBUTTONUP anyway (fix the position of what I was dragging, etc) so I might as well flip my flag there as well. The other nice thing about this is that I can set the flag without needing the WM_LBUTTONDOWN to fire, in cases like, for instance, wanting to force a placement of a tile when you first introduce it. You don't have to rewrite the button down and up logic either, because when you click to place it will get both the down and up messages and will drop it appropriately.

-fel

Edited by - felisandria on February 1, 2001 11:13:52 AM

Share this post


Link to post
Share on other sites