Click here to Skip to main content
15,943,751 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
I have created a SDI application and overwritten the message map
.I am getting the control in
afx_msg void OnLButtonUp(UINT nFlags, CPoint point){....}
afx_msg void OnLButtonDown(UINT nFlags, CPoint point){....}

while clicking the left button inside my application and releasing the click.

but here is my problem,
If click the left button outside of my application[say in desktop] and releasing the click inside my application then OnLButtonUp() is not getting called.Any Idea why? and if its not possible them please give some alternate solution.

Thanks in advance.

This behavior is by design ;)
It has something to do with allowing the user to drag things from one application and drop them on another.

There are other mouse messages that may do the trick for you. You may start here:

WM_MOUSEMOVE[^]; you can check the flag MK_LBUTTON and see when it is turned off.

Hope this helps,

Share this answer
shankha2010 17-May-12 8:41am    
Thanks for the response,

somewhere I found
put set SetCapture(); inside ON_WM_LBUTTONDOWN()
and ReleaseCapture(); inside ON_WM_LBUTTONUP()

but in my case ON_WM_LBUTTONDOWN() is occuring outside.
so is there any trick I can do with this?
like writing SetCapture(); in the OnInitialUpdate()??

if possible,then please send that code snippet.
Pablo Aliskevicius 17-May-12 9:21am    
Pablo Aliskevicius - 7 secs ago
I'm sorry, I can't give you a snippet, since I don't own that code.
Basically, you'll have to play and see what happens.
Best wishes,
shankha2010 23-May-12 2:43am    
thanks a lot.
I found that in such cases instead of coming the event to onMouseUp its coming to onMouseMove and its easy also to distinguish when its coming the onMouseMove due to the above said reason.[by switching a flag ON in onLButtonDown and checking it to onMouseMove]

However thanks a lot for this support :)
Don't know if it suits your needs or not, but you could try installing a global hook and catch mouse events and react on them, like relay the needed messages someway to your own process.
See this[^] for starters.
The WindowFromPoint[^] function might come in handy too...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900