CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2004
    Posts
    54

    How do I determine if a window is hidden?

    I can't seen to find the right search terms to find the answer to this problem if it has been answered already.

    Given a CWnd (or HWND), how do I determine if that window is hidden (as in SW_HIDE) or not?

  2. #2
    Join Date
    Nov 2004
    Posts
    54

    Re: How do I determine if a window is hidden?

    By the way, this is what I've tried so far, and it does not work because showCmd is SW_SHOWNORMAL when the window is hidden.
    Code:
    WINDOWPLACEMENT WindowPlacement;
    WindowPlacement.length = sizeof(WindowPlacement);
    MyWindow.GetWindowPlacement(&WindowPlacement);
    
    bool IsWindowHidden = (WindowPlacement.showCmd == SW_HIDE);

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How do I determine if a window is hidden?

    Did you try CWnd::IsWindowVisible?
    Victor Nijegorodov

  4. #4
    Join Date
    Nov 2004
    Posts
    54

    Re: How do I determine if a window is hidden?

    CWnd::IsWindowVisible is exactly what I needed. I'm sorry for missing the obvious answer. I was too focused on finding if a window was hidden. Thank you.

  5. #5
    Join Date
    Aug 2012
    Posts
    1

    Re: How do I determine if a window is hidden?

    IsWindowVisible will return false, if is has been SW_SHOWn but its parent is hidden

    to find out whether the window itself would be visible if its parent was visible would be

    (::GetWindowLong(hWnd, GWL_STYLE) & WS_VISIBLE) == WS_VISIBLE;

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How do I determine if a window is hidden?

    Quote Originally Posted by dmjalund View Post
    IsWindowVisible will return false, if is has been SW_SHOWn but its parent is hidden
    to find out whether the window itself would be visible if its parent was visible would be
    (::GetWindowLong(hWnd, GWL_STYLE) & WS_VISIBLE) == WS_VISIBLE;
    Didn't you read the OP?
    Quote Originally Posted by Monolith View Post
    Given a CWnd (or HWND), how do I determine if that window is hidden (as in SW_HIDE) or not?
    So, Monolith didn't ask whether the WS_VISIBLE style is currently set or not but whether window is visible or not (hidden)!
    Thus as OP already confirmed more than three years ago (!):
    Quote Originally Posted by Monolith
    CWnd::IsWindowVisible is exactly what I needed!
    Victor Nijegorodov

  7. #7
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: How do I determine if a window is hidden?

    [ Closed thread ]
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured