Results 1 to 5 of 5

Thread: Get focused window title/caption in C++ ?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    12

    Question Get focused window title/caption in C++ ?

    Hello every one
    i searched this forum and google before posting here this question and didn't find any thing
    Does any body knows how to get the focused window title?
    for exemple if i ama using C++ Builder for my application and i have a timer with 300ms interval...and i want to put the code in it something like:
    //Edit1->Text = GetFocusWindowTitle;

    Any one knows how to do it

    - Sorry for my bad english

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Get focused window title/caption in C++ ?

    In Windows:

    Code:
    #include <windows.h>
    
    // ...
    
    TCHAR buf[255];
    GetWindowText(GetForegroundWindow(), buf, 255);
    Last edited by penagate; May 7th, 2007 at 12:29 AM.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    12

    Re: Get focused window title/caption in C++ ?

    Quote Originally Posted by penagate
    In Windows:

    Code:
    #include <windows.h>
    
    // ...
    
    TCHAR buf[255];
    GetWindowText(GetForegroundWindow(), buf, 255);
    thx for the reply
    but i don't know how to use this code to get the focused window title into my text box or any other output way

  4. #4
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Get focused window title/caption in C++ ?

    What don't you understand? Basically the code he gave you calls a windows API function and shoves the output into a buffer that he has named "buf." The buffer is just an array of TCHARs which you can use in whatever manner you need.


    "X-mas is 24.Desember you English morons.." - NoteMe

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    12

    Re: Get focused window title/caption in C++ ?

    Quote Originally Posted by dsheller
    What don't you understand? Basically the code he gave you calls a windows API function and shoves the output into a buffer that he has named "buf." The buffer is just an array of TCHARs which you can use in whatever manner you need.
    ok
    thx alot it worked great

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width