Support Forums

Full Version: How to check if from is activated.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

I am working on a chat client and i want to notify the user when there is a new message. So far so good, it all works when the window is minimized. But when the window doesnt have focus (and its not minimized) the user doesnt get notified.

So my question is; how can i check if the focus is on my program or if the users is using another program?
I believe this would work, found it on MA.
"What you need to test is the ActiveControl like this"
If Screen.ActiveControl.Name = Me.Subform1.Name Then
focus = true
Activecontrol is not a member of screen, i am no skid but i dont know how to fix it.
Code:
<DllImport("user32.dll")> _
Private Shared Function GetActiveWindow() As IntPtr
End Function

You might find this unmanaged API useful once you get a way of activating the window to the top (it returns a handle to the active window which can be used to query properties of that window), Hint: There's an API for that as well. However if you're relying on the active Window to determine a new incoming "message/notification" then you're doing something really wrong in my opinion.

This is the .NET forum though so which is it? My guess would be VB.net but I have to ask because you didn't specify the language you were doing this in.
(04-17-2012, 09:43 AM)Modestep Wrote: [ -> ]Activecontrol is not a member of screen, i am no skid but i dont know how to fix it.

'skid' means script kiddie. It means a person who uses others' tools instead of creating their own, it mainly relates to hacking. So if you can't code, it doesn't make you a skid, using tools like Havij makes you a skid.

Anyway on topic; Listen to Ace, he's most likely the best VB coder on this forum.
(04-17-2012, 08:06 PM)BreShiE Wrote: [ -> ]'skid' means script kiddie. It means a person who uses others' tools instead of creating their own, it mainly relates to hacking. So if you can't code, it doesn't make you a skid, using tools like Havij makes you a skid.

Anyway on topic; Listen to Ace, he's most likely the best VB coder on this forum.
I can code ;p, i just didnt know how to do this. I know use the getwindowtext api, if there is a new message and my program isnt the active one i notice the user.