CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 1999
    Location
    Salisburyl UK
    Posts
    324

    quick question about changing background colour

    Hi All.

    I would like to change the BK colour of a CStatic object on my Dialog window.
    Is this possible without deriving my own CStatic class and changing the painting method?
    Also, how would I centre justify text within the CStatic object??

    Many Thanks
    Phill

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: quick question about changing background colour

    1. See the axample in MSDN article CWnd::OnCtlColor
    2. Using SS_CENTER style?
    Victor Nijegorodov

  3. #3
    Join Date
    Sep 1999
    Location
    Salisburyl UK
    Posts
    324

    Re: quick question about changing background colour

    Hi Victor
    Thanks for the reply.. and that would certainty do the job. However, for reasons best known to myself, I have an array of pointers to my CStatics from which I have created my objects, and I only want to change the BKColour of some of them.
    Would identifying the correct object within the OnCtlColor message handler be a problem since I dont know the ID?

    I have tried to change the colour at the point of creation by getting the CStatics CWnd CDC and using that to change the colour without success. Maybe Im being thick, but I cant see why that should'n work.

    Thanks again
    Phill

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: quick question about changing background colour

    Replace this line:
    Code:
       if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
    with something like:
    Code:
       if (pWnd == m_pStatic1 || pWnd == m_pStatic3 || ...)
    where m_pStatic1, m_pStatic3, ... - your "pointers to CStatics" which should have another bk-color
    Victor Nijegorodov

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