Link to home
Start Free TrialLog in
Avatar of Meir Rivkin
Meir RivkinFlag for Israel

asked on

DC question

i'm using ExtTextOut() to draw a rectangle and put string in it.
               pDC->SetBkColor(RGB(255,255,128));
               pDC->ExtTextOut(coordX ,coordY, ETO_CLIPPED, NULL, szText, NULL);

how do i change the font and the color to be like the tooltip ?
Avatar of robpitt
robpitt

This should do the trick...


NONCLIENTMETRICS ncm;
CFont font,oldfont;

ncm.cnSize=sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof(ncm),&ncm,0);

font.CreateFontIndirect(&ncm.lfStatusFont)

pDC->SetBkColor(GetSysColor(INFOBK));
pDC->SetTextColor(GetSysColor(INFOTEXT));
oldfont=pDC->SelectObject(font);
pDC->ExtTextOut(....)
pDC->SelectObject(oldfont);

Avatar of Meir Rivkin

ASKER

robpitt:
my compiler doesn't familiar with INFOBK and INFOTEXT...?
ok got it, should be COLOR_INFOBK and COLOR_TEXT
i get an error:
error C2582: 'CFont' : 'operator =' function is unavailable

in this line:
oldfont=pDC->SelectObject(font);

???

Try adding a "&" i.e.
   SelectObject(&font)



ok its working but one more question, how to add a black border?
FrameRect
right but in FrameRect u need to give a rectangle but as u can see below i'm using ExtTextOut() which calculating the rect according to the length of the given string, the recrangle offset is the firsyt 2 arguments (coordX and coordY), so how can i retrieve this rectangle for the FrameRect?
u answer me that and u get 100 pts
u answer me that and u get 100 pts
ASKER CERTIFIED SOLUTION
Avatar of robpitt
robpitt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
robpitt: thank u mate