CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2008
    Posts
    26

    Refreshing the backcolor of an edit control

    In plain Win32 programming(No MFC) ,i wanted to change an edit control's foreground color(text color) and the entire edit control's background color. So i intercepted the wm_paint message and wm_ctlcoloredit.Code is

    wm_ctlcoloredit

    HDC hdc=(HDC)wParam;
    //COLORREF forecolor and backcolor are already defined
    SetBkMode(hdc,OPAQUE);
    SetTextColor(hdc,forecolor);
    SetBkColor(hdc,backcolor);

    wm_paint

    HDC thdc;
    PAINTSTRUCT ps;
    thdc=BeginPaint(hwnd,&ps); //hwnd is handle of the edit control
    RECT r;
    r.top = 0;
    r.left = 0;
    r.bottom = height - 4; //height is height of edit control
    r.right = width - 4; //width is widthof edit control
    FillRect(thdc,&r,CreateSolidBrush(backcolor));
    EndPaint(mem->hwnd,&ps);


    THE PROBLEM:-

    Let us say the backcolor is yellow.When the form has loaded, the edit control is filled with a yellow color and no text. However when i click the edit control it becomes ok and the text,forecolor and backcolor are displayed correctly. If i minimize and then maximize , same problem reoccurs. How do i fix this? (I am NOT intercepting wm_lbuttonup or any click messages so problem doesnt seem to relate to the click). Help.

  2. #2
    Join Date
    Apr 2008
    Posts
    26

    Re: Refreshing the backcolor of an edit control

    Please help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured