Modifying the background color of an IP address common control

The following code segment changes the background color of an edit control

  case WM_CTLCOLOREDIT:
    {
      HDC hdc = (HDC)wParam;
      SetTextColor(hdc, RGB(0,0,0));
      SetBkColor(hdc, RGB(196,196,169));
    }
    return (int)GetSysColorBrush(0);

I cannot figure out how to change the background color of an IP Address control.  I tried to disable the window to get it to grey out in a dialog box, but it looks the same as when enabled.  Would I have to subclass the control?  
KalvynAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nonubikCommented:
>Would I have to subclass the control?
Not necessarly. You can handle the control's parent WM_CTLCOLOR message. Check whether lParam is the handle to your IP Address control and then change the color.
0
KalvynAuthor Commented:
nonubik,  I tried

  case WM_CTLCOLOR:
    {
      HDC hdc = (HDC)wParam;
      SetTextColor(hdc, RGB(0,0,0));
      SetBkColor(hdc, RGB(196,196,169));
    }
    return (int)GetSysColorBrush(3);

which should change the background color of all controls, but a breakpoint at this point is never triggered.
0
nonubikCommented:
I found out more:
An IP Address control (SysIPAddress32 class) has 4 edit controls as children. Try subclassing all of them and change the background from there.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KalvynAuthor Commented:
Thanks for your input nonubik,  I ended up using the following procedure to subclass the address control

static long WINAPI IPClass1 (HWND hWnd, UINT message, UINT wParam,LONG lParam)
{
  switch (message)
  {
  case WM_ERASEBKGND:
    GetClientRect (hWnd,&rect);
    SelectObject((HDC)wParam,GetSysColorBrush(3));
    Rectangle((HDC)wParam,rect.left,rect.top,rect.right,rect.bottom);
    return 1;
  case WM_PAINT:
    GetClientRect (hWnd,&rect) ;
    BeginPaint(hWnd,&ps);
    app.DrawBitmap(ps.hdc,app.bmApp,0,0);
    EndPaint(hWnd,&ps);            
    return 0;
  case WM_CTLCOLOREDIT:
    {
      HDC hdc = (HDC)wParam;
      SetTextColor(hdc, RGB(0,0,0));
      SetBkColor(hdc, RGB(255,255,196));
    }
    return (int)app.hBrush;
  }
  return CallWindowProc (lpIPClass1,hWnd,message,wParam,lParam) ;
}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.