WndProc not working as expected?

  • Thread starter Thread starter Piotrekk
  • Start date Start date
P

Piotrekk

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
 
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
 
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
 
Back
Top