locked
find out if a window IntPtr is hidden or not RRS feed

  • Question

  • find out if a window IntPtr is hidden or not

    thanks  !!!!!!!!!

    Monday, November 29, 2010 11:33 PM

Answers

  • You can use GetWindowLong with the proper flags.

    Add a using of System.Runtime.InteropServices, and implement code like the following:

    private static bool GetVisibilityHwnd(IntPtr hWnd)
    {
      return (GetWindowLong(hWnd, GWL_STYLE) & WS_VISIBLE) != 0;
    }
    
    // APIs
    
    private const int GWL_STYLE = -16;
    private const int WS_VISIBLE = 268435456;
    
    [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet=CharSet.Auto, SetLastError=true)]
    private static extern int GetWindowLong([In()] System.IntPtr hWnd, int nIndex);
    
    • Marked as answer by mad-YuRi Tuesday, November 30, 2010 4:49 PM
    Tuesday, November 30, 2010 12:31 AM
  • You can call GetVisiblityHwnd(item.MainWindowHandle) inside your loop, if that is what you are looking to do.

    Otherwise, please explain your question.

     

    • Marked as answer by mad-YuRi Tuesday, November 30, 2010 1:51 AM
    Tuesday, November 30, 2010 1:37 AM

All replies

  • I didn't find it. It must be hidden.

    What is that "window IntPtr" you're talking about?

    Tuesday, November 30, 2010 12:24 AM
  • You can use GetWindowLong with the proper flags.

    Add a using of System.Runtime.InteropServices, and implement code like the following:

    private static bool GetVisibilityHwnd(IntPtr hWnd)
    {
      return (GetWindowLong(hWnd, GWL_STYLE) & WS_VISIBLE) != 0;
    }
    
    // APIs
    
    private const int GWL_STYLE = -16;
    private const int WS_VISIBLE = 268435456;
    
    [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet=CharSet.Auto, SetLastError=true)]
    private static extern int GetWindowLong([In()] System.IntPtr hWnd, int nIndex);
    
    • Marked as answer by mad-YuRi Tuesday, November 30, 2010 4:49 PM
    Tuesday, November 30, 2010 12:31 AM
  • foreach

     

     

    (System.Diagnostics.Process item in System.Diagnostics.Process.GetProcesses)

    {

    item.MainWindowHandle

     

    // <-----

    }

    Tuesday, November 30, 2010 12:32 AM
  • You can call GetVisiblityHwnd(item.MainWindowHandle) inside your loop, if that is what you are looking to do.

    Otherwise, please explain your question.

     

    • Marked as answer by mad-YuRi Tuesday, November 30, 2010 1:51 AM
    Tuesday, November 30, 2010 1:37 AM