# DC output - changing it

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

how do I change the font used in a DC with TextOut() it defaults to a bold font and its ugly , I tried sending a WM_SETTEXT message but it does nothing I cant seem to get that working , but then that wouldnt change the font used in TextOut() would it?, also I want to be able to change the background colour of the text , can somebody point me in the right direction? , a link or example anything , thanks

##### Share on other sites
You need to load a font, and call SelectObject on the DC with it, for example:
HFONT hFont = (HFONT)GetStockObject(ANSI_VAR_FONT); // or create one hereSelectObject(hDC, hFont);// now call TextOut

To change the color use SetBkColor(hDC, RGB(r, g, b)) or what you probably want is SetBkMode(hDC, TRANSPARENT).

##### Share on other sites
That works pretty well , the text is still bold tho I used

GetStockObject(DEFAULT_GUI_FONT);

I'm sendin the text to an Edit control? is that why its still bold? , what i really wanna do is change the text in the edit control , I tried

SendMessage(hEdit, WM_SETTEXT, (WPARAM) "text",0);

but I think theres summin wrong with that , I dont think I've done it right

##### Share on other sites
Well for one thing, the text pointer goes in the 4th parameter of SendMessage for WM_SETTEXT, but its easier to just use SetWindowText:
SetWindowText(hEdit, "text")

##### Share on other sites
oh i see , silly me , thanks heh

##### Share on other sites

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628639
• Total Posts
2983972

• 10
• 18
• 20
• 13
• 9