473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Getting the State of a Mouse Button

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
7 17104
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
<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
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
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
> 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
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
Yep, that helped. Thanks.
Have you tried GetKeyState?

Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John Champaign | last post by:
Hi all, I'm working on an educational applet for a child with special needs. He's got a bit of a trick to make my life more difficult... To interact with the applet he needs to click on...
8
by: Harlin Seritt | last post by:
I have the following script. Two widgets call the same function. How can I tell inside of the called function which button called it?: def say_hello(): print 'hello!' print widget root =...
1
by: Weston C | last post by:
I'm working on a small javascript application where I'd like to get one behavior when a user clicks on an image (image swap), but when they simply hold down the mouse button for a second, they get...
4
by: riscy | last post by:
I have a button with mouse_click event when pushed. However it does not generates mouse down event. To fix this I could poll the mouse state every 10mSec and see if the mouse button remains down...
1
by: neeraj | last post by:
Hi people's I developed one MDI application with one MDI form and 2 child forms, form. Border style of first child forms set as Fixed3D and Window State set as normal (like dialog Box) and...
4
by: jmdeschamps | last post by:
why is the button sunken when called through a bind method, and not with the command attribute? Thank you! ## Cut'nPaste example from Tkinter import * import tkMessageBox class...
2
by: mwatcher | last post by:
Hi all, I am using .net 2.0. How can I get the current state of the mouse button (e.g.. Mouse Button Right is pressed). I'm not in a mouse event handler routine. What I wanna do is to check if...
8
by: rahulnag22 | last post by:
I have created a button widget with a button click binding. The button initially has a state=disabled. I can see the greyed out version of the button in the GUI. But If I click on the button it...
3
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
Is there any way to determine the state of the mouse buttons during a WM_NCHITTEST message? I have a situation where I need to perform custom logic during a WM_NCHITTEST messsage (by overriding a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.