Capture Key Commands

.NET Edition of the F-IN-BOX
jankrod
Posts: 8
Joined: Wed Jul 19, 2006 5:12 pm

Capture Key Commands

Postby jankrod » Thu Jun 28, 2007 8:14 pm

In flash if a user hits Ctrl-C to copy when in a textfield flash does not have any way of detecting that event. Is there anyway to detect that in C#.

Because the flash control has focus. regular events that watch for keyup on the form dont work.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Sat Jun 30, 2007 5:12 pm

Thank you for your question.

Yes, after a few tests I see that it's not a simple task...

I've tried implementing of IMessageFilter.

See the code:

Code: Select all

[DllImport("user32.dll", EntryPoint = "IsChild", CallingConvention = CallingConvention.StdCall)]
public static extern int IsChild(IntPtr hWndParent, IntPtr hWnd);

public bool PreFilterMessage(ref Message m)
{
   if (f_in_box__control1.Handle == m.HWnd || ( 0 != IsChild(f_in_box__control1.Handle, m.HWnd)))
      if (0x101 /* WM_KEYUP */ == m.Msg && (int)'C' == m.WParam.ToInt32())
      {
         // Tada!
      }

   return false;
}


It works well but I don't know to detect if Control is also pressed...
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html


Return to “.NET Edition”

Who is online

Users browsing this forum: No registered users and 13 guests

cron