473,387 Members | 1,641 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.

TrackMouseEvent in C#?

Is there some sample code for this available?
I don't have a clue how to use this function in C#, I found one for C++
though: http://www.codeguru.com/Cpp/misc/misc/article.php/c307

I need the WM_NCMOUSELEAVE Notification and as far as i can see this
function gets me this notification.

Thanks
Nov 17 '05 #1
3 5347
Hi,

You can use the designer to trap the event or you can write it on your own:

//
// 'this' is the form
//
this.MouseLeave += new System.EventHandler(this.Form1_MouseLeave);

private void Form1_MouseLeave(object sender, System.EventArgs e)
{

}

"Tyron Madlener" wrote:
Is there some sample code for this available?
I don't have a clue how to use this function in C#, I found one for C++
though: http://www.codeguru.com/Cpp/misc/misc/article.php/c307

I need the WM_NCMOUSELEAVE Notification and as far as i can see this
function gets me this notification.

Thanks

Nov 17 '05 #2
The MouseLeave Event from the Designer uses WM_MOUSELEAVE.
What I need is to get the WM_NCMOUSELEAVE event (with the function
TrackMouseEvent()).
Hi,

You can use the designer to trap the event or you can write it on your own:

//
// 'this' is the form
//
this.MouseLeave += new System.EventHandler(this.Form1_MouseLeave);

private void Form1_MouseLeave(object sender, System.EventArgs e)
{

}

Nov 17 '05 #3
I tried writing some code to call that function in the Hope that it will
work at the first go - but it didn't :/
Code:

[DllImport("kernel32.dll", SetLastError=true)]
static extern int GetLastError ();

[DllImport("user32")]
public static extern bool TrackMouseEvent(TRACKMOUSEEVENT lpEventTrack);

[StructLayout( LayoutKind.Sequential,CharSet=CharSet.Ansi)]
public struct TRACKMOUSEEVENT {
public long cbSize;
public long dwFlags;
public long hwndTrack;
public long dwHoverTime;
}
and in the C# App Constructor:

TRACKMOUSEEVENT foo = new TRACKMOUSEEVENT();
foo.cbSize = Marshal.SizeOf(typeof(TRACKMOUSEEVENT));
foo.dwFlags = TME_NONCLIENT;
foo.hwndTrack = (long)this.Handle;
bool bar = TrackMouseEvent(foo);
MessageBox.Show(""+GetLastError());

The TrackMouseEvent function fails and returns zero.
So I called (as msdn advised me) GetLastError() to get the error msg and
it returns 998 which means:
ERROR_NOACCESS Invalid access to memory location.

Has anyone a clue what my OS is trying to tell me here?
Nov 17 '05 #4

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

Similar topics

8
by: NeoAsimov | last post by:
Hello, There is what I want to do. I worked on the problem since 6 hours but I had a problem (probably stupid) and I dont know how to resolve it. I need to have an Mouse Event Click when...
1
by: Sheriff | last post by:
Receiving a single mouseHover is simple, just move the mouse over my control and wait. However, following this mouse hover event, if I move the mouse around within the control and once again wait,...
2
by: Eitan | last post by:
Hello, I am creating a new window class based on CWnd. I am placing it on the View (CFormView). How can I get the notification or any other indication that the cursor/mouse is not on this...
2
by: Egbert Nierop \(MVP for IIS\) | last post by:
Hi, I have a class, see below, that needs to be subclassed in a dialog. Inside the dialog (OnInitDialog), I need something like this. ...
4
by: Egbert Nierop \(MVP for IIS\) | last post by:
Hi, I have a CWindowImpl derived class , see below at ***, that needs to subclass simple controls like textboxes. like this...: m_MyControl.SubclassWindow(GetDlgItem(IDC_MyControl).m_hWnd); ...
0
by: lisseut | last post by:
Hi, hope I'm posting to the right forum. I'm using C# under .NET 1.1, Windows XP SP2 I have a form and I've overridden WndProc to print to a text box whenever it receives the WM_NCMOUSELEAVE...
4
by: ThunderMusic | last post by:
Hi, I'm developping a form that renders differently when hovered and trigger some processing when not hovered (leaved). The thing is, when I leave my form and another form from my application is...
2
jamesd0142
by: jamesd0142 | last post by:
Hi im just starting to dabble with windows API and i getting a headache!. Is there any way to find a list of functions available in user32 DLL file? any other info is welcome here... James
5
by: RomeoPapacy | last post by:
I'm currently writing a replacement shell and am suffering from quite dire memory leaks, when running, every time I roll my mouse over the taskbar icon a new window scrolls out revealing the window's...
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: 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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.