Jump to content
  • Advertisement
Sign in to follow this  
stealth

DC output - changing it

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 here
SelectObject(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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!