Thanks David.. That worked. One more thing. If the dialog is a modeless dialog and if the user goes back to the main frame window and moves the window, the modeless dialog will go out of application. So for this i have added the WM_MOVING event in MainFrame class. void CMainFrame::OnMoving(UINT fwSide, LPRECT pRect) { //CFrameWnd::OnMoving(fwSide, pRect); HWND hWnd = pDlg->GetSafeHwnd(); RECT rc; RECT* pRc=&rc; rc.left=rc.top=rc.right=rc.bottom=0; LRESULT result = ::SendMessage(hWnd, WM_MOVING, (WPARAM)fwSide, (LPARAM)&rc); } and modified the WM_MOVING handler of Modeless Dialog as below. void CModelessDlg::OnMoving(UINT fwSide, LPRECT pRect) { CDialog::OnMoving(fwSide, pRect); CRect rcParent; if(pRect->right==0) //Calin from MainFrame GetWindowRect(pRect); GetOwner()->GetWindowRect(rcParent); // keep the child's left edge inside the parent's right edge pRect->left = min(pRect->left, rcParent.right - m_nWidth); // keep the child's left edge inside the parent's left edge pRect->left = max(pRect->left, rcParent.left); // keep the child's top edge inside the parent's bottom edge pRect->top = min(pRect->top, rcParent.bottom - m_nHeight); // keep the child's top edge inside the parent's top edge pRect->top = max(pRect->top, rcParent.top); // keep the child's right edge inside the parent's right edge pRect->right = min(pRect->right, rcParent.right); // keep the child's right edge inside the parent's left edge pRect->right = max(pRect->right, rcParent.left + m_nWidth); // keep the child's bottom edge inside the parent's bottom edge pRect->bottom = min(pRect->bottom, rcParent.bottom); // keep the child's bottom edge inside the parent's top edge pRect->bottom = max(pRect->bottom, rcParent.top + m_nHeight); if((rcParent.Width() < pRect->right - pRect->left) || (rcParent.Height() < pRect->bottom - pRect->top)) { this->ShowWindow(SW_HIDE); } else this->ShowWindow(SW_SHOW); this->MoveWindow(pRect); //Added by Arun } Once again Thanks a lot David..... :)
modified on Wednesday, May 5, 2010 5:31 AM