คำตอบ EnumWindows does not enumerate math input panel window

  • Wednesday, July 18, 2012 10:06 PM
     
     
    I cannot use Windows API EnumWindows to enumerate such window. Any idea? Thanks.

All Replies

  • Thursday, July 19, 2012 7:17 AM
    Moderator
     
     Answered Has Code

    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

    • Marked As Answer by Leonjl Friday, July 20, 2012 6:00 PM
    •  
  • Friday, July 20, 2012 6:00 PM
     
     

    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.

  • Monday, July 23, 2012 2:11 AM
    Moderator
     
     Answered Has Code

    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