How do I get a handle to the currently focused window

B

Bill Fuller

I would like to get Windows paramaters from the currently in-focus Window in
C#. What is the best way to do this?
 
K

Kerem Gümrükcü

Hi Bill,
I would like to get Windows paramaters from the currently in-focus Window
in C#. What is the best way to do this?

[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();

and is the direct opposite:

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);

Regards

Kerem

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top