Archived

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

wise_Guy

CWnd->SendMessage

Recommended Posts

wise_Guy    122
Okay... here is an MFC problem for all the gurus out there: If I use Send Message to send a WM_LBUTTONDOWN message, where do I place the Y coordinate?
  
this->SendMessage(WM_LBUTTONDOWN, nFlags, point.x);
  
is what I have to work with. I think I may have to use HI/LO words.. but i am unsure how to set them I have tried as such UINT place; place |= point.x; place |= (point.y << 16); but to no avail... could someone correct me as to the errors of my ways? thanks

Share this post


Link to post
Share on other sites
Houdini    266
There are a few different ways you can do it. You can either pass it in one unsigned 32bit value using MAKELPARAM and retrieve those values using HIWORD and LOWORD, or you can pass a pointer to a Point structure containing those values (as long as that structure is not local, unless of course you only use SendMessage and never PostMessage) and then typecast it back to a Point structure in your function.


- Houdini

Share this post


Link to post
Share on other sites
Syntax    122

LRESULT SendMessage(
UINT message,
WPARAM wParam = 0,
LPARAM lParam = 0 );

SendMessage(WM_LBUTTONDOWN, (WPARAM) point.x, (LPARAM) point.y);

-Lucas

Share this post


Link to post
Share on other sites
wise_Guy    122
Syntax / Lucas:

LRESULT SendMessage(
UINT message,
WPARAM wParam = 0,
LPARAM lParam = 0 );

While this _is_ the syntax, the wParam is used for varius flags, not the x/y position... so yes I need that MAKELPARAM macro.

And everyone - sorry for posting twice... but I didn''t see those little numbers at the bottom of the screen (1 2 3 4 ) and so I thought my message didn''t really get posted... even when I check all messages in the past 60 days i only got i small page....

Share this post


Link to post
Share on other sites
Shannon Barber    1681
Actually its a Win32 question, all CWnd::SendMessage(...) does is SendMessage(m_hwnd, ...)

And you may want to use PostMessage not SendMessage; SendMessage call the winproc directly, PostMessage adds the message to the queue (which is the expected behavior).

Share this post


Link to post
Share on other sites