Reputation: 1091
How I can get a window's descriptor if I know only a part of its title and its className?
Upvotes: 2
Views: 4089
Reputation: 24447
Something like this:
BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam ) {
wchar_t lpClassName[128] = {0};
MYSTRUCT* MS_INFO = ( MYSTRUCT* )lParam;
GetClassName( hwnd, lpClassName, _countof( lpClassName ) );
if( strstr( lpClassName, MS_INFO -> lpClassName ) ) {
wchar_t lpWindowName[128] = {0};
GetWindowText( hwnd, lpWindowName, _countof( lpWindowName ) );
if( strstr( lpWindowName, MS_INFO -> lpWindowName ) ) {
...
}
}
}
Upvotes: 3
Reputation: 595349
FindWindow()
requires the full title. Use EnumWindows()
, or GetWindow()
in a loop, to enumerate through all available windows, calling GetClassName()
and GetWindowText()
on each one and compare the values to your search criteria until you find a match.
Upvotes: 6