Getting the State of a Mouse Button

  • Thread starter Thread starter Tyron
  • Start date Start date
T

Tyron

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
 
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?

Use the GetKeyState API call in User32, with VK_LBUTTON as the parameter.
 
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,

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.
 
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.
 
Have you tried GetKeyState?

Tyron Madlener said:
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.
 
Back
Top