471,330 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

How do I get a handle to the currently focused window

I would like to get Windows paramaters from the currently in-focus Window in
C#. What is the best way to do this?
Jun 27 '08 #1
1 6254
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

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Bill Fuller" <so*****@nospam.comschrieb im Newsbeitrag
news:Oq**************@TK2MSFTNGP06.phx.gbl...
>I would like to get Windows paramaters from the currently in-focus Window
in C#. What is the best way to do this?

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by pnp | last post: by
11 posts views Thread by objectref | last post: by
3 posts views Thread by TC | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.