473,408 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 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 6870
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: lukasz | last post by:
I'm looking for ideas how to implement a tool window with several buttons which, once clicked, should paste certain character in to the active EditBox in an other window of my application. The...
3
by: pnp | last post by:
How can I make a Toolbox form always stay focused without making it a topmost form?
11
by: objectref | last post by:
Hi to all, is there a way to get the window handle of the main window of an application or process ? For example, if someone opens Microsoft Word, he gets a window so he/she can write text....
0
by: gif | last post by:
i have a main form and a toolbar in an dialog box. I would make the comportment of the toolbar like a child window, but having the possibility to move it also outside the main client area. What i...
3
by: TC | last post by:
Hey Folks, I am using the following 4 Win32 APIs with a C# AddIn: FindWindow SetWindowLong SetForegroundWindow EnableWindow Within the AddIn, there are some winforms. I use these APIs to...
7
by: lkr | last post by:
hi is there is anyway to capture the document events of a MSWord?eg:I have to handle the event awhen WM_KEYUP or anyother events will occur. give me a solution............ thanks in advance lkr
3
by: rsjonny | last post by:
I'm writing C++ code with visual studio 2005, I find when my source edit view get focused, the property of this class is missing, so if I want to add a virtual function or a window's message...
1
by: moondaddy | last post by:
I have a c# 3.5 wpf app which uses user controls for data entry screens. These data entry screens can be nested inside of each. We can also have several ones open side by side at the same time. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.