如何查找窗口的 SW_SHOW/SW_HIDE 状态

2022-01-12 00:00:00 winapi c++ show-hide mfc

我正在尝试确定已使用 CWnd::ShowWindow() 隐藏或启用的窗口控件的可见性.(或::ShowWindow(hWnd,nCmdShow))

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

我不能简单地使用 ::IsWindowVisible(hWnd),因为控件位于选项卡上,它本身可能会被切换,导致 IsWindowVisible 返回 FALSE.

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.

有没有办法获得 SW_SHOW/HIDE(或其他)窗口状态,还是我需要使用 ShowWindow() 的 retun 值并相应地重置?

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?

由于控件已启用(或禁用)以显示,但当前可能不可见,因为选项卡已切换,我认为它的 SW_SHOW 状态将保持不变,即使窗口本身实际上并未打开.如果我的期望是不现实的.

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'

推荐答案

使用GetWindowPlacement.它填充 WINDOWPLACEMENT 结构,其中有字段 <代码>showCmd.

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

showCmd
指定窗口的当前显示状态.此成员可以是以下值之一.

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

相关文章