Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,670 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,171 people online right now. Registration is fast and FREE... Join Now!




The command prompt...modified.

 
Reply to this topicStart new topic

The command prompt...modified., I need some quick help changing the appearance of the prompt box....

FreshBlood
post 5 Sep, 2008 - 01:52 AM
Post #1


New D.I.C Head

*
Joined: 4 Sep, 2008
Posts: 11

Okay, I'm doing a text-based RPG kind of thing as my first project. It's quite a jump from IRC (THANK GOD!) scripting, and it's been alot funner to learn. But, there's something I'm absolutely tired of seeing every time I check if my one line worked how I wanted it to..... The DOS box appearance. Now see, I'm not asking to start running graphics and such, I just want to use an image background as a general background. I was searching around for any and all appearance mods topics, and thus far have failed to find any. So, if you know of some that are easy to learn, (self teaching here... gotta keep it simpler for monkey.) can ya kick them my way? Appreciated!
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 5 Sep, 2008 - 01:59 AM
Post #2


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,441



Thanked 94 times

Dream Kudos: 2625

Expert In: ruling the world.

My Contributions


Try this snippet that I wrote:
http://www.dreamincode.net/code/snippet2176.htm

Note that it's Windows specific, but when setting colour in the console, it will usually be platform dependent.

Hope this helps smile.gif
User is online!Profile CardPM

Go to the top of the page

FreshBlood
post 5 Sep, 2008 - 02:21 AM
Post #3


New D.I.C Head

*
Joined: 4 Sep, 2008
Posts: 11

Cool cool, thanks. Will try to make sense of it biggrin.gif Quick question though... it's rather "noobish," I know... but I feel as though it needs to be asked. At least on my part.

CODE

SetColour (5);
std::cout << "This text should be colourful!" << std::endl;



Does SetColour (#); have to be followed with the rest? I was trying to find a way to integrate the topline in, but kinda stared blankly. I guess what I'm asking is if SetColour (#); sitting right above a cout would change that line of cout, and not need the void and whatnot? Mind you, I've no idea what void is, quite yet. tongue.gif Sorry for being intrusive and, I dunno, Slow I guess.

This is my first day actually coding, and I've been immersing myself a little more than my brain's comprehending at the time. And It is late. :PPP
User is offlineProfile CardPM

Go to the top of the page

gabehabe
post 5 Sep, 2008 - 04:16 AM
Post #4


Working Girl.

Group Icon
Joined: 6 Feb, 2008
Posts: 5,441



Thanked 94 times

Dream Kudos: 2625

Expert In: ruling the world.

My Contributions


That code could be a little difficult to understand if this is your first day of coding...

But here is an example, I think it's what you're looking for:

cpp
/*
* The simplest way to have colourful text in the console
* Author: Danny Battison
* Contact: gabehabe@hotmail.com
*/

#include <iostream> /* Standard input/output stream */
#include <windows.h> /* Standard Windows API header */

void SetColour (int index) /* Set the colour, just pass the index */
{
/* Pass the console handle and the index (param) to the Win API function */
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), index);
}

void ResetColour () /* Reset the colour to the default (white) */
{
/* Pass 7 as the colour for the original white text colour */
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}

int main()
{
std::cout << "This is the original colour for text..." << std::endl;
SetColour (5);
std::cout << "This text should be colourful!" << std::endl;
std::cout << "All text after SetColour(#) is colourful!" << std::endl;
ResetColour();
std::cout << "This is back to normal. sad.gif";

std::cin.get(); /* Hold the window open */
return EXIT_SUCCESS; /* The program was executed successfully */
}


Hope this helps smile.gif
User is online!Profile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 05:58AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month