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

Windows Forms - Is there a way to determine the "context" in which WM_NCHITTEST Message is being used?

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).

Depending on whether the user has "picked up" the control or not, I
need the following behaviour

1) When the control is being dragged, the control must not intercept
any mouse events (i.e. so user can drop the control / other forms and
controls "underneath the control can intercept the MOUSE messages),
EXCEPT

2) However, even when being dragged, I still need control over the
mouse cursor from the control

Rather than manually re-raising events for all the mouse messages on
the control, returning WM_NCHITTEST as HTTRANSPARENT when being
dragged does the trick for part 1)
However, unfortunately, I no longer have any control over the mouse
cursor - my control no longer receives WM_SETCURSOR when being
dragged, as it would seem that since the control's "HITTEST" is
HTTRANSPARENT, that the WM_CURSOR's are being passed underneath as
well (kind of obvious I guess :-)

Does anyone know if I can be more 'selective' about the HITTESTing.
Unfortunately, it seems LPARAM contains only the coords, and no other
flags.

Otherwise I guess I will need to trap and re-raise all Mouse Events to
achieve the above
(I guess I could also set the cursor on the 'underneath' controls /
forms, but this isn't ideal / encapsulated)

* Alternatively, can I force a WM_CURSOR message from the
WM_NCHITTEST?

Thanks in advance

Stuart
protected override void WndProc(ref Message m)
{
Boolean bDoBase;
bDoBase = true;

switch (m.Msg)
{
case WindowsMessages.WM_SETCURSOR:
Cursor.Current = // One of our custom cursors,
this works fine, but doesn't get called once we have returned
HTTRANSPARENT from WM_NCHITTEST;
break;

case WindowsMessages.WM_NCHITTEST:
// If user is dragging, we don't want this control to intercept
mouse clicks etc, however we DO still want to process the WM_CURSOR
messages so we can control which cursor to use
if (m_bDragging)
{
bDoBase = false;
// Pseudo Code
if ("CONTEXT OF THE HIT TEST" <"CURSOR")
{
// i.e. I'm transparent, don't send mouse
events to me
m.Result =
(IntPtr)HitTestValues.HTTRANSPARENT;
}
else
{OK, process WM_SETCURSOR, just for this one exception}

}
}
break;

default:
break;
}

if (bDoBase)
{
base.WndProc(ref m);
}
}

Apr 10 '07 #1
0 2101

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

Similar topics

4
by: john bailo | last post by:
I wrote a c# program that does some file manipulation on a remote server. Testing it from my workstation, it ran fine. When I copied it to another server, and ran it from there, on load, it...
8
by: H. S. | last post by:
I am getting this error if I try to compile the file demarcated below. What I am missing here? I am using g++ (GCC) 3.3.5 (Debian 1:3.3.5-8). {tp2}> g++ -ansi -g -Wall tp2.cc -o tp2 tp2.cc: In...
2
by: Eirik M. | last post by:
Hi, I've got the following piece of code that's causing me a bit of a problem XmlDocument doc = new XmlDocument (); XmlNode rootNode = doc.CreateNode (XmlNodeType.Element, "usersettings",...
3
by: Dmitri Shvetsov | last post by:
Hi, Maybe somebody knows why it's happening? I wrote a C# Windows Application working with the remote database through a DataSet. It works cool from my computer but when I gave this...
5
by: | last post by:
Hoping someone can help with a simple but puzzling problem. I have some code that I want to build as a class method. The code works fine when I embed it in Page_Load. But when I try to generalize...
1
by: Roy | last post by:
From the MS site: NAME: ClientScriptManager.GetCallbackEventReference (Control, String, String, String) DESCRIPTION: Obtains a reference to a client-side function that, when invoked, initiates a...
0
by: Blasting Cap | last post by:
I had some old code set to throw an email to me when a user hit an exception. VS 2003 worked fine with the code, VS 2005 when I run it in debug mode pauses over the code each time, and gives me...
0
by: Reader | last post by:
On a windows form, there is TableLayoutPane. I 1) Increase size of form 2) Increse size of table 3) Add a row in the table 4) Save I receive exception "Value cannot be null. Parameter name:...
1
by: avecreep | last post by:
Hi, i was trying to find a web application and i found one open source on the internet. i put the code folders on the root folder and when i tried to acces via web browser it all worked fine ( i...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.