Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Is it a fatal defect of CExtControlBar? Collapse All
Subject Author Date
tera tera Mar 23, 2009 - 1:46 AM

Hello.


In the following procedures,

When we operate a bar , MDI freezes.


1, You double-click CView



2, You let a bar make a float and close a bar



3, MDI does not react



The test environment is Prof2.85 (2009-01-14).

http://ifreeta.dee.cc/20090323/SampleMDITest.lzh


 

Technical Support Mar 24, 2009 - 9:32 AM

View windows are specific in MFC. They are mainly designed as part of MFC’s document view architecture. Of course, you can use it without document connection like you did in dialog (CNxfRitsumenInDlg and CNxkCView) at your own risk, but results of such experiments sometimes can be really fun. That is what’s really happen in your project. The behavior problem after double clicking view and closing the floating bar is not a problem of Prof-UIS. This problem is brought by the following two methods in MFC source code:

void CView::OnActivateView(BOOL bActivate, CView* pActivateView, CView*)
{
            UNUSED(pActivateView);   // unused in release builds

            if (bActivate)
            {
                        ASSERT(pActivateView == this);

                        // take the focus if this frame/view/pane is now active
                        if (IsTopParentActive())
                                    SetFocus();
            }
}

void CView::OnActivateFrame(UINT /*nState*/, CFrameWnd* /*pFrameWnd*/)
{
}

int CView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
{
            int nResult = CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
            if (nResult == MA_NOACTIVATE || nResult == MA_NOACTIVATEANDEAT)
                        return nResult;   // frame does not want to activate

            CFrameWnd* pParentFrame = GetParentFrame();
            if (pParentFrame != NULL)
            {
                        // eat it if this will cause activation
                        ASSERT(pParentFrame == pDesktopWnd || pDesktopWnd->IsChild(pParentFrame));

                        // either re-activate the current view, or set this view to be active
                        CView* pView = pParentFrame->GetActiveView();
                        HWND hWndFocus = ::GetFocus();
                        if (pView == this &&
                                    m_hWnd != hWndFocus && !::IsChild(m_hWnd, hWndFocus))
                        {
                                    // re-activate this view
                                    OnActivateView(TRUE, this, this);
                        }
                        else
                        {
                                    // activate this view
                                    pParentFrame->SetActiveView(this);
                        }
            }
            return nResult;
}

Both methods do what is absolutely not needed for view window detached from document and created inside dialog. The CView::OnActivateView() invokes the SetFocus() even without view visibility check and even worst - without checking whether the view window is part of document view architecture. The CView::OnMouseActivate() has the same bad problems – it invokes the pParentFrame->SetActiveView(this) code without analyzing kind of view window and its connection with document object.

We fixed the problem in scope of your test project. We added the CNxkCView::OnActivateView() method which does not invoke parent class method. We handled the WM_MOUSEACTIVATE message in the CNxkCView::WindowProc() virtual method. Here is the modified version of your project:

http://www.prof-uis.com/download/forums/tmp/SampleMDITest_modified_for_tera_t.zip


tera tera Mar 25, 2009 - 1:13 AM

Hello.


In View, WM_MOUSEDOWN does not fly

This is fatal. 


Give my best regards.


 


LRESULT CNxkCView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)

{

 if( message == WM_MOUSEACTIVATE )

  return MA_ACTIVATEANDEAT;


    switch( message )

    {

    case WM_LBUTTONDOWN:

      {

       TRACE("MOUSE_DOWN \n");

      }

      break;

    }


    return CView::WindowProc(message, wParam, lParam);

}


 

Technical Support Mar 25, 2009 - 2:19 PM

The WM_LBUTTONDOWN messages are not received because of these two lines of code:

   if( message == WM_MOUSEACTIVATE )
                        return MA_ACTIVATEANDEAT;

You can replace them with:
   if( message == WM_MOUSEACTIVATE )
                        return MA_ACTIVATE;