471,339 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,339 software developers and data experts.

WndProc not working as expected?

Hi

I have overriden WndProc to detect when the key is pressed. Because it
didnt work i inserted debug code to detect what messages pass through
the WndProc exactly.My application is minimized in taskbar and visible
via notifyicon. When I run the program :

protected override void WndProc(ref Message m)
{
System.Diagnostics.Debug.WriteLine(m.Msg);

base.WndProc(ref m);
}

I see :

36
129
131
1
12
70
36
131
71
3
14
13
5
128
128
14
13
14
13
124
125
124
125
70
131
71
70
71
14
13
24
49612

....and no more messages pass through WndProc. I need to catch windows
message when user presses Control twice. Why no more messages pass
through the WndProc and how to catch control presses twice?

Best Regards
PK
Aug 17 '08 #1
4 3977
The key down event would only occur if your window has focus, which it
doesn't. What you need is a global keyboard hook. I don't recall how to do
it, but two method names I do recall are SetWindowsHookEx and
CallNextHookEx.
Pete

Aug 17 '08 #2
On Aug 17, 3:14*pm, Piotrekk <Piotr.Kolodz...@gmail.comwrote:
Hi

I have overriden WndProc to detect when the key is pressed. Because it
didnt work i inserted debug code to detect what messages pass through
the WndProc exactly.My application is minimized in taskbar and visible
via notifyicon. When I run the program :

* * * * protected override void WndProc(ref Message m)
* * * * {
* * * * * * System.Diagnostics.Debug.WriteLine(m.Msg);

* * * * * * base.WndProc(ref m);
* * * * }

I see :

36
129
131
1
12
70
36
131
71
3
14
13
5
128
128
14
13
14
13
124
125
124
125
70
131
71
70
71
14
13
24
49612

...and no more messages pass through WndProc. I need to catch windows
message when user presses Control twice. Why no more messages pass
through the WndProc and how to catch control presses twice?

Best Regards
PK
Hello

You can do LowLevelHook in C#
It will tell you all the info about key up/down of mouse
Aug 18 '08 #3
I was thinking the same thing...here's a link.

http://blogs.msdn.com/toub/archive/2...03/589423.aspx

-Drew
Aug 19 '08 #4
On 19 Sie, 09:46, "DrewCE" <moc.sgodniahc@werd - backwardswrote:
I was thinking the same thing...here's a link.

http://blogs.msdn.com/toub/archive/2...03/589423.aspx

-Drew
Thank you
Aug 22 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by cyrille | last post: by
4 posts views Thread by Rob | last post: by
reply views Thread by rosydwin | last post: by

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.