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 » CExtGridCellInplaceSlider question Collapse All
Subject Author Date
David Skok Aug 20, 2007 - 12:16 PM

I am using the CExtGridCellInplaceSlider in a CExtGridWnd. I monitor changes in cell value by overriding OnScrollPosSet. If I drag the slider or use Alt+left right arrow keys this function is called with pWndGrid valid which has been working fine. I recently noticed that if I set the value directly by entering the number OnScrollPosSet is called with pWndGrid set to NULL. I need pWndGrid to ultimately get the pointer to the document that needs to be altered. It appears that the only way I can do that in the case of direct entry is by overriding OnInplaceControlTextInputComplete. Is there some other central location that I might catch where the scroll position is being set that includes a valid pWndGrid so that I do not have to override two functions?

Technical Support Aug 21, 2007 - 6:17 AM

Please look at the following method declaration in the CExtGridCellInplaceSlider class:

virtual ULONG ScrollPosSet( ULONG nScrollPos );
virtual ULONG OnScrollPosSet(
      ULONG nScrollPos,
      CExtGridWnd * pWndGrid = NULL,
      LONG nColNo = 0L,
      LONG nRowNo = 0L,
      INT nColType = 0,
      INT nRowType = 0
      );
Here is the source code of the ScrollPosSet() method which simply calls OnScrollPosSet():
ULONG CExtGridCellInplaceSlider::ScrollPosSet( ULONG nScrollPos )
{
      ASSERT_VALID( this );
      return OnScrollPosSet( nScrollPos );
}
That means you can call directly the OnScrollPosSet() method and specify all the needed parameters.

David Skok Aug 21, 2007 - 7:11 AM

Thank you for the response.

I looked further and would like to suggest that you change the source to CExtGridCellInplaceSlider::OnInplaceControlTextInputComplete as follows:

// Remove
//            ScrollPosSet( nVal );

// Put in it’s place
     OnScrollPosSet(
         nVal,
         &wndGrid,
         nColNo,
         nRowNo,
         nColType,
         nRowType );

Currently OnScrollPosSet is hit if an individual uses direct entry, drags the slider or uses Alt+arrow keys however in the case of direct entry not all of the parameters are filled in if direct entry is used. Why use ScrollPosSet when it is possible to directly call OnScrollPosSet in OnInplaceControlTextInputComplete. This way a user of this cell type can catch a changed value by overriding one method rather than two and always count on having the parameters filled in. PS - ScrollPosSet is NOT called when a user drags the slider or uses the Alt+arrow keys anyway and even so overriding it is likely to have little value if cells don’t know where they are or what grid they are in.

Just a suggestion.

Technical Support Aug 22, 2007 - 11:11 AM

We are agree with you completely. Thank you. Here is the updated source code

void CExtGridCellInplaceSlider::OnInplaceControlTextInputComplete(
      HWND hWndInplaceControl,
      CExtGridWnd & wndGrid,
      LONG nVisibleColNo,
      LONG nVisibleRowNo,
      LONG nColNo,
      LONG nRowNo,
      INT nColType,
      INT nRowType,
      __EXT_MFC_SAFE_LPCTSTR sTextNew,
      bool bSaveChanges
      )
{
      ASSERT_VALID( this );
      ASSERT( hWndInplaceControl != NULL && ::IsWindow(hWndInplaceControl) );
      ASSERT_VALID( (&wndGrid) );
      if( bSaveChanges )
      {
            TCHAR * strStop = NULL;
            ULONG nVal = 0L;
            nVal = _tcstoul( LPCTSTR(sTextNew), &strStop, 10 );
            if( nVal != ULONG_MAX )
            {
                  if( nVal < 0L )
                        nVal = 0L;
                  if( nVal > m_nScrollTotalRange )
                        nVal = m_nScrollTotalRange;
//                ScrollPosSet( nVal );
                  OnScrollPosSet(
                        nVal,
                        &wndGrid,
                        nColNo,
                        nRowNo,
                        nColType, 
                        nRowType
                        );
            }
      }
      wndGrid.OnGridCellInplaceControlTextInputComplete(
            *this,
            hWndInplaceControl,
            nVisibleColNo,
            nVisibleRowNo,
            nColNo,
            nRowNo,
            nColType,
            nRowType,
            sTextNew,
            bSaveChanges
            );
}