CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 1999
    Location
    Germany
    Posts
    130

    Text/background color

    Hi,

    My control outputs text in a window.
    If I change the backgroundcolor to, say, black,
    and the textcolor to green, then the letters are
    still on a white background.
    Although the background without text is black.

    How can I get green letters on a completely black background ?

    Thanks,

    PUH



  2. #2
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: Text/background color

    In the MSDN documentation :


    The background color for a character is specified by the SetBkColor and SetBkMode member functions of the CDC class.

    This help ?


    Roger Allen
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

  3. #3
    Join Date
    Apr 1999
    Location
    romania
    Posts
    43

    Re: Text/background color

    Hi,
    you have to make the control transparent . If you are using an Edit control you have to implement the
    OnCtlColor() function.
    ccode
    HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    switch(nCtlColor)
    {
    case CTLCOLOR_EDIT:
    {
    pDC->SetBkMode(TRANSPARENT);
    return myNewBrush;
    }
    }
    return myOldBrush;
    }
    //where myNewBrush is a brush made with your desired color
    //and myOldBrush is a grey one.
    /ccode


  4. #4
    Join Date
    Jul 1999
    Location
    Zagreb, Croatia
    Posts
    63

    Re: Text/background color

    in *.cpp not *Dlg.cpp put SetDialogBkColor...
    -------------------------------------------------

    BOOL COcdApp::InitInstance()
    {
    AfxEnableControlContainer();

    //*************THIS**************************
    SetDialogBkColor(RGB(0, 0, 0), RGB(0, 0, 255));
    //*******************************************

    // Standard initialization
    // If you are not using these features and wi...


  5. #5
    Join Date
    Jul 1999
    Location
    Zagreb, Croatia
    Posts
    63

    Re: Text/background color

    No, Roger, not enough

    Well, I put static text. Colored (green fonts on black). For background, I load bitmap picture on way: ClassWizard->InsertActiveX Control..->choose Microsoft Forms 2.0 Image -> this creates frame, then go to properties->All->choose picture and in right cell click mice->find the *.bmp picture in directory ... and this is it. Stuffs works great.
    (Thanx M$).
    And now, how to make my static text transparent, without black background?
    I find some "tetris" whatever example, some hints (which are far away from "hinting" me...) So, who would be so kind, and dummy me tell how to make this letters transparent, without background?
    Thanx.


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