准备睡了,有个问题没弄明白,上来问下,关于SetWindowPos的问题,MSND有一段说明:
If the SWP_SHOWWINDOW or SWP_HIDEWINDOW flag is set, the window cannot be moved or sized.但是我这样用为什么还是会修改大小的?
GetDlgItem(IDC_BUTTON_SAVE)->SetWindowPos(NULL, cTempRect.left, cTempRect.top, cTempRect.Width(), cTempRect.Height()*2, SWP_SHOWWINDOW);不是说不会改变大小吗?请指教,谢谢!

解决方案 »

  1.   

    uFlags
    [in] Specifies the window sizing and positioning flags. This parameter can be a combination of the following values. 
    ......
    SWP_NOSIZE
    Retains the current size (ignores the cx and cy parameters).
    SWP_NOZORDER
    Retains the current Z order (ignores the hWndInsertAfter parameter).
    SWP_SHOWWINDOW
    Displays the window.
      

  2.   

    谢谢,但是答非所问。我问的是,MSDN里面说明的不改变,到底是在什么情况下使用的,因为像我那样使用,是可以调整大小的。
      

  3.   

    the SetWindowPos function assumes that SWP_NOMOVE and SWP_NOSIZE are set if SWP_HIDEWINDOW or SWP_SHOWWINDOW was set. Thus, hiding and showing a window and changing its size and position are not possible in an atomic operation.setwindowpos函数,如果执行SWP_HIDEWINDOW或SWP_SHOWWINDOW SetWindowPos设置,就假设SWP_NOMOVE和SWP_NOSIZE已经设定。因此,隐藏和显示一个窗口,并改变其大小和位置,都不可能在一个原子操作。msdn上是这样说的。
      

  4.   

    谢谢楼上,我上面的代码,和说明的有什么不同呢?难道说是,如果窗口原来是隐藏的,设置了SWP_SHOWWINDOW则,不会改变大小和移动;如果窗口是显示的,则SWP_SHOWWINDOW无效,所以会改变大小和移动?
    有可能是这样,我用代码试试。
      

  5.   

    你显示是如何显示的?showwindow(sw_show)?
      

  6.   

    /*
     * SetWindowPos Flags
     */
    #define SWP_NOSIZE          0x0001
    #define SWP_NOMOVE          0x0002
    #define SWP_NOZORDER        0x0004
    #define SWP_NOREDRAW        0x0008
    #define SWP_NOACTIVATE      0x0010
    #define SWP_FRAMECHANGED    0x0020  /* The frame changed: send WM_NCCALCSIZE */
    #define SWP_SHOWWINDOW      0x0040
    #define SWP_HIDEWINDOW      0x0080
    从宏定义来看,SWP_SHOWWINDOW并没有包括SWP_NOSIZE和SWP_NOMOVE 
      

  7.   

    大家试试嘛,建个窗体试下。我只是看到MSDN说不会移动和改变大小有点疑惑,因为像我这样用的是可改变大小的,不明白。