开发者

Changing color of a edit control in WInCE (win32)

开发者 https://www.devze.com 2023-01-24 06:02 出处:网络
I have created a edit control with ES_PASSWORD . I want to change the color of my static box to grey.

I have created a edit control with ES_PASSWORD . I want to change the color of my static box to grey.

case WM_CTLCOLOREDIT:
{
    HDC  hdc  = (HDC)  wParam ;             
   开发者_开发知识库 SetBkMode( hdc, RGB(65, 65, 65));
    return (LRESULT)GetStockObject(NULL_BRUSH);            
 }

But still by edit control is white color :(

Please help me. If there are more then one edit control , is there to h


Your message handler should look like this:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

  switch (message) 
  {

      case WM_CTLCOLOREDIT:
      {
          HBRUSH hBrush = CreateSolidBrush(RGB(255,0,0));
          ::SelectObject((HDC)wParam, (HGDIOBJ)hBrush);
          break;
      }
      default:
          return DefWindowProc(hWnd, message, wParam, lParam);
  }

  return 0;
}

Make sure you don't cal DefWindowProc, that will defeat the override.

0

精彩评论

暂无评论...
验证码 换一张
取 消