Fonts:
Using CreateFont method the
specific string can be displayed on the output window.
Syntax:
CreateFont(height,width,tilting,orientation,font_width,italic,underline,strike_thorugh,charset,out_precision,clipping_precision,quality,family,font_name);
Ex:
Void projView::OnDraw(CDC
*pDC)
{
CDC *pDC;
CFont mytext;
mytext.CreateFont(40,10,0,0,0,1,1,1,ANSI_CHARSET,0,0,0,0,”Arial”);
pDC->SelectObject(&mytext);
pDC->TextOut(100,200,”Hello World”);
}
Color:
We can display the string
using TextOut function. The color of this string can be changed using
SetTextColor and background color can be set using the methos SetBkColor.
Ex:
Void projView::OnDraw(CDC
*pDC)
{
pDC->SetBkColor(RGB(0,0,0));
pDC->SetTextColor(RGB(0,255,0));
pDC->TextOut(100,100,”Life is wonderful”);
}
Note: Here color
passed in these function is in RGB(Red,Green,Blue).
Red(R)
|
Green(G)
|
Blue(B)
|
Color
|
0
|
0
|
0
|
Black
|
255
|
0
|
0
|
Red
|
0
|
255
|
0
|
Green
|
0
|
0
|
255
|
Blue
|
255
|
255
|
0
|
Yellow
|
255
|
0
|
255
|
Magenta
|
0
|
255
|
255
|
Cyan
|
255
|
255
|
255
|
White
|
Pen & Brush:
Pen and Brush are the
graphical objects used to draw the object and to fill up these objects. Pen is
basically used for drawing line and shape border. The pen’s color and thickness
can be specified. Brush full up object area with specific color. Brush has style
to fill up area of the object.
Ex:
Void projView::OnDraw(CDC
*pDC)
{
CPen pen1(PS_DASH,1,RGB(0,0,0));
CBrush brush1(HS_CROSS,RGB(0,0,0));
pDC->SelectObject(&pen1);
pDC->SelectObject(&brush1);
pDC->Rectangle(100,100,500,500);
}
0 comments:
Post a Comment