我现在可以使一个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);
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);
然后SetWindowPos 设置回来..
取得了以后,然后GetWindowRect()保存坐标到你的变量等...
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控件不见了
SetWindowPos的参数需要的是客户区坐标。
ScreenToClient(rcChild);
pwndChild->MoveWindow(rcChild,FALSE);
注意:GetWindowRect得到的是相对于屏幕的坐标,而设置位置时,具有WS_CHILD风格的控件使用的是其父窗口客户区内坐标。
另外,给控件改个ID,例如IDC_STATIC1,不要用IDC_STATIC。
还原不出来
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);
p_static->SetParent(saveParent);
ScreenToClient(&m_rect);
p_static->MoveWindow(m_rect,FALSE);