Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 21st, 2005, 11:15 AM
Authorized User
 
Join Date: Jul 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Setting backGround Colour of a text

Hi Guys,

  Iam working on Vc++, & came across a problem.Hope someone could help!.

  Iam Using device Context for diplaying things to the view.

  Initially,I write a "text" to the view using "TextOut" method - See Code:

  & Then using the "BRUSH" object to fill the rectangle with that colour,using "FillRect" method.Now the "text" which was displayed in the same postion before is not Visible anymore .

  My need ,is after writing a "Text" to the view & filling the rectangle containing the text with a colour,want the underlying "text" to be visible(which is not the case now).

  Ofcourse,I know that If I set the BackgroundColour atfirst & then write the "text" to the screen,then the "text" will be visible.

  But I would not be able to do so co's of some restrictions in my Project...



  I want the text "Shading test" to be displayed with the blue background colour.Constraint being,I can't Fill the rectangle with the colour & then draw the text.....

Would be nice if someone could suggest something to do in this regard with respect to the code below.

Thanks......


    pDC->SetBkMode(TRANSPARENT);
     CRect rect;
    GetClientRect(rect);
    rect.SetRect(0,0,800,800);
    pDC->Rectangle(CRect(0,0,800,800));

    SIZE size;
    size.cx = 1000;
    size.cy = 1000;
    SetScrollSizes(MM_TEXT,size);

    pDC->TextOut(50,20,"Shading Test");

    CRect rect1;
    rect1.SetRect(10,10,300,100);
    pDC->Rectangle(CRect(10,10,300,100));
    CBrush brushBlue(RGB(240,248,255));
    CBrush* pOldBrush = pDC->SelectObject(&brushBlue);
    pDC->FillRect(rect1,&brushBlue);

Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Table row background colour changing meetravig Java GUI 0 September 21st, 2007 05:06 AM
Setting background image for gridvew cell anup_daware .NET Framework 2.0 0 September 17th, 2007 05:18 AM
Background colour/image printing ghari HTML Code Clinic 0 September 21st, 2006 01:05 PM
How to custom-define the default background colour ms_priya Java GUI 1 January 10th, 2006 05:28 PM
Setting Background color of the Stage with AS robprell Flash (all versions) 2 December 12th, 2005 02:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.