How to Recognize mouse Click on StatusBar?
-
Friday, February 27, 2009 1:28 PMHi,
Does any one have an idea of how I can recognize mouse clicks on Status Bar Panes(indicators) That I created in the MainFrame? I do know how to get the coordinates of the panes.
Thanks
sft
Answers
-
Friday, February 27, 2009 1:45 PMModerator
If your statusbar does not have style WS_EX_NOPARENTNOTIFY then you can handle WM_PARENTNOTIFY message. Please have a look in MSDN to find out details. Also if working with MFC then there is a handler function called OnParentNotify. Parent windows are notified of mouse clicks on child windows if above style is not given. Hope this helps!
Then you can use functions like GetCurrentMessage(MFC) or GetMessagePos(SDK) to retrieve mouse position when this event happened. Make sure to call this from an event handler. Then retrieve item rects and check whether mouse point is within any of those rects.Another option is to sub class status bar if possible then handle clicks here. Searching will help.
VC++ Developer http://nibuthomas.wordpress.com- Marked As Answer by Software2007 Friday, February 27, 2009 2:25 PM
All Replies
-
Friday, February 27, 2009 1:45 PMModerator
If your statusbar does not have style WS_EX_NOPARENTNOTIFY then you can handle WM_PARENTNOTIFY message. Please have a look in MSDN to find out details. Also if working with MFC then there is a handler function called OnParentNotify. Parent windows are notified of mouse clicks on child windows if above style is not given. Hope this helps!
Then you can use functions like GetCurrentMessage(MFC) or GetMessagePos(SDK) to retrieve mouse position when this event happened. Make sure to call this from an event handler. Then retrieve item rects and check whether mouse point is within any of those rects.Another option is to sub class status bar if possible then handle clicks here. Searching will help.
VC++ Developer http://nibuthomas.wordpress.com- Marked As Answer by Software2007 Friday, February 27, 2009 2:25 PM
-
Friday, February 27, 2009 2:28 PM
Thanks for the quick response. I got it to recognize the click in CMainFrame Class by overriding PretranslateMessage(). The trick now is that I would like to be able to recognize the clicks on the MainFrame Status bar in my CView class...
I appreciate the help.
Thanks
sft

