|
show about "AddMessageFilter" of Aplictaion class
maybe is parallel function in Control class
|
|
|
|
|
Ok, I am using a global hook, and I am wondering how I can keep the keys from sending to the active program.
I searched around the net and CodeProject and I just can't figure it out. I'm not terribly familiar with WindowsAPI stuff.
Thanks in advance.
-- modified at 19:33 Friday 17th February, 2006
|
|
|
|
|
You just figured it out? So, what is your problem?
-- modified at 19:23 Friday 17th February, 2006
|
|
|
|
|
Just *can't* figure out.
Why is it that we always leave out the mosti mportant words? haha.
|
|
|
|
|
This might help: http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.addmessagefilter.aspx[^]
<br />
static void Main() <br />
{<br />
Application.AddMessageFilter(new TestMessageFilter());<br />
Application.Run(new Form1());<br />
}<br />
<br />
public class TestMessageFilter : IMessageFilter <br />
{<br />
public bool PreFilterMessage(ref Message m) <br />
{<br />
const int WM_KEYDOWN= 0x0100;<br />
if (m.Msg==WM_KEYDOWN) <br />
{<br />
MessageBox.Show("KeyDown hitted"); <br />
}<br />
<br />
return false;<br />
}<br />
}<br />
<br />
-- modified at 19:54 Friday 17th February, 2006
|
|
|
|
|
What type of hook are you using? A really global hook that captures all keyboard events from the whole system, or a hook that only applies to one application? Maybe you can show us a bit of code?
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
It is a global keyboard hook. I am using the Kennedy.ManagedHooks DLL from this site. I enable it with a hotkey, and disable it the same way.
public Form1()<br />
{<br />
Form1.RegisterHotKey(this.Handle,this.GetType().GetHashCode(), 8, (int)'P');<br />
InitializeComponent();<br />
keyboardHook = new Kennedy.ManagedHooks.KeyboardTracking();<br />
keyboardHook.KeyboardEvent += new Kennedy.ManagedHooks.KeyboardTracking.KeyboardEventHandler(keyboardHook_KeyboardEventExt);<br />
<br />
}<br />
protected override void WndProc(ref Message m)<br />
{<br />
if (m.Msg == 0x0312)<br />
if (keyboardHook.IsHooked)<br />
{<br />
keyboardHook.UninstallHook();<br />
input = false;<br />
textBox4.Text = "";<br />
}<br />
else<br />
{<br />
textBox4.Text = "";<br />
keyboardHook.InstallHook();<br />
input = true;<br />
}<br />
base.WndProc(ref m);<br />
}<br />
private void keyboardHook_KeyboardEventExt(Kennedy.ManagedHooks.KeyboardEvents kEvent, Keys key)<br />
{<br />
bool shi;<br />
if(keyboardHook.ShiftPressed == true)<br />
shi = true;<br />
else<br />
shi = false;<br />
if(kEvent == KeyboardEvents.KeyDown){<br />
string msg;<br />
if(shi == true)<br />
msg = key.ToString();<br />
else<br />
msg = key.ToString().ToLower();<br />
textBox4.Text += msg;<br />
}<br />
}<br />
I think that covers all the relevant code from my end of the application. If there are any questions about what anything does more specifically, I can answer those. The Hotkey works fine, and I am planning to add the message filter or whatever when it hotkeys in and remove it when they hotkey out of the hook, obviously. Thanks for the help thus far.
|
|
|
|
|
Well, in the "real" global hook implementation I did in C++, years ago, the solution is simple. You just don't pass the keystroke message up the hook chain. But I don't see a way to do that, or more to the point NOT do that, using this library. At least it's not obvious in the code you've posted.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Also, I am using WH_KEYBOARD_LL to hook, if that helps out more.
|
|
|
|
|
Ok, I am just going to use blockinput() I think. It blocks the mouse too, but oh well.
|
|
|
|
|
All you need to do to eat the key message is NOT call the CallNextHookEx function in your KeyboardProc handler. It's that simple...
LowLevelKeyboardProc Function[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 9:33 Saturday 18th February, 2006
|
|
|
|
|
Thanks! I'll go mess around with my hooking code.
|
|
|
|
|
hi all
can anyone tell me how to import a flash file into a .NET winForm ? please suggest appropriate class libraries.
thanks
|
|
|
|
|
Hi!
I want to compose a large UserControl of many sub-controls. These children may also be composed of many other controls.
All the childs and grandchilds are not supposed to handle Click events themselves. How can the event be propagated to the parent without subscribing to the Click events of all children and grandchildren and grandgrandchildren an so on?
Thanks,
Eric
|
|
|
|
|
Please excuse my ignorance on this whole .NET thing but I guess everyone in this field eventually gets around to it...
From what I understand, Windows Forms are the next generation of MFC designed for use in a .NET, managed code environment. Is that correct?
Does this mean I have to write managed code to use 3rd party api's that are built on Windows Forms (i.e., Dundas Chart, Gauge and Diagram products)?
Or, can I continue to write unmanaged code and still utilize Windows Forms based api's in C++ code? In other words, can I use the Dundas products in unmanaged C++ code?
Thanks in advance!
Bob
|
|
|
|
|
If the component is a managed code class library, then no you can't use it directly from unmanaged code. You'd have to go through a COM to get at the managed classes, if those classes are exposed to COM.
Exposing .NET Framework Components to COM[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I was wondering how much work is involved on the developer's side to convert an application to calling WinHelp to HTML (or Web) Help.
Are there some standard steps a programmer should go through to ensure this transition is clean and works properly? This is for a .NET environment.
If you've been through this, any information would be helpful.
Thank you,
ellenu
|
|
|
|
|
need help where to download a free full version of FlexCell 2.0 .net framework..... really appreciated if you can provide a link where i can download it for free...
tnx tnx tnx and more power...............
|
|
|
|
|
|
I'd love to hear from anyone with an opinion on how to go about resolving the problem below:
I have a Web Service that allows for files to be uploaded. Because of the default limitation of 4MB in parameters, I allow repeated calls to the file upload function sending chunks of the file at a time. The Web Service then appends the file together at the server end. All works perfectly when running the Web Service on my computer, but when running the Web Service on a server (of which I am an Administrator) there is an issue.
In my Test program that calls the Web Service I setup Authentication:
l_wsService.PreAuthenticate = True
l_wsService.Credentials = CredentialCache.DefaultCredentials
My first call to the file uploading function works successfully. It's the second call to the same function that fails with the error "The request failed with HTTP status 401: Unauthorized". The program never gets inside the function the second time, failing on this error before it reaches the function. After the first call I reload one parameter with the next chunk of the file but don't change anything to do with the service or it's authentication settings.
When I have a file small enough not to break into chunks I can upload it and make subsequent calls to different functions within this same Web Service without a problem. When I have multiple small files the uploading of the second file fails.
My questions are:
How can I get this to work?
If this is a security problem then why does it only occur on the second call to this one function?
Regards,
Paul
-- modified at 20:14 Tuesday 14th February, 2006
|
|
|
|
|
Worked out the answer:
l_wsService.PreAuthenticate = False
It seems to go against everything that I have read on other websites, but it works.
I'd still love for someone to explain exactly why.
Regards,
Paul.
|
|
|
|
|
What is the windows based equivalent to System.Console.WriteLine? I read somewhere (but now cannot find where!) that when your are developing a Windows Application, you should avoid using System.Console.WriteLine and use something else instead.... what would this be? I want something very simple that I can quickly use just like System.Console.WriteLine.
Why I am asking...I am learning C# but prefer to learn using C# project that are Windows Applications. The examples in books use System.Console.Writeline. The code might contain a bunch of writeline statements for showing your results.
I know I could change the C# Output Type temporarily to Console Application and continue to use the System.Console.WriteLine. This solves my problem, but not in the way I would like to solve this. I thought there was some windows-based equivalent to System.Console.Writeline.
|
|
|
|
|
Debug.WriteLine() is what you're looking for. The output will only show up on any TraceListener or the Output window in Visual Studio.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I have a Windows Form in C# that I'm hosting an activeX control in, which the dev env has automatically created the interop dll for. Everything works fine however there is a security issue that I'd like to close.
One of the properties on the ActiveX is a write-only BSTR that you provide a password. The interop layer exposes this as a managed string meaning I can't clear the memory storing the string once I've assigned it to the property.
I'm trying to figure out if I can modify the MSIL to marshal the property call to use either a SecureString directly or and IntPtr created using the Marshal.SecureStringToGlobalAllocUnicode. My early attempts to disassemble/modify/reassemble the interop dll have been less than successful so any guidance or suggestions would be welcome.
Many Thanks
Dave
|
|
|
|
|
When I am trying to install .NET i am very much able to install 'Disc 1' and 'Component'. But after I install Disc 1 it does not prompt me to enter Disc 2 and even if I enter Disc 2 there is no setup file in it. Please suggest.
UNI
|
|
|
|