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);
|