我运行 notepad.exe后,用程序得到了这个程序的HWND
然后代码如下  WINDOWPLACEMENT wndpl;//是局部变量
wndpl.length = sizeof(WINDOWPLACEMENT);
::GetWindowPlacement(Target_hwnd, &wndpl);
if(wndpl.showCmd==SW_HIDE)
wndpl.showCmd = SW_SHOWNORMAL;
else
wndpl.showCmd = SW_HIDE;
::SetWindowPlacement(Target_hwnd, &wndpl);
//我的程序行为,大家能看懂吧,就不细说了....第一次执行,会隐藏窗口,但第二次执行得到的窗口 showCmd 还是SW_SHOWNORMAL,不能显示窗口请问,难道 SetWindowPlacement 已经把窗口隐藏了,那得到他的窗口状态的 showCmd 不是SW_HIDE,既然第一次用 SetWindowPlacement 已经把窗口隐藏了,为什么第二次得到的不是 SW_HIDE

解决方案 »

  1.   

    If the window identified by the hWnd parameter is maximized, the showCmd member is SW_SHOWMAXIMIZED. If the window is minimized, showCmd is SW_SHOWMINIMIZED. Otherwise, it is SW_SHOWNORMAL. 
      

  2.   


    哎,犯错误了,没仔细看MSDN...汗
    ResThe flags member of WINDOWPLACEMENT retrieved by this function is always zero. If the window identified by the hWnd parameter is maximized, the showCmd member is SW_SHOWMAXIMIZED. If the window is minimized, showCmd is SW_SHOWMINIMIZED. Otherwise, it is SW_SHOWNORMAL. The length member of WINDOWPLACEMENT must be set to sizeof(WINDOWPLACEMENT). If this member is not set correctly, the function returns FALSE. For additional res on the proper use of window placement coordinates, see WINDOWPLACEMENT.