By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,586 Members | 623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,586 IT Pros & Developers. It's quick & easy.

Getting the State of a Mouse Button

P: n/a
I need to know if the Left Button of the Mouse is clicked in the
WM_NCMOUSEMOVE Notification but this Message doesnt
contain the Mouse Button States as WM_MOUSEMOVE does.
So how can I get them?

Thanks
Nov 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hello Tyron,

You can do that using the MouseDown event, just handle the event and inside
the event handler use something like

if (e.Button == MouseButtons.Right)
{
//right click
} else if (e.Button == MouseButtons.Left) {
//left click
}

Martin.
I need to know if the Left Button of the Mouse is clicked in the
WM_NCMOUSEMOVE Notification but this Message doesnt
contain the Mouse Button States as WM_MOUSEMOVE does.
So how can I get them?
Thanks


Nov 17 '05 #2

P: n/a
<Tyron> wrote in message news:OW**************@tk2msftngp13.phx.gbl...
I need to know if the Left Button of the Mouse is clicked in the
WM_NCMOUSEMOVE Notification but this Message doesnt
contain the Mouse Button States as WM_MOUSEMOVE does.
So how can I get them?
Use the GetKeyState API call in User32, with VK_LBUTTON as the parameter.

Thanks

Nov 17 '05 #3

P: n/a
I cant use events for the Problem i got.
Its kinda hard to explain why, but i'll try:

My goal is to add a "Minimize to Tray"-Button to the caption bar (near
the minimize button)
This button should behave exactly the same like the others do.
So if I press (not click) the left mouse button at the traybutton, it
should get the pressed graphics. If I then move the mouse (and keep
pressing the left mouse button) outside of the button it should get the
unpressed graphic and when I move the mouse inside the button again it
should also get the pressed graphics again.
I don't think I can handle this with events. This has to be done in the
WM_NCMOUSEMOVE Notification (and this notification doesn't contain any
information about the mouse button states like WM_MOUSEMOVE does).
Hello Tyron,

You can do that using the MouseDown event, just handle the event and
inside the event handler use something like

if (e.Button == MouseButtons.Right)
{
//right click
} else if (e.Button == MouseButtons.Left) {
//left click
}

Martin.
I need to know if the Left Button of the Mouse is clicked in the
WM_NCMOUSEMOVE Notification but this Message doesnt
contain the Mouse Button States as WM_MOUSEMOVE does.
So how can I get them?
Thanks


Nov 17 '05 #4

P: n/a
Hello Tyron,

Do you use a context menu on this tray button? In which case you can change
the graphic on the context menus popup event. Come to think of it you could
just create a blank context menu, assign it as the context menu for the
system tray icon and handle the popup event.
I cant use events for the Problem i got.
Its kinda hard to explain why, but i'll try:
My goal is to add a "Minimize to Tray"-Button to the caption bar (near
the minimize button)
This button should behave exactly the same like the others do.
So if I press (not click) the left mouse button at the traybutton, it
should get the pressed graphics. If I then move the mouse (and keep
pressing the left mouse button) outside of the button it should get
the
unpressed graphic and when I move the mouse inside the button again it
should also get the pressed graphics again.
I don't think I can handle this with events. This has to be done in
the
WM_NCMOUSEMOVE Notification (and this notification doesn't contain any
information about the mouse button states like WM_MOUSEMOVE does).
Hello Tyron,

You can do that using the MouseDown event, just handle the event and
inside the event handler use something like

if (e.Button == MouseButtons.Right)
{
//right click
} else if (e.Button == MouseButtons.Left) {
//left click
}
Martin.
I need to know if the Left Button of the Mouse is clicked in the
WM_NCMOUSEMOVE Notification but this Message doesnt
contain the Mouse Button States as WM_MOUSEMOVE does.
So how can I get them?
Thanks


Nov 17 '05 #5

P: n/a
> Hello Tyron,

Do you use a context menu on this tray button? In which case you can
change the graphic on the context menus popup event. Come to think of it
you could just create a blank context menu, assign it as the context
menu for the system tray icon and handle the popup event.


This has nothing to do with the icon in the system tray.
The button is going to be in the upper right corner of the window (in
the non-client area).
E-Mule has that 'Minimize-to-Tray' Button as well.
Nov 17 '05 #6

P: n/a
Have you tried GetKeyState?

"Tyron Madlener" <ne********@v-cm.net> wrote in message
news:e%****************@TK2MSFTNGP15.phx.gbl...
Hello Tyron,

Do you use a context menu on this tray button? In which case you can
change the graphic on the context menus popup event. Come to think of it
you could just create a blank context menu, assign it as the context
menu for the system tray icon and handle the popup event.


This has nothing to do with the icon in the system tray.
The button is going to be in the upper right corner of the window (in the
non-client area).
E-Mule has that 'Minimize-to-Tray' Button as well.

Nov 17 '05 #7

P: n/a
Yep, that helped. Thanks.
Have you tried GetKeyState?

Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.