473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Text Color & Style Settings

71
This is, I'm sure, and easy question for most. I am a moderate C/C++ programmer in console based programs, I am looking to teach myself windows based programming though. I'm going through a book I bought and trying all of the exercises it gives to help me brush up on things.

One things I'm curious about, but can't find in the book, is how to change text color and style. I've got a character pointer with the text "Hello World" stored in it, then I'm drawing it into a box with the following line:

DrawText(hdc, szHello, strlen(szHello), &rt, DT_LEFT);

If I wanted to change the color of the text, what would I do to accomplish this?

Also, can anyone suggest some websites with useful tutorials that I should bookmark for references?

Any help would be greatly appreciated.
Oct 10 '07 #1
3 2749
Studlyami
464 Expert 256MB
Use the function SetTextColor( hdc, COLORREF); This will set the color of the font for a specific device context.

As for web sites for information Are you wanting MFC or WIN32?

www.codeproject.com has a lot of great tutorials are articles for both.
www.functionx.com has a lot of information on MFC items. It also contains some information on WIN32 as well.
www.msdn.com does it really need an explanation.

If your using WIN32 i recommend the book "Programming Windows" by Charles Petzold. If your using MFC I believe there is plenty of web resources for it, but learning some WIN32 wouldn't hurt.
Oct 10 '07 #2
Studlyami
464 Expert 256MB
Ahh I missed the styles part. For changing the styles you are going to want to creat a font object (createfont(. . .), there a several other ways for getting a font object google them) When you create the font you can specify all kinds of different styles. Look up createfont on msdn.com. You will also need to apply the font to the hdc. SelectObject(hdc, font).
Oct 10 '07 #3
rsteph
71
That worked thank you. And thank you for the sites.
Oct 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
4
by: sweep | last post by:
Hi there, I have a problem with some CSS I'm writing and I was looking for a little help. I have a nav bar at the top and left side of my page in CSS which work fine. The remaining space has a...
4
by: drew197 | last post by:
I am a newbie. I am editing someone elses code to make it compatible with Firefox and Safari. In IE, when you click on the proper link, a block of text is shown in a nice paragraph form. But, in...
2
by: Graeme | last post by:
Hi there Yet another daft question. Can I fill a css defined box with a text character such that the box can be set to say, 85% page width, and the text character fills the bos to that width,...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
13
by: =?Utf-8?B?S2VzdGZpZWxk?= | last post by:
Hi Our company has a .Net web service that, when called via asp.net web pages across our network works 100%! The problem is that when we try and call the web service from a remote machine, one...
1
by: dhaneshrs | last post by:
I have a small code that shows inactive and active users from the ms access DB. <%@ Page Language="VB" MasterPageFile="~/MasterPageAdmin.master" Title="Welcome" %> <%@ Import...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.