Results 1 to 6 of 6

Thread: Check if window with certain title exists

  1. #1
    Join Date
    Jan 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Check if window with certain title exists

    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?

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Check if window with certain title exists

    Yes, you need that winapi magic
    A combination of EnumWindows() and GetWindowTitle() should do the trick.

  3. #3
    Join Date
    Oct 2008
    Location
    Brazil, Sao Paulo - SP
    Posts
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Check if window with certain title exists

    There is a simpler way! Take a look at msdn: http://msdn.microsoft.com/en-us/library/ms633499.aspx

    The FindWindow() function:
    Qt Code:
    1. HWND handle = FindWindow(NULL, "Window Title");
    To copy to clipboard, switch view to plain text mode 

    This should work for you.

    PS: The function returns NULL on a non'existant window, or the window handle otherwise.
    Last edited by tinsuke; 21st January 2009 at 11:30. Reason: Further explanations

  4. #4
    Join Date
    Jan 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Check if window with certain title exists

    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!

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Check if window with certain title exists

    If you're willing to introduce a dependency to Qxt, you can use QxtWindowSystem.
    J-P Nurmi

  6. #6
    Join Date
    Jan 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Check if window with certain title exists

    Thanks, I'll look into that

Similar Threads

  1. Replies: 4
    Last Post: 23rd December 2008, 20:41
  2. Window title bar and "X" button
    By markcole in forum Qt Programming
    Replies: 3
    Last Post: 20th December 2007, 20:58
  3. Remove window title
    By marcel in forum Qt Programming
    Replies: 2
    Last Post: 10th April 2007, 05:06
  4. Remove Window title bar
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 16th January 2007, 12:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.