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 » DoDataExchange() being called twice when focus moves Collapse All
Subject Author Date
Richard Chaney Apr 25, 2007 - 2:53 PM

I have an edit control in a dialog which requires validation. I am using the ON_EN_KILLFOCUS message to validate the input when the edit loses focus. This event calls UpdateData(TRUE) and MFC automatically shows a message box like "Please enter an integer between 0 and 100" if the data is invalid.

The problem is that when the focus moves to a Prof-UIS control, e.g. CExtButton, the error message box pops up twice (the kill focus message also comes twice). However, moving focus to a standard CButton only causes it once. It seems moving focus to any Prof-UIS control causes the problem, while any normal MFC control does not.

I am using Prof-UIS 2.64 under Windows XP SP2 with VS2005. I can email a simple example project showing this problem if you wish.

Richard Chaney

Technical Support Apr 29, 2007 - 10:15 AM

Thank you for reporting this bug. We fixed it and the fix will be available in the next version. You can also fix this yourself by updating the source code for the CExtButton::OnLButtonDown() method (in ../Prof-UIS/ExtButton.cpp):

void CExtButton::OnLButtonDown(UINT nFlags, CPoint point) 
{
      if( m_bKeyTracking )
            return;
      CButton::OnLButtonDown( nFlags, point );
HWND hWndOwn = m_hWnd;
      if( IsWindowEnabled() )
      {
            CFrameWnd * pParentFrame = GetParentFrame();
            if(         pParentFrame != NULL
                  &&    pParentFrame->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) )
                  )
            {
                  CFrameWnd * pMDIFrame = pParentFrame->GetParentFrame();
                  if(         pMDIFrame != NULL
                        &&    pMDIFrame->IsKindOf( RUNTIME_CLASS(CMDIFrameWnd) )
                        )
                  {
                        CMDIChildWnd * pActive = ((CMDIFrameWnd*)pMDIFrame)->MDIGetActive();
                        if( LPVOID(pParentFrame) != LPVOID(pActive) )
                              ((CMDIChildWnd*)pParentFrame)->MDIActivate();
                  }
            }
            if( ! ::IsWindow( hWndOwn ) )
                  return;
            HWND hWndFocus = ::GetFocus();
            if( hWndFocus != hWndOwn )
            {
//                ::SetFocus( hWndOwn );
                  return; // DDX validation failed
            }
      } // if( IsWindowEnabled() )
      if( ! ::IsWindow( hWndOwn ) )
            return;
      _DoClick();
}

Here is the project we used for testing.