I'm writing a program which gets interrupted when another window is called on top ( eg. When you receive a message from a chat client, for example MSN ). Is there any way to shut down this application at the start of my program ? Thanks.
I'm writing a program which gets interrupted when another window is called on top ( eg. When you receive a message from a chat client, for example MSN ). Is there any way to shut down this application at the start of my program ? Thanks.
There are several solutions. One solution is to search for whatever application you want to terminate via FindWindow(). Another solution is to enumerate active processes.
Kuphryn
I thought of FindWindow(), however people will use MSN or other clients in different languages, and I probably won't be able to find them. I haven't heard of enumeration, what is it ? How can I use it ?
Also, is there any way to find out if the user is connected to the Internet, finding out if he has a modem, and breaking the internet connection ?
I'm not sure I understand exactly what you're trying to do, but you could use FindWindow() and search for the class, instead of the window name. The class stays the same, no matter what language is selected.
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials
What is the window class ? I understand this is the first statement entered in the FindWindow() function, but how do I find it out ? Does each unique program / window have its unique class, and is it the same on every computer ?
i love it.Programmer [noun] : A savage sub-species of Human ( Homo Sapiens Sapiens ), whose odd social behaviour and rituals remain little known by humans. Living on code, they spend their time in a mysterious trance-like state in front of what they call "compilers", which we believe is a gateway to their deities.
you will need FindWindowEx to search for the different windows.
when you find the window you want to close you could probley send a WM_DESTROY message or something
Try to help all less knowledgeable than yourself, within
the limits provided by time, complexity and tolerance.
- Nor
Sorry my net screwed up, it posted three times.
Last edited by bennyandthejets; 07-29-2003 at 12:52 AM.
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials
again
Last edited by bennyandthejets; 07-29-2003 at 12:53 AM.
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials
Korhedron, you've asked a big question there. I wouldn't know how to explain it exactly, because I only learnt about window classes through experience. But I'll try:
Every window that is created in Windows is created with a particular window class. The class is either a built-in or custom made structure that defines certain aspects that the window will have. For example, the window procedure that is used, the application icon, the default menu, or the background brush (the pattern and color of the background). Look up the WNDCLASSEX structure on MSDN for more details. Basically, classes save you a lot of time by allowing you to specify the same details for a window over and over, without writing everything out.
A good example is the BUTTON class. It's a built-in, or predefined, class in Windows. In a program, you may have many buttons. Without classes, you would have to write the window procedures (including graphics coding, mouse interaction coding, and memory allocation) again and again for every button. Instead, they encapsulated the code into a container, or class, that you can specify with just 6 letters.
So, say you want to list all of the MSN chat windows on your screen at the current time. Instead of searching the window captions, which vary depending on who you're talking to, you search the window classes, which will be the same for every single MSN chat window. On my computer, this class is "IMWindowClass". The following code will find you the first Messenger window open:
If you want to find all the Messenger windows open, you'll have to use EnumWindows(), and check each window class to see if it's a match.Code:HWND hwnd=FindWindow("IMWindowClass",NULL);
And yes, this class should be the same on every computer. To find it out, use Spy++. If you don't have that, you'll have to make a program yourself that enumerates all the windows and their window classes. You can identify the window you want by the caption.
I hope this helps.
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials