473,394 Members | 1,869 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,394 software developers and data experts.

Application is Active?

How do i know if my application is the current active window?
i have tryied using me.focused but that only work if the form is focused, if
a child control is focused it then returns false and i want to know if my
application is the current active one in windows so i dont need to flash the
window to get user attention or bring it to front.

Thanks,

Jun 27 '08 #1
2 2282
On Apr 29, 3:58 am, "Christian Reizlein" <creizl...@hotmail.com>
wrote:
How do i know if my application is the current active window?
i have tryied using me.focused but that only work if the form is focused, if
a child control is focused it then returns false and i want to know if my
application is the current active one in windows so i dont need to flash the
window to get user attention or bring it to front.

Thanks,
Christian,
You can take a look at Form's ActiveForm and ActiveMDIchild
properties. For instance, if you want to determine that your current
active form is Form1 by name;

If Me.ActiveForm.Name.ToString() = "Form1" Then
MsgBox("Yes,Form1 is active")
Else
Msgbox("Nope,another form is active")
Else

Hope this helps,

Onur
Jun 27 '08 #2
"Christian Reizlein" <cr*******@hotmail.comschrieb
How do i know if my application is the current active window?
i have tryied using me.focused but that only work if the form is
focused, if a child control is focused it then returns false and i
want to know if my application is the current active one in windows
so i dont need to flash the window to get user attention or bring it
to front.
Maybe there's a shorter way...: (perhaps even a managed one that I did
not find).

Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd
As IntPtr, ByRef ProcessID As Int32) As IntPtr

'...

Dim hwnd As IntPtr
Dim ProcessID As Int32

hwnd = GetForegroundWindow
GetWindowThreadProcessId(hwnd, ProcessID)

MsgBox((ProcessID = Process.GetCurrentProcess.Id).ToString)

Armin

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LarsJ | last post by:
Hi, can please MS answer this question: Is there any way for an desktop application to make it the active application (= the application window is highlighted and in front)? Or is there any way...
5
by: Homer J. Simpson | last post by:
Hi, Any idea to get the -REAL- number of active users -WITHOUT- this kind of code ? ---------------------------------------------------------------------------- --------- Sub Session_OnStart...
4
by: pjdouillard | last post by:
Hello all, Here is the context of my problem: We have an ASP.NET 1.1 application that has its own application pool setup and that runs under the identity of a NT Domain service account (this...
7
by: Venkat Venkataramanan | last post by:
Hello: I have a UI layer that interacts with the business layer which interacts with the DB layer. I have developed the business layer as a class library that complies to a DLL that will be...
4
by: Ray | last post by:
Does anyone out there have experience with using Db2 8.2 with a program called MISys (also known as ACCPAC). I am having some problems with the application running exteremly slow on workstations...
1
by: Rasheed | last post by:
We are building a smart client application (.NET 2.0) which uses Web Services to access the business objects. Services: The Web Services have been secured by brokered authentication using X509...
2
by: remya1000 | last post by:
i'm using VB.NET. and its a windows application. in my program i need to display a table in datagrid. so i created the table using DataTable and i'm calling that dataTable to dataGrid. and its...
4
by: tim007 | last post by:
Hi, How can we get tthe number of active users connected to our web application. I have added application varible that gets incrimeted at session_start and then is decreased at session_end ...
4
by: =?ISO-8859-15?Q?Albe_V=B0?= | last post by:
In my Application, I need to make a certain graphical refresh, interrogating SqlServer, only if Application has focus (i.e. the title bar is blue). Interrogating .Focused property of various...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.