views:

246

answers:

0

hi, i have a problem with my children ;) i have a main-window (CWnd) to which i add several children (CWnd) to it. the usual behavior should be, that, no matter where i click on the child (e.g. to resize or move), the child comes to front. but thats not the case. only, when i exactly click on the caption.

any ideas how to correct that? thanks in advance

i use mfc on win7_32

class CChildWindow : public CWnd
{
    DECLARE_DYNAMIC(CChildWindow)
    DECLARE_MESSAGE_MAP()
public:
    CChildWindow(CWnd *pParent)
    : CWnd()
    {
     static LPCTSTR pClass;
     if(!pClass)
      pClass = AfxRegisterWndClass(CS_DBLCLKS|CS_PARENTDC|CS_HREDRAW|CS_VREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) GetStockObject(WHITE_BRUSH));

     CRect rcPos(100,100,300,300);
     CreateEx(WS_EX_TOOLWINDOW, pClass, "childwindow", WS_CLIPSIBLINGS | WS_CHILD | WS_THICKFRAME | WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_VISIBLE, rcPos, pParent, 0xFFFF);
    }
};

IMPLEMENT_DYNAMIC(CChildWindow, CWnd)
BEGIN_MESSAGE_MAP(CChildWindow, CWnd)
END_MESSAGE_MAP()

///////

class CParentWindow : public CWnd
{
    DECLARE_DYNAMIC(CParentWindow )
    DECLARE_MESSAGE_MAP()

    public:
    CParentWindow()
    : CWnd()
    {}

    int OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
     ModifyStyle(0, WS_CLIPCHILDREN);
     return CWnd::OnCreate(lpCreateStruct);
    }

    void OnLButtonDown(UINT nFlags, CPoint point)
    {
     Register( new CChildWindow(this) );
    }
};

IMPLEMENT_DYNAMIC(CParentWindow, CWnd)
BEGIN_MESSAGE_MAP(CParentWindow, CWnd)
    ON_WM_CREATE()
    ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()

related questions