vc吸附窗口

来源:互联网 发布:python编写shell脚本 编辑:程序博客网 时间:2024/05/01 22:25

 太意外了,一个小小的吸附窗口效果竟然很难找到,今天总算完成了特此纪念

 

pCDlgUsers=new CDlgUsers();
 pCDlgUsers->Create(CDlgUsers::IDD,this);

m_follow=TRUE;

 if (!pCDlgUsers->IsWindowVisible())
 {
  pCDlgUsers->ShowWindow(SW_SHOWDEFAULT);
  CRect   rect;  
  GetWindowRect(&rect); 
  m_x=rect.right;
  m_y=rect.top;
  pCDlgUsers->SetWindowPos(this,m_x,m_y,0,0,SWP_NOZORDER|SWP_NOSIZE);
 }

 

void CCrmDlg::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
{
 CDialog::OnWindowPosChanged(lpwndpos);
 // TODO: Add your message handler code here
 if (m_follow && pCDlgUsers->IsWindowVisible()) 
 {     
  CRect   rect;  
  GetWindowRect(&rect);    
   m_x=rect.right;
   m_y=rect.top;
   pCDlgUsers->SetWindowPos(this,m_x,m_y,0,0,SWP_NOZORDER|SWP_NOSIZE); 
 }
}

 m_follow=FALSE;

 if (pCDlgUsers!=NULL)
 {
  pCDlgUsers->DestroyWindow();
  delete pCDlgUsers;  
 }

原创粉丝点击