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:

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

        CWnd *pWnd = ChildWindowFromPoint(point);
        if(pWnd!=NULL) {
                ScreenToClient (rect);
                if(pWnd1 == pWnd){
                        // no dialog in this static box
                        // handles don't match so must be a dialog in the static already

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


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