سؤال

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

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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 ) ) {
      ...
    }
  }
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top