How do I determine if a window is hidden?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

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

  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?
    Share on Google+

  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);
    Share on Google+

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,269

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

    Did you try CWnd::IsWindowVisible?
    Victor Nijegorodov
    Share on Google+

  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.
    Share on Google+

  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;
    Share on Google+

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,269

    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
    Share on Google+

  7. #7
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,019

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

    [ Closed thread ]
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/
    Share on Google+

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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center