how to find a window's SW_SHOW/SW_HIDE status

24,992

Solution 1

Use GetWindowPlacement. It fills WINDOWPLACEMENT structure, which has field showCmd.

showCmd
Specifies the current show state of the window. This member can be one of the following values.

Solution 2

Call GetWindowLong( handle, GWL_STYLE), check the returned value for WS_VISIBLE style presence.

Solution 3

I would use GetWindowPlacement, however I am not sure if I understood what you want. It fills in a WINDOWPLACEMENT structure and then use the showCmd member.

Share:
24,992
geocoin
Author by

geocoin

some code monkey that uses predominantly C++ on windows platforms. have worked for companies such as ntl broadcast(an ex UK Telco now renamed and nothing to do with CATV) Honeywell (an experience never to be repeated) and McLaren Electronics, doing whizzy F1 telemetry type stuff (cool!) now works in a small place, producing legal Database UI software while trying to think up an interesting handheld game concept or trying to hack some hardware beyond recognition.

Updated on February 11, 2020

Comments

  • geocoin
    geocoin over 4 years

    I am trying to determine a window control's visibility that has been hidden or enabled with CWnd::ShowWindow(). (or ::ShowWindow(hWnd,nCmdShow))

    I cannot simply use ::IsWindowVisible(hWnd) as the control is on a tab sheet, which may itself be switched out, causing IsWindowVisible to return FALSE.

    Is there a way to get the SW_SHOW/HIDE (or others) window status or do I need to use the retun value of ShowWindow() and reset accordingly?

    edit: as the control is enabled (or disabled) to show, but may not be currently visible, as the tab is switched ot, I would think that it's SW_SHOW status would remain the same, even if the window itself is not actually switched in. If I'm unrealistic in my expectations that that's fine.

    So really I'm looking for 'can this window/control be shown'