?
Solved

Text Color and Sound

Posted on 1998-03-07
4
Medium Priority
?
200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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
Course of the Month10 days, 8 hours left to enroll

765 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