|
Has anybody found a way to implement a global message trap, so that no matte what window/control has focus, and no matte where the mouse is pointing, you can listen to the mouse wheel roll messages?
I have seen mouse driver settings that say send messsages to the window being pointed at, rather than the window with focus. I want to develop several controls that respond to mouse wheel events without having focus, and I dont want to set focus to them just so that I can "hear" the mouse wheel messages either.
Any input, pardon the pun, would be great.
Nursey
|
|
|
|
|
It's exactly the same as a keyboard hook, except it looks at mouse messages. Create an implementation of IMessageFilter and call Application.AddMessageFilter[^] to start it. All you have to do is add the code to watch for the mouse wheel message, documented here[^]. Look through the Windows C++ header files (*.h) for MW_MOUSEWHEEL to find what the constant value is for the message.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Please note that what Dave said is only for the message pump for your application. You could also set Control.Capture to true to capture mouse events that you could handle either in WndProc or even the events that are exposed on the Control on which you set its Capture property to true .
You could also implement a system hook, but this is very dangerous and not something to be taken lightly - you're hooking every group of messages for the entire platform and your code has to be clean, efficient, and must be unloaded and gracefully fail should any problems occur. There are several articles here on CodeProject about that. Search for SetWindowsHook to find articles on this site.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
Thank you both for your advice, that was just what I needed to hear.
I've done quite a bit with subclassing in the past, but as its been a while, and as I would like to know if there is a more ".NET" like way in which this should be done, then it was well worth asking.
If I hook into the application message pump, then presumably, as controls run "in process" I will be able to hook into every Windows Forms App that utilises my controls?
Many thanks once again.
Nursey
|
|
|
|
|
cnurse wrote:
If I hook into the application message pump, then presumably, as controls run "in process" I will be able to hook into every Windows Forms App that utilises my controls?
Most likely, yes. It greatly depends on the container application, though. I don't forsee you having any
The ".NET" way of things has nothing to do with Windows Forms or anything else, actually. .NET is Microsoft's brand of the CLI, or Common Language Infrastructure. Windows Forms is part of the BCL and actually encapsulates the Common Controls (like Edit, Rich Edit, Static, etc.) and many, many other Windows APIs and other Win32 APIs. Handling messages in this way is nothing different from what Microsoft is doing. That's why the Control class defines the WndProc method (among other Windows Platform-related members) - not just so you can use it but so that they can use it to encapsulates the Common Controls.
Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
|
|
|
|
|
well i want to open my window in full screen mode. i mean only client area should be displayed and also i want to change the resolution of computer through code .. like when my application runs it change the computer resolution to my desired resolution is it possible in c#.
what comes in my mind as a biggner programer .. i set size to 810 x 610 and set location manually to -10,-10 but i don't think it is a good and proper solution so if there is any other way to do this please tell me.
In short words i want that my application covers the whole screen area no metter what resolution is been used
|
|
|
|
|
How about setting the form border to none and size to maximize?
Gary Thom
DYNAMIC LINKING ERROR: Your mistake is now everywhere.
|
|
|
|
|
Here is what I do in OnLoad event of the form:
FormBorderStyle = FormBorderStyle.None;
TopMost = true;
Rectangle rect = Screen.PrimaryScreen.Bounds;
Location = new Point(0, 0);
Size = new Size(rect.Width, rect.Height);
and it works perfectly for me.
|
|
|
|
|
Umair Ahmad khan wrote:
like when my application runs it change the computer resolution to my desired resolution
Don't. Your user might not have enough privileges to accomplish this operation. Besides, it is considered a bad practice to programaticaly change user's settings.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Hello,
I have problem with filling the data table. The error is in the code below.
[code]
private void frmStudent_Load(object sender, System.EventArgs e)
{
//Setup the connection string, data adapter, and commanbuilder.
//Fill the data table
OleDbConnection m_cnADONetConnection = new OleDbConnection();
OleDbDataAdapter m_daDataAdapter = new OleDbDataAdapter();
DataTable m_dtStudents = new DataTable();
m_cnADONetConnection.ConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdb;Persist Security Info=False";
m_daDataAdapter = new OleDbDataAdapter("Select * student",m_cnADONetConnection);
OleDbCommandBuilder m_cbCommandBuilder = new OleDbCommandBuilder(m_daDataAdapter);
m_daDataAdapter.Fill(m_dtStudents);//Error - An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
m_cnADONetConnection.Open();
}
[/code]
I would be happy if anyone knows how to solve this problem.
Many thanks in advance
Steve
|
|
|
|
|
Hi Steve,
My first suggestion would be that you check the syntax of your SQL statement.
"Select * student"
I don't use Access very much, but in SQL Server you can't miss out 'FROM'.
Rich
|
|
|
|
|
Thanks for your reply. I feel stupid for missing the from keyword of.
Thanks
|
|
|
|
|
Hi, all!
I'm working on a control library which now contains four independent controls. This control library is one dll indeed. The question is how to do so that each control would have its own icon instead of standard one(undefined) because when I trying to set
[ToolboxBitmapAttribute(typeof(BT.WinUI.Controls.CWSplitter), @"CWSplitter.bmp")]
they all then will be with undefined icon. But I was seen a dll where this is done. It has 9 controls and each with its own icon...
Thanks.
Regards,
@LEXX.
|
|
|
|
|
Did you apply the ToolboxBitmapAttribute to each control class?
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hello,
i have developed a web service where the client sends to the server a signed xml document signed with "Infopath". When the server receives the document it is impossible fot him to valiadate the signatures. Here is my code:
(doc is a XmlDocument)
<br />
XmlNodeList nodeList = doc.GetElementsByTagName("Signature");<br />
SignedXml[] signatures = new SignedXml[nodeList.Count];<br />
<br />
for(int i = 0; i < nodeList.Count; i++)<br />
{ <br />
signatures[i] = new SignedXml();<br />
signatures[i].LoadXml((XmlElement)nodeList[i]);<br />
if (!signatures[i].CheckSignature())<br />
validSignatures--;<br />
}<br />
The xml document has been signed with a valid X509 certificate.
thank you for your help!
|
|
|
|
|
Hi could anyone give me some source code or tutorials on generating product keys in c#??
Also need advice. I want to generate a product key and have some way to detect if the licence count is at its maximum. So therefore the program can not be installed again.
How do I do this??
Thanks.
|
|
|
|
|
Product keys sources' usually aren't given away.
To make one, you will need to create your own algorithm.
Aaron Eldreth
TheCollective4.com
My Articles
I hereby boycott this poll. Really....
- Leppie
|
|
|
|
|
|
Here is a good Article and code.
Applications Licensing using the .NET Framework
By Kenn Scribner
http://www.developer.com/net/net/article.php/11087_3074001_1
|
|
|
|
|
Is it possible to make customized SaveFileDialog using C#? please guide
|
|
|
|
|
Hi all!
I'm trying to write a method that reads an object. If the object can't be read, the stream should return to it's original state. This seems to be easily achievable by getting the stream's position before attempting to read and to set is back to the same position if reading would fail. However, this does not work out:
public void ReadFromStream(StreamReader stream)
{
long safePos = stream.BaseStream.Position;
string line = stream.ReadLine();
string[] keyAndName = line.Split(new char[]{' '});
if(keyAndName[0].Trim() != keyWord)
{
stream.BaseStream.Position = safePos;
System.Windows.Forms.MessageBox.Show(stream.ReadLine());
throw new Exception();
}
}
Should I return the stream C++-style? I wouldn't think so since a stream is a reference type in C#...
I don't have a clue why this fails. FYI: the value of safePos and stream.BaseStream.Position always remain the same, in my case 16384.
Thanks for any help!
Jochen
|
|
|
|
|
You might want to try wrapping your stream with BufferedStream
BufferedStream bstream = new BufferedStream(stream);
and read from it. This will allows you to call Seek to reposition the pointer.
|
|
|
|
|
I can use the Seek method on the Basestream property. However, I cannot get the exact position in my stream, since that property only returns positions which are multiples of the buffersize. Using DiscardBufferedData() does not have any influence here...
|
|
|
|
|
I am porting an enterprise level 3-tier C++ application to C# with a tight timeline. I am confused with the database jargon in .net Can somebody advice me on which objects/wizards can satisfy following requirements:
1. Compatibility with multiple database vendor (Oracle and MS SQL to start with)
2. Transactional control
3. Ability to fetch XML from query results
4. Ability to operate on views and execute stored procedures
Can some expert guide me?
|
|
|
|
|
Hello,
I want a C# code that I can use to open the CD driver.
thanks
|
|
|
|