?
Solved

Text Color and Sound

Posted on 1998-03-07
4
Medium Priority
?
201 Views
Last Modified: 2006-11-17
How do you change the color of the text that is outputted with a normal output function like cout?
Also, how do you play sound?  I know about cout << '\007'; but there's a function that lets you
change the length and frequency of the sound.
0
Comment
Question by:Jose_G
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:q2guo
ID: 1183241
What compiler are your using, on what platform?
0
 

Author Comment

by:Jose_G
ID: 1183242
I don't know why that's important, but Borland C++ 5.01, Win32.
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1183243
For sound, you probably can use

#include <dos.h>

sound(x);
delay(time);
nosound();
where x is the frequency, time is in milliseconds

I am don't sure about changing the color of the output of cout
0
 
LVL 7

Accepted Solution

by:
galkin earned 100 total points
ID: 1183244
To change text color you must obtain device context of the window used as output window. You can get it with GetDC(). Then having HDC you can use SetTextColor. To play sound use PlaySound Win32 API function. Be sure to link your project with winmm.lib
and compiler with mmsystem.h

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question