A
ariadna.sirianni
Hi.
I'm developing in C# for PPC devices.
I found some code that works for WindowsForms. The code is the
followin:
DllImport("coredll.dll, EntryPoint="GetFocus")]
private extern static IntPtr GetFocus();
···
control.Focus();
IntPtr handle = GetFocus();
[C#]
public class MyForm : Form
{
[DllImport("user32.dll", CharSet=CharSet.Auto,
CallingConvention=CallingConvention.Winapi)]
internal static extern IntPtr GetFocus();
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, then this will return null.
focusedControl = Control.FromHandle(focusedHandle);
return focusedControl;
}
}
As you see, GetFocus returns an IntPtr of the focused control, after
that, the function "Control.FromHandle" recives that IntPtr and
returns the focused control.
I need to know if there is some function in .Net Compact Framework
that works as FromHandle (Control.FromHandle) does.
Thanks in advance.
Ariadna.-
I'm developing in C# for PPC devices.
I found some code that works for WindowsForms. The code is the
followin:
DllImport("coredll.dll, EntryPoint="GetFocus")]
private extern static IntPtr GetFocus();
···
control.Focus();
IntPtr handle = GetFocus();
[C#]
public class MyForm : Form
{
[DllImport("user32.dll", CharSet=CharSet.Auto,
CallingConvention=CallingConvention.Winapi)]
internal static extern IntPtr GetFocus();
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, then this will return null.
focusedControl = Control.FromHandle(focusedHandle);
return focusedControl;
}
}
As you see, GetFocus returns an IntPtr of the focused control, after
that, the function "Control.FromHandle" recives that IntPtr and
returns the focused control.
I need to know if there is some function in .Net Compact Framework
that works as FromHandle (Control.FromHandle) does.
Thanks in advance.
Ariadna.-