Pobranie tytułu aktywnego okna

0

jak pobrać tytuł aktywnego okna?
C++ Builder 2010
bo jak robie coś takiego

HWND okno = GetActiveWindow();
int dlugosc = GetWindowTextLength(okno);
AnsiString text;
Button1->Caption = GetWindowText(okno, text.c_str(), dlugosc+1);

to w text mam pusto, a w Button1->Caption pokazuje jakies krzaczki.

natomiast gdy uzylem to poprzez

HWND = FindWindow(NULL, "Mozilla Firefox");

to pobral wtedy normalnie tytul i dzialalo ok wszystko.

Więc jak to zrobić, żeby działało z GetActiveWindow() ?

0

Kupujesz kota w worku i masz pretensje że zamiast kota jest pies?

msdn napisał(a)

The GetActiveWindow function retrieves the window handle to the active window attached to the calling thread's message queue.
The return value is the handle to the active window attached to the calling thread's message queue. Otherwise, the return value is NULL.

Prawidłowe funkcje to m.in. GetForegroundWindow, GetGUIThreadInfo.

0
GetWindowText(okno, text.c_str()/*BYLO_JUŻ_STO_TYSIECY_RAZY_ŻE_TAK_SIE_NIE_ROBI! */, dlugosc+1);

1 użytkowników online, w tym zalogowanych: 0, gości: 1