Thank you for reporting this issue. Please update the source code for the following method:
LRESULT CALLBACK CExtGridInplaceEditIPAddress::g_HookWndProc(
HWND hWnd,
UINT nMessage,
WPARAM wParam,
LPARAM lParam
)
{
if( g_pHookTarget != NULL && g_pHookTarget->GetSafeHwnd() != NULL )
{
if( nMessage == WM_GETDLGCODE )
return DLGC_WANTALLKEYS|DLGC_WANTCHARS|DLGC_WANTTAB;
if( g_pHookTarget->m_hWnd != NULL && ::IsWindow(g_pHookTarget->m_hWnd) )
{
if( nMessage == WM_KILLFOCUS )
{
if( g_pHookTarget->m_hWnd != (HWND)wParam
&& (!::IsChild( g_pHookTarget->m_hWnd, (HWND)wParam ))
)
{
g_pHookTarget->_DoEndEdit( true, 0 );
return 0L;
}
} // if( nMessage == WM_KILLFOCUS )
if( WM_KEYFIRST <= nMessage && nMessage <= WM_KEYLAST && _T(’0’) <= wParam && wParam <= _T(’9’) )
{
for( INT nIndexWnd = 0; nIndexWnd < 4; nIndexWnd++ )
{
HWND hWndHooked = g_pHookTarget->m_hWndHooked[ nIndexWnd ];
WNDPROC pWNDPROC = g_pHookTarget->m_pWNDPROC[ nIndexWnd ];
if( hWndHooked != NULL && ::IsWindow(hWndHooked) && hWndHooked == hWnd )
{
__EXT_DEBUG_GRID_ASSERT( pWNDPROC != NULL );
if( nMessage == WM_KEYDOWN )
{
TCHAR strCurrentText[ 5 ];
::memset( strCurrentText, 0, sizeof(strCurrentText) );
::GetWindowText( hWnd, strCurrentText, 4 );
INT nTextLength = INT(_tcslen(strCurrentText));
if( 0 < nTextLength && nTextLength <= 3 )
{
LONG nSelFrom = 0, nSelTo = 0;
::SendMessage( hWnd, EM_GETSEL, WPARAM(&nSelFrom), LPARAM(&nSelTo) );
if( nSelFrom < 0 )
nSelFrom = nTextLength;
nSelFrom = min( nSelFrom, nTextLength );
if( nSelTo < 0 )
nSelTo = nTextLength;
nSelTo = min( nSelTo, nTextLength );
LONG nFrom = min( nSelFrom, nSelTo ), nTo = max( nSelFrom, nSelTo );
__EXT_DEBUG_GRID_ASSERT( nFrom <= nTo );
nTo;
TCHAR str[1] = { TCHAR(0) };
::SendMessage( hWnd, EM_REPLACESEL, 0L, LPARAM(str) );
::SendMessage( hWnd, EM_SETSEL, nFrom, nFrom );
return 0L;
} // if( 0 < nTextLength && nTextLength <= 3 )
} // if( nMessage == WM_KEYDOWN )
else if( nMessage == WM_CHAR )
{
TCHAR strCurrentText[ 5 ], strNewWindowText[ 7 ];
::memset( strCurrentText, 0, sizeof(strCurrentText) );
::memset( strNewWindowText, 0, sizeof(strNewWindowText) );
::GetWindowText( hWnd, strCurrentText, 4 );
INT nTextLength = INT(_tcslen(strCurrentText));
if( nTextLength >= 3 )
return 0L;
LONG nNewSelPos = -1L;
if( nTextLength > 0 )
{
LONG nSelFrom = 0, nSelTo = 0;
::SendMessage( hWnd, EM_GETSEL, WPARAM(&nSelFrom), LPARAM(&nSelTo) );
if( nSelFrom < 0 )
nSelFrom = nTextLength;
nSelFrom = min( nSelFrom, nTextLength );
if( nSelTo < 0 )
nSelTo = nTextLength;
nSelTo = min( nSelTo, nTextLength );
LONG nFrom = min( nSelFrom, nSelTo ), nTo = max( nSelFrom, nSelTo );
__EXT_DEBUG_GRID_ASSERT( nFrom <= nTo );
INT nSavedIndex = 0, nCharIndex = 0;
for( ; nCharIndex < nFrom && nSavedIndex < 4; nCharIndex ++, nSavedIndex ++ )
strNewWindowText[ nSavedIndex ] = strCurrentText[ nCharIndex ];
strNewWindowText[ nSavedIndex ++ ] = TCHAR(wParam);
nNewSelPos = nSavedIndex;
for( nCharIndex = nTo; nCharIndex < nTextLength && nSavedIndex < 4; nCharIndex ++, nSavedIndex ++ )
strNewWindowText[ nSavedIndex ] = strCurrentText[ nCharIndex ];
} // if( nTextLength > 0 )
else
strNewWindowText[0] = TCHAR(wParam);
INT nFieldValue = INT( _ttol(strNewWindowText) );
if( ! ( 0 <= nFieldValue && nFieldValue <= 255 ) )
{
nNewSelPos = -1L;
nFieldValue = max( nFieldValue, 0 );
nFieldValue = min( nFieldValue, 255 );
__EXT_MFC_SPRINTF( __EXT_MFC_SPRINTF_PARAM( strNewWindowText, 3 ), _T("%d"), nFieldValue );
}
if( nNewSelPos < 0L )
nNewSelPos = LONG( _tcslen(strNewWindowText) );
::SetWindowText( hWnd, strNewWindowText );
::SendMessage( hWnd, EM_SETSEL, nNewSelPos, nNewSelPos );
return 0L;
} // else if( nMessage == WM_CHAR )
return ::CallWindowProc( pWNDPROC, hWnd, nMessage, wParam, lParam );
} // if( hWndHooked != NULL && ::IsWindow(hWndHooked) && hWndHooked == hWnd )
} // for( INT nIndexWnd = 0; nIndexWnd < 4; nIndexWnd++ )
return 0L;
} // if( WM_KEYFIRST <= nMessage && nMessage <= WM_KEYLAST && _T(’0’) <= wParam && wParam <= _T(’9’) )
if( nMessage == WM_KEYDOWN )
::SendMessage( g_pHookTarget->m_hWnd, nMessage, wParam, lParam );
} // if( g_pHookTarget->m_hWnd != NULL && ::IsWindow(g_pHookTarget->m_hWnd) )
for( INT nIndexWnd = 0; nIndexWnd < 4; nIndexWnd++ )
{
HWND hWndHooked = g_pHookTarget->m_hWndHooked[ nIndexWnd ];
WNDPROC pWNDPROC = g_pHookTarget->m_pWNDPROC[ nIndexWnd ];
if( hWndHooked != NULL && ::IsWindow(hWndHooked) && hWndHooked == hWnd )
{
__EXT_DEBUG_GRID_ASSERT( pWNDPROC != NULL );
return ::CallWindowProc( pWNDPROC, hWnd, nMessage, wParam, lParam );
} // if( hWndHooked != NULL && ::IsWindow(hWndHooked) && hWndHooked == hWnd )
} // for( INT nIndexWnd = 0; nIndexWnd < 4; nIndexWnd++ )
} // if( g_pHookTarget != NULL && g_pHookTarget->GetSafeHwnd() != NULL )
return 0L;
}