我现在可以使一个CStatic全屏显示,代码如下,但怎样使它恢复到原来的位置?     CWnd * p_staticVideo;       
    CWnd * saveParent;
     p_static =(CWnd *)this->GetDlgItem(IDC_STATIC);
    saveParent=p_static->GetParent(); 
    p_static->SetParent(GetDesktopWindow()); 
    CRect   rect; 
    GetDesktopWindow()-> GetWindowRect(&rect); 
    p_static->SetWindowPos(&wndTopMost,rect.left,rect.top,rect.right,rect.bottom,SWP_SHOWWINDOW); 

解决方案 »

  1.   

    先记住static之前的位置坐标等 Rect
    然后SetWindowPos 设置回来..
      

  2.   

    先保存未全屏的rect,,再在CStatic添加类似双击的事件让其恢复原来的位置
      

  3.   

    保存原来的位置,给 SetWindowPos 使用步骤应该和上面是一样的吧,只是恢复成原来的
      

  4.   

    楼上的大哥,怎样保存static之前的位置坐标等 Rect ?谢谢了
      

  5.   

    p_static =(CWnd *)this->GetDlgItem(IDC_STATIC); 
    取得了以后,然后GetWindowRect()保存坐标到你的变量等...
      

  6.   

    还是还原不出来CWnd * p_static;
    CWnd * saveParent;
    CRect m_rect;全屏代码:
    p_static =(CWnd *)this->GetDlgItem(IDC_STATIC);
    p_static->GetWindowRect(&m_rect);
    saveParent=p_static->GetParent(); 
    p_static->SetParent(GetDesktopWindow()); 
    CRect   rect; 
    GetDesktopWindow()-> GetWindowRect(&rect); 
    p_static->SetWindowPos(&wndTopMost,rect.left,rect.top,rect.right,rect.bottom,SWP_SHOWWINDOW); 恢复代码:
    p_static->SetParent(saveParent);
    p_static->SetWindowPos(&wndTop,m_rect.left,m_rect.top,m_rect.right,m_rect.bottom,SWP_SHOWWINDOW); 还是还原不了,CStatic控件不见了
      

  7.   

    GetWindowRect获得的坐标是屏幕坐标,应该再用dlg->ScreenToClient转换成客户区坐标再保存。
    SetWindowPos的参数需要的是客户区坐标。
      

  8.   

    pwndChild->GetWindowRect(rcChild);
    ScreenToClient(rcChild); 
    pwndChild->MoveWindow(rcChild,FALSE); 
      

  9.   

    先把控件句柄和控件矩形保存起来,要还原的时候,通过句柄来操作,先还原Parent,再设置矩形。
    注意:GetWindowRect得到的是相对于屏幕的坐标,而设置位置时,具有WS_CHILD风格的控件使用的是其父窗口客户区内坐标。
    另外,给控件改个ID,例如IDC_STATIC1,不要用IDC_STATIC。
      

  10.   

    还是不行呀,
    还原不出来
    CWnd * p_static; 
    CWnd * saveParent; 
    CRect m_rect; 全屏代码: 
    p_static =(CWnd *)this->GetDlgItem(IDC_STATIC); 
    p_static->GetWindowRect(&m_rect); 
    saveParent=p_static->GetParent(); 
    p_static->SetParent(GetDesktopWindow()); 
    CRect  rect; 
    GetDesktopWindow()-> GetWindowRect(&rect); 
    p_static->SetWindowPos(&wndTopMost,rect.left,rect.top,rect.right,rect.bottom,SWP_SHOWWINDOW); 恢复代码: 
    p_static->SetParent(saveParent); 
    p_static->SetWindowPos(&wndTop,m_rect.left,m_rect.top,m_rect.right,m_rect.bottom,SWP_SHOWWINDOW); 
    p_static->SetParent(saveParent);
    p_static->GetWindowRect(m_rect); 
    ScreenToClient(m_rect); 
    p_static->MoveWindow(m_rect,FALSE); 
      

  11.   

    要保存句柄,p_static是GetDlgItem返回的临时对象指针,不能重复使用。另外,恢复的时候就不要再GetWindowRect了。
      

  12.   

    恢复代码: 
    p_static->SetParent(saveParent); 
    ScreenToClient(&m_rect); 
    p_static->MoveWindow(m_rect,FALSE);