Reputation: 399
I am trying to use EnumWindows to print out the titles of all visible windows.
It was working at first, EnumWindows was calling the callback function createWindow() multiple times with each call of EnumWindows. But without adding any meaningful code it stopped working and now only calls createWindow() once with a handle of a not visible window.
Here is my code:
int main()
{
int row = 2;
int col = 2;
vector<Window> detectedWindows((row * col) + 4);
EnumWindows(&createWindow, (LPARAM)&detectedWindows);
}
BOOL CALLBACK createWindow(HWND input, LPARAM storage)
{
if (IsWindowVisible(input))
{
TCHAR titleTchar[30];
GetWindowText(input, titleTchar, 30);
wcout << titleTchar << endl;
CString titleCstr = titleTchar;
CT2CA converting(titleCstr);
string title(converting);
cout << title << endl;
}
return 0;
}
There are no recorded error messages. GetLastError returns 0.
Upvotes: 0
Views: 777
Reputation: 13144
Your callback returns FALSE
so EnumWindows()
stops enumerating windows. Have it return TRUE
instead.
Upvotes: 4