Public Class MyForm: Form
{
[DLLIMPORT ("User32.dll", Charset = Charset.auto, CallingConvention = CALLINGCONVENTION.WINAPI)]
INTERNAL STATIC EXTERN INTPTR getFocus ();
// Get focus controls
Private control getfocusedControl ()
{
Control FocusedControl = NULL;
// TO GET HOLD of The Focused Control:
INTPTR FOCUSEDHANDLE = Getfocus ();
IF (FocusedHandle! = INTPTR.ZERO)
// Note That if The Focused Control Is Not a .Net Control, THIS WILL RETURN NULL.
FocusedControl = Control.FromHandle (FocusedHandle);
Return FocusedControl;
}
}