Solved

Text Color and Sound

Posted on 1998-03-07
4
193 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
Comment Utility
What compiler are your using, on what platform?
0
 

Author Comment

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

Expert Comment

by:q2guo
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now