473,387 Members | 1,464 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,387 software developers and data experts.

Determine MouseButton state during WM_NCHITTEST

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 form's WndProc method),
but the logic should only be implemented if the left mouse button is pressed.
I am familiar with Windows.Forms.Control.MouseButtons, but that property is
not updated until after the WM_NCHITTEST occurs.

Thanks for any help!
Lance

Sep 5 '07 #1
3 4262
Hi Lance,

The WM_NCHITTEST message is sent to a window when the cursor moves, or when
a mouse button is pressed or released. Other mouse messages are actually
generated from WM_NCHITTEST message based on the mouse position. If you
wanted to check if the user clicked in non-client area of the form, then I
would recommend you to use WM_NCLBUTTONDOWN or WM_RBUTTONDOWN. This should
help you to determine if the non-client click is using the left or right
mouse button.

If you really wanted to check mouse button in WM_NCHITTEST, I recommend you
to p/invoke GetKeyState() win32 API with VK_LBUTTON and check if the return
value is not zero.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 6 '07 #2
Hi Jeffrey,

I was able to get it to work based on your information. Thanks so much for
your help.

Lance

Sep 6 '07 #3
Hi Lance,

Thanks for your feedback.

Also, based on the further discussion with Raymond Chen. The return value
of WM_NCHITTEST should not be dependent on volatile state like whether
mouse buttons are down.

The purpose of WM_NCHITTEST is to figure out how your window is arranged.
This is done in response to many things, not just input. For example, an
app might call WindowFromPoint, and the window manager will send
WM_NCHITTEST to figure out which window lies at a particular point on the
screen.

So, WM_NCLBUTTONDOWN or WM_RBUTTONDOWN should be used here. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 7 '07 #4

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

Similar topics

2
by: Hunter Hillegas | last post by:
I cannot determine what character is stored in a varchar... For instance: thedonnaholics=# select state from mailing_list where rec_num = 7; state ------- (1 row) If I then execute:
1
by: mdb | last post by:
I want to determine whether the SHIFT key is depressed, but NOT during a key up/down/pressed event. How can I do that?
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
0
by: Maciek | last post by:
Hi When I set Session state mode to StateServer (IIS 6.0; windows2003; .NET 2.0) in my application, I have recived this message:...
5
by: yancheng.cheok | last post by:
hello, may i know how i can determine whether a pointer is pointing to an array or a single item during runtime? this is because in certain situation, i need to determine whether to use delete...
7
by: semedao | last post by:
Hi all, I view many posts about this issue , the connected property does not tell us the current status of the socket. based on couple of suggestions of msdn , and some article here , I try to...
0
by: NonNB | last post by:
Hi I have a user control which the user can "drag" across the screen (I'm not using "real" .NET drag drop - instead a single click flavour, where the control is drawn at the mouse position). ...
9
by: | last post by:
I am interested in scanning web pages for content of interest, and then auto-classifying that content. I have tables of metadata that I can use for the classification, e.g. : "John P. Jones" "Jane...
2
by: Trmbne2000 | last post by:
Hi, I'm developing a service provider listing service. Part of the specification is to have both an address and a 'seasonal address' for each listing. The database stores the start and end months...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.