Respondida EnumWindows does not enumerate math input panel window

  • miércoles, 18 de julio de 2012 22:06
     
     
    I cannot use Windows API EnumWindows to enumerate such window. Any idea? Thanks.

Todas las respuestas

  • jueves, 19 de julio de 2012 7:17
    Moderador
     
     Respondida Tiene código

    This API can work, the Math Input Panel has no Caption, so I think you just check the Caption and let the application tell you if the Window exists.

    We can check the Window Class like this:

    	WNDENUMPROC lpEnumFunc = EnumWindowsProc;
    	LPARAM lParam = NULL;
    	BOOL hr = EnumWindows(lpEnumFunc,lParam);
    	return 0;
    }
    
    BOOL CALLBACK EnumWindowsProc(
    	__in  HWND hwnd,
    	__in  LPARAM lParam
    	)
    {
    	LPWSTR lpString = new wchar_t[256];
    	GetClassName(hwnd,lpString, 256);
    	LPWSTR classname = L"MathInput_Window";
    	if(!wcsncmp(classname,lpString,wcslen(classname)-1))//class name: MathInput_Window
    		std::wcout<<lpString<<"+"<<hwnd<<std::endl;
    	return TRUE;
    }


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us

    • Marcado como respuesta Leonjl viernes, 20 de julio de 2012 18:00
    •  
  • viernes, 20 de julio de 2012 18:00
     
     

    Mike, thanks for reply. I got the window with your way. However, IsWindowVisible returns FALSE on the handle of MIP. I expect it to return true. Any idea? Thanks.

  • lunes, 23 de julio de 2012 2:11
    Moderador
     
     Respondida Tiene código

    You're welcome!

    When I use this code, the Math Input Panel Window is displayed topmost on the desktop, then the IsWindowVisible function return 1 to me.

    Maybe you minimize it, so that you cannot see it when you run the code, and the code will not think so it is visible.

    BOOL CALLBACK EnumWindowsProc(
    	__in  HWND hwnd,
    	__in  LPARAM lParam
    	)
    {
    	LPWSTR lpString = new wchar_t[256];
    	GetClassName(hwnd,lpString, 256);
    	LPWSTR classname = L"MathInput_Window";
    	if(!wcsncmp(classname,lpString,wcslen(classname)-1))//class name: MathInput_Window
    	{
    
    		std::wcout<<lpString<<"+"<<hwnd<<" IsWindowVisible:"<<IsWindowVisible(hwnd)<<std::endl;
    	}
    	return TRUE;
    }


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us