Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Detecting a window within another window (http://www.go4expert.com/forums/detecting-window-window-t4078/)

zapper222 30Apr2007 09:06

Detecting a window within another window
 
I am trying to write an app using MFC which allows me to drag small dialogs around and drop them in static windows within a main dialog. The idea is, the small dialogs represent workers and the static windows represent work positions. The problem I am having is when I drop the second dialog in the same static window, it simply overlaps the first dialog so you can't tell there are two dialogs ( or three or four etc.).
I have been using this code to try and detect when the static has a dialog in it:
Code:

void CBoxes1Dlg::OnLButtonUp(UINT nFlags, CPoint point)
{
        CRect rect;
        CWnd *pWnd1;
        CPoint pt;
        int y=0;

        CWnd *pWnd = ChildWindowFromPoint(point);
        if(pWnd!=NULL) {
                pWnd->GetWindowRect(rect);
                ScreenToClient (rect);
                pt.x=rect.left+5;
                pt.y=rect.top+5;
                pWnd1=pWnd->ChildWindowFromPoint(pt,CWP_ALL);
               
                if(pWnd1 == pWnd){
                        // no dialog in this static box
                }else{
                        // handles don't match so must be a dialog in the static already
                }
        }
        m_person->SetWindowPos(&CWnd::wndTop,(pt.x),(pt.y),0,0,SWP_NOSIZE|SWP_NOZORDER);
}

This doesn't work properly.....
Anyone see the problem or think of an easier way to do it.

Thanks
Zapper


All times are GMT +5.5. The time now is 10:19.