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 » CExtGridCellIPAddress Collapse All
Subject Author Date
Ian McIntosh Dec 4, 2007 - 9:57 AM

These seem to only accept 2 digits per segment not the 3 required for a decimal ip address.
How do I correct this?

Technical Support Dec 5, 2007 - 8:30 AM

Thank you for reporting this issue. It seems this limitation is provided by the IP Address common control, which has so little width that is does not allow you to display all the digits. Here is the fix

bool CExtGridInplaceEditIPAddress::Create()
{
      ASSERT_VALID( this );
      ASSERT( m_hWnd == NULL );
      if( m_wndGrid.GetSafeHwnd() == NULL )
      {
            ASSERT( FALSE );
            delete this;
            return false;
      }
DWORD dwAreaFlags =
            CExtGridHitTestInfo::CellTypesToAreaFlags(
                  m_nColType,
                  m_nRowType
                  );
bool bFontMustBeDestroyed = false;
HFONT hCellFont =
            m_cell.OnQueryCellFont(
                  m_wndGrid,
                  m_nVisibleColNo,
                  m_nVisibleRowNo,
                  m_nColNo,
                  m_nRowNo,
                  m_nColType,
                  m_nRowType,
                  dwAreaFlags,
                  bFontMustBeDestroyed
                  );
HFONT hFont = hCellFont;
      if( hFont == NULL )
      {
            hFont = (HFONT)
                  m_wndGrid.OnSiwGetDefaultFont().GetSafeHandle();
            if( hFont == NULL )
                  hFont = (HFONT)
                        ::GetStockObject(DEFAULT_GUI_FONT);
            if( hFont == NULL )
            {
                  if( hFont == NULL )
                        hFont = (HFONT)
                              ::GetStockObject(SYSTEM_FONT);
                  if( hFont == NULL )
                  {
                        ASSERT( FALSE );
                        delete this;
                        return false;
                  }
            }
      }
LOGFONT lf;
      VERIFY( ::GetObject(hFont,sizeof(LOGFONT),&lf) );
      if(         bFontMustBeDestroyed 
            &&    hCellFont != NULL 
            )
            ::DeleteObject( hCellFont );
      if( ! m_font.CreateFontIndirect(&lf) )
      {
            ASSERT( FALSE );
            delete this;
            return false;
      }

UINT nDrawTextFlags =
            m_cell.OnQueryDrawTextFlags(
                  m_nVisibleColNo,
                  m_nVisibleRowNo,
                  m_nColNo,
                  m_nRowNo,
                  m_nColType,
                  m_nRowType,
                  dwAreaFlags,
                  0
                  );
      nDrawTextFlags;
bool bReadOnly = false;
bool bPassword = false;
COLORREF clrText = COLORREF(-1L);
COLORREF clrBack = COLORREF(-1L);
      m_cell.OnInplaceControlQueryStyle(
            m_wndGrid,
            this,
            m_nVisibleColNo,
            m_nVisibleRowNo,
            m_nColNo,
            m_nRowNo,
            m_nColType,
            m_nRowType,
            dwAreaFlags,
            bReadOnly,
            bPassword,
            clrBack,
            clrText
            );
COLORREF clrBackAll = m_cell.BackColorGet( CExtGridCell::__ECS_ALL );
COLORREF clrBackNormal = m_cell.BackColorGet( CExtGridCell::__ECS_NORMAL );
      if( clrBackAll != COLORREF(-1L) )
            clrBack = clrBackAll;
      else if( clrBackNormal != COLORREF(-1L) )
            clrBack = clrBackNormal;
      if( clrBack == COLORREF(-1L) )
            clrBack = m_wndGrid.OnSiwGetSysColor( COLOR_WINDOW );
      m_bInConstruction = true;

      { // BLOCK: client DC
            CClientDC dcMeasure( &m_wndGrid );
            CExtSafeString strMeasureText = _T("   000 . 000 . 000 . 000   ");
            CSize _sizeData = CExtPaintManager::stat_CalcTextDimension( dcMeasure, m_font, strMeasureText ).Size();
            CSize _sizeControl = m_rcInplaceControl.Size();
            _sizeData.cy += 2;
            if( _sizeControl.cx < _sizeData.cx )
                  m_rcInplaceControl.right = m_rcInplaceControl.left + _sizeData.cx;
            if( _sizeControl.cy < _sizeData.cy )
                  m_rcInplaceControl.bottom = m_rcInplaceControl.top + _sizeData.cy;
            CRect rcAlign = m_wndGrid.OnSwGetClientRect();
            if( m_rcInplaceControl.right > rcAlign.right )
                  m_rcInplaceControl.OffsetRect( rcAlign.right - m_rcInplaceControl.right, 0 );
            if( m_rcInplaceControl.left < rcAlign.left )
                  m_rcInplaceControl.OffsetRect( rcAlign.left - m_rcInplaceControl.left, 0 );
            if( m_rcInplaceControl.bottom > rcAlign.bottom )
                  m_rcInplaceControl.OffsetRect( 0, rcAlign.bottom - m_rcInplaceControl.bottom );
            if( m_rcInplaceControl.top < rcAlign.top )
                  m_rcInplaceControl.OffsetRect( 0, rcAlign.top - m_rcInplaceControl.top );
      } // BLOCK: client DC
      CExtGIE < CIPAddressCtrl >::Create(
            WS_CHILD|WS_VISIBLE,
            m_rcInplaceControl,
            &m_wndGrid,
            UINT( __EXT_MFC_IDC_STATIC )
            );          
      if( m_hWnd == NULL )
      {
            ASSERT( FALSE );
            delete this;
            return false;
      }
      SetFont( &m_font );
      CExtGridCellIPAddress * pCell = 
            DYNAMIC_DOWNCAST( CExtGridCellIPAddress, &m_cell );
      ASSERT( pCell != NULL );
      ASSERT_VALID( pCell );
DWORD dwCellStyle = m_cell.GetStyle();
      if(   (dwCellStyle&__EGCS_READ_ONLY) != 0 || bReadOnly )
            EnableWindow( FALSE );

      if(         (m_cell.GetStyleEx()&__EGCS_EX_UNDEFINED_ROLE) != 0 
            ||    m_cell.IsEmpty()
            )
            m_dwIPAddressPrevious = 0;
      else
            pCell->GetAddress( m_dwIPAddressPrevious );
      m_dwIPAddressInitial = m_dwIPAddressPrevious;
      SetAddress( m_dwIPAddressPrevious );
      SetWindowPos(
            &CWnd::wndTop,0,0,0,0,
            SWP_NOMOVE|SWP_NOSIZE
                  |SWP_NOACTIVATE
                  |SWP_FRAMECHANGED
                  |SWP_SHOWWINDOW
            );
      SetFocus();
      m_bInConstruction = false;
      g_pHookTarget = this;
      INT nIndexWnd = 0;
      for(  HWND hWnd = ::GetWindow( m_hWnd, GW_CHILD ); 
                  hWnd != NULL, nIndexWnd < 4; 
                  hWnd = ::GetWindow( hWnd, GW_HWNDNEXT ), nIndexWnd++ 
            )
      {
            m_hWndHooked[ nIndexWnd ] = hWnd;
            ASSERT( m_hWndHooked[ nIndexWnd ] != NULL );
            ASSERT( ::IsWindow(m_hWndHooked[ nIndexWnd ]) );
#if _MFC_VER >= 0x800
            m_pWNDPROC[ nIndexWnd ] = (WNDPROC)
                  ::SetWindowLongPtr(
                        m_hWndHooked[ nIndexWnd ],
                        __EXT_MFC_GWL_WNDPROC,
                        (DWORD_PTR)g_HookWndProc
                        );
#else
            m_pWNDPROC[ nIndexWnd ] = (WNDPROC)
                  ::SetWindowLong(
                        m_hWndHooked[ nIndexWnd ],
                        __EXT_MFC_GWL_WNDPROC,
                        (DWORD)g_HookWndProc
                        );
#endif
            ASSERT( m_pWNDPROC[ nIndexWnd ] != NULL );
      }
      return true;
}

Ian McIntosh Dec 5, 2007 - 1:22 AM

I can reproduce the problem using the simple grids sample by making the following changes in CDemoGrid::_InitDemoTable_Colors():

change
static LPCTSTR g_arrHdrNames[] = {_T("Sample"),_T("Text"),_T("Background")};
static INT g_arrHdrExtents[] = { 250, 150, 150 };
to
static LPCTSTR g_arrHdrNames[] = {_T("Sample"),_T("Text"),_T("Background"),_T("IP Address")};
static INT g_arrHdrExtents[] = { 250, 150, 150, 70 };

add
CExtGridCellIPAddress * pCellIpAddress =
         STATIC_DOWNCAST(
             CExtGridCellIPAddress,
             GridCellGet(
                 3L,
                 nRowNo,
                 0,
                 0,
                 RUNTIME_CLASS(CExtGridCellIPAddress)
                 )
             );
     pCellIpAddress->TextSet( "0.0.0.0" );

between
pCellColor->ModifyStyle( __EGCS_BUTTON_DROPDOWN|__EGCS_CHK_CHECK );
and
} // for( LONG nRowNo = 0L; nRowNo < nRowCount; nRowNo++ )

now build & run. go to the color tab and edit one of the IpAddresses. It only allows me to type in 2 digit numbers for each segment.

Technical Support Dec 4, 2007 - 11:47 AM

We tested this feature with the ProfUIS_Controls sample (the Grid page, the IP Address column) and found no problems. We successfully typed any 3-digit based numbers less or equal to 255 in each part of the in-place IP Address control activated by the IP Address grid cells. Please provide more details on how to reproduce this issue.