CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Coloring Rect of Create(lpszText,dwstyle,&rect,parentwnd,nID) white

  1. #1
    Join Date
    Oct 2019
    Posts
    82

    Coloring Rect of Create(lpszText,dwstyle,&rect,parentwnd,nID) white

    I have below code

    Code:
    CStatic *text = new CStaic ;
    CRect textrect(10,20,70,50);
    MapDialogRect(&tectrect);
    
    text -> Create(name.data(),WS_CHILD | WS_VISIBLE | SS_RIGHT,textrect,this);
    The problem is text is displayed on rectangle with gray color. How can i paint that rectangle color to white?

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,817

    Re: Coloring Rect of Create(lpszText,dwstyle,&rect,parentwnd,nID) white

    Try to handle WM_CTLCOLORSTATIC message.

    BTW, have you solved your problem with Editbox control?
    Victor Nijegorodov

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,599

    Re: Coloring Rect of Create(lpszText,dwstyle,&rect,parentwnd,nID) white

    You really need to use the resource editor. You're developing a really bad habit.

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,817

    Re: Coloring Rect of Create(lpszText,dwstyle,&rect,parentwnd,nID) white

    Quote Originally Posted by Beginner_MFC View Post
    I have below code

    Code:
    CStatic *text = new CStaic ;
    CRect textrect(10,20,70,50);
    MapDialogRect(&tectrect);
    
    text -> Create(name.data(),WS_CHILD | WS_VISIBLE | SS_RIGHT,textrect,this);
    The problem is text is displayed on rectangle with gray color. How can i paint that rectangle color to white?
    You could also subclass this static control (deriving your own class from CStatic and overriding OnPaint method).
    I'd also recommend you to check out this site where you will find a lot of very useful tips and tricks including Changing Dialog Box/CFormView Color and many others.
    Victor Nijegorodov

  5. #5
    Join Date
    Oct 2019
    Posts
    82

    Re: Coloring Rect of Create(lpszText,dwstyle,&rect,parentwnd,nID) white

    Yes i solved editbox problem by passing correct parameters in CRect()

  6. #6
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,817

    Re: Coloring Rect of Create(lpszText,dwstyle,&rect,parentwnd,nID) white

    Quote Originally Posted by Beginner_MFC View Post
    Yes i solved editbox problem by passing correct parameters in CRect()
    Then it would be a good idea to share the solution and mark that thread as resolved!
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)