There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Web & Email
Tag Cloud
acer asus bios blue screen boot bsod computer crash desktop driver drivers error excel freeze gaming hard drive hardware hdmi internet laptop malware memory motherboard mouse netgear network networking outlook printer problem router slow software sound svchost.exe toshiba trojan usb video video card virus vista wifi windows windows 7 windows 7 32 bit windows update windows xp wireless work
Search
Search for:
Tech Support Guy Forums > Internet & Networking > Web & Email >
Solved: C++: Text colors and sound

Reply  
Thread Tools
NormanSmiley's Avatar
Senior Member with 519 posts.
 
Join Date: Mar 1999
Location: Fayetteville, NC
24-Jan-2000, 07:38 PM #1
Post Solved: C++: Text colors and sound
I am making a program in C++ and want to change the colors of a couple of sentences (not the entire body of text). I have been told to use conio.h and supposed commands but haven't been able to get any of them to work. Can you please give me some help with this?

Also, I would like to add a line where the user is prompted if they want sound in the program:

cout << "Would you like sound?\n";
cout << "1. Yes\n2. No.";
cin >> SoundChoice
if (SoundChoice == 1)
{
what code should I put here???
}
else
{
cout << "No sound";
}

Can you please help me (I want to either play a wave file or a midi file). I am using Borland C++ 4.52.

Thanks.

------------------
NormanSmiley
My Page
Get paid to surf the net!

[This message has been edited by NormanSmiley (edited 01-24-2000).]
NormanSmiley's Avatar
Senior Member with 519 posts.
 
Join Date: Mar 1999
Location: Fayetteville, NC
25-Jan-2000, 01:40 PM #2
Either no one knows the answer or the 'Development' topic is hardly ever visited.

------------------
NormanSmiley
My Page
Get paid to surf the net!
YSB's Avatar
YSB YSB is offline
Senior Member with 781 posts.
 
Join Date: Mar 1999
Location: New York City
25-Jan-2000, 10:09 PM #3
Patience! I waited weeks for responses on some of my posts! There does seem to be a shortage of developers here but with patience you might still get a decent answer.

Frankly, I just saw this post now, since it's only been here a day. I'm not sure I could help much because my knowledge of C++ is limited but here are my thoughts anyway for whatever they're worth.

As far as conio.h goes, I went through all functions listed in that header some time ago on the MSDN looking for similar functions. I don't remember seeing anything useful to that end but I have to check again. I might just not remember.

As far as sound goes, I'm not sure how your playing the sound but the most simple solution would seem to me to create a variable that you check whenever you plan on playing sound.

if (soundchoice)
playsound();

I might be missing the point here, but my roots are in C with only limited training in C++. Even in C I'm not exactly an authority but if you post more details as to what the problem is, I might still be able to take a shot at it. (Assuming that my current answer is way off.)

If you have access to the MSDN there should be a listing of all the functions in conio.h if you want to check again. I believe it's now available for free at MS's site. If I have time later, I'll try to find it and post a link.

Good luck!

(And sorry about the delay )
NormanSmiley's Avatar
Senior Member with 519 posts.
 
Join Date: Mar 1999
Location: Fayetteville, NC
26-Jan-2000, 12:26 AM #4
Thanks for posting.

It's not that I have a problem, it's that I don't know how to do it. All I want is for a sound file to be played when the program is run, nothing fancy. I have looked in conio.h but couldn't make heads or tails of most of it. If you know how to do the colors in C, I would be happy to hear how.

I was told to do something like this:

texcolor(GREEN);
backgroundcolor(WHITE);

Something like that...I can't remember right off-hand. When compiling I get errors saying that it is an unknown variable or something like that. I know I am doing something wrong, but not sure exactly what.

------------------
NormanSmiley
My Page
Get paid to surf the net!

[This message has been edited by NormanSmiley (edited 01-25-2000).]
NormanSmiley's Avatar
Senior Member with 519 posts.
 
Join Date: Mar 1999
Location: Fayetteville, NC
26-Jan-2000, 12:30 AM #5
Upon reading over my post I think I might know what I need to do.

texcolor(GREEN); Looks like a Class of some sort so I have to define the class or something like that. (The whole subject of classes hasn't been easy for me to grasp, and pointers and references for that matter ).

I may be way wrong on this...that is why I am a complete novice in C++.

------------------
NormanSmiley
My Page
Get paid to surf the net!
YSB's Avatar
YSB YSB is offline
Senior Member with 781 posts.
 
Join Date: Mar 1999
Location: New York City
01-Feb-2000, 07:23 PM #6
First, I don't think that conio.h is the header you're looking for. The functions in conio.h are things like getch() and other input/output functions. I saw a mention in the MSDN to a graph.h but I couldn't actually find the header or any documentation about it. I also noticed a class that is supposed to affect text ouput color which was called CDC. (I think I got that right.) I don't know much of anything about it but maybe that could at least send you in the right direction.

As far as sound goes, again there are classes to handle that but as a C guy with no real knowledge of the MFC I don't know much about them.

Are there any C++ guys out there?

If noone else responds, I have a friend who does VC++ and I could run it by him next time I see him.
NormanSmiley's Avatar
Senior Member with 519 posts.
 
Join Date: Mar 1999
Location: Fayetteville, NC
07-Feb-2000, 06:01 PM #7
I finally found a solution for the problem:

I first had to change my program into a Standard DOS based one that uses BGI graphics. Then I just had to combine some C with the rest of my C++ code. Here are the basics:

#include "stdio.h"
#include "conio.h"

int main()
{
textcolor(GREEN);
cprintf("Text here");
return 0;
}

Using iostream.h will allow you to print to the screen using cout << and the color of the text will not be affected by the previous decleration. This is a good thing, as I only wanted a few main words highlighted.

I would prefer to have my program as a Win16 with only C++, but I haven't figured out the color codes for it yet.

Still boggled by sound...

------------------
NormanSmiley
My Page
Get paid to surf the net!

[This message has been edited by NormanSmiley (edited 02-07-2000).]
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:45 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.