Question

How I can get a window's descriptor if I know only a part of its title and its className?

Était-ce utile?

La solution

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.

Autres conseils

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 ) ) {
      ...
    }
  }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top