I have an edit control which background color
depends from validity of user input.
If input is valid edit control should keep default look, else the background color should change to light gray.
I am checking validity in
EN_UPDATE
handler and if it is invalid I store the
HWND
of the edit control into
vector
.
Visual Styles
are enabled.
The problem comes when I change the position of the mouse pointer. Let me describe it:
1. I click on edit control and type invalid input.
2.
I move mouse pointer elsewhere, but edit control still has focus.
3. Now I delete invalid input by pressing backspace.
4.
As soon as input becomes valid the color changes properly,
but borders become thicker/darker.
These pictures illustrate the problem:
1. Edit control before typing in data:
http://pbrd.co/Scn5QK[
^]
2. Edit control when user pastes invalid data (
mouse pointer is in grey area ):
http://pbrd.co/Scnvqc[
^]
The last character is
r
.
3. Now if mouse pointer is
out of edit control's client area ( on dialog's client area for example ) and user deletes
r
here is what I get:
http://pbrd.co/ScnHWw[
^]
Notice the thicker border.
When mouse pointer hovers above the edit control it gets repainted properly.
Here are the relevant code snippets ( if needed I can submit a small
SSCCE ) :
case WM_COMMAND:
{
switch( LOWORD(wParam) )
{
case IDC_MYEDIT:
{
if( HIWORD(wParam) == EN_CHANGE )
{
if( )
{
}
}
}
break;
case WM_CTLCOLOREDIT:
{
if( )
{
SetBkMode( (HDC)wParam, TRANSPARENT );
return (INT_PTR)( (HBRUSH)GetStockObject( LTGRAY_BRUSH ) );
}
else
return DefWindowProc( ... ); }
How can I fix this?