473,793 Members | 2,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)HitTest Values.HTTRANSP ARENT;
}
else
{OK, process WM_SETCURSOR, just for this one exception}

}
}
break;

default:
break;
}

if (bDoBase)
{
base.WndProc(re f m);
}
}

Apr 10 '07 #1
0 2132

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

Similar topics

4
5219
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 threw a balloon message: "This application is running in a partially trusted context. Some functionality in the application may be disabled due to
8
19267
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 member function `void Other::DoSomething()': tp2.cc:11: error: `int Base::iX' is protected tp2.cc:29: error: within this context // %< %< ----------------------------------- %< %<
2
55637
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", null); User user = new User (userid); XmlNode rolesNode = user.GetRoles (); rootNode.AppendChild (rolesNode);
3
2372
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 application to my friend who (and only him) has to work with the database tables to edit them he began receiving the following message every time when a new window opens:
5
3086
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 the code into the method of a class I am trying to build, it gives me strange errors: "CS0103: The name 'Server' does not exist in the current context". (Server being a call to Server.MapPath.) I'm working in ASP.NET 2.0 and VS.NET 2005. ...
1
1489
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 client call back to a server-side event. The client-side function for this overloaded method includes a specified control, argument, client-side script, and context. What is "context?"
0
1496
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 the message: "HTTPException was unhandled by user code. Request Not Available in this context." This is the code that it says it doesn't like:
0
1986
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: context". Any suggestions...highly appreciated.
1
3006
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 am using IIS). But i want to make some custom changes on the forms and some functionalites. To do so, i created my own project on Visual Studio 2005, and copied the origanal code folders to my project folder and added those existing items on visual...
0
9671
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10433
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10161
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9035
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.