473,399 Members | 3,302 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,399 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 6869
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.