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
Solved

Text Color and Sound

Posted on 1998-03-07
4
195 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
  • 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 50 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

828 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