PDA

View Full Version : Check if window with certain title exists



devil
20th January 2009, 21:56
Is it possible to somehow check if window (on Windows) with certain title exists at the moment.. or do I need some kind of winapi magic for that?

spud
21st January 2009, 09:23
Yes, you need that winapi magic;)
A combination of EnumWindows() and GetWindowTitle() should do the trick.

tinsuke
21st January 2009, 11:29
There is a simpler way! Take a look at msdn: http://msdn.microsoft.com/en-us/library/ms633499.aspx

The FindWindow() function:

HWND handle = FindWindow(NULL, "Window Title");

This should work for you.

PS: The function returns NULL on a non'existant window, or the window handle otherwise.

devil
21st January 2009, 13:15
Oh, thank you so much! I've been looking for this like.. forever.. too bad it can't be done with Qt but I totally understand why. But thanks again! :)

jpn
21st January 2009, 13:39
If you're willing to introduce a dependency to Qxt (http://libqxt.org), you can use QxtWindowSystem (http://doc.libqxt.org/latest/classQxtWindowSystem.html).

devil
21st January 2009, 14:42
Thanks, I'll look into that :)